Class PrefixLib

java.lang.Object
org.apache.jena.riot.system.PrefixLib

public class PrefixLib extends Object
Algorithms over PrefixMap to abbreviate and expand
  • Constructor Details

    • PrefixLib

      public PrefixLib()
  • Method Details

    • canonicalPrefix

      public static String canonicalPrefix(String prefix)
      Remove ":" from a prefix if necessary to make it canonical.
      Parameters:
      prefix -
      Returns:
      prefix, without colon.
    • canonicalGraphName

      public static org.apache.jena.graph.Node canonicalGraphName(org.apache.jena.graph.Node graphName)
      Canonical name for graphs
    • abbreviate

      public static String abbreviate(PrefixMap prefixes, String uriStr)
      Abbreviate a uriStr, giving a string as a short form. If not possible return null. This does not guarantee that the result is suitable for all RDF syntaxes. Further checking for the rules of a particular syntax are necessary.
    • abbrev

      public static org.apache.jena.atlas.lib.Pair<String,String> abbrev(PrefixMap prefixes, String uriStr)
      Abbreviate a uriStr, return the prefix and local parts. This does not guarantee that the result is suitable for all RDF syntaxes.
    • abbrev

      public static org.apache.jena.atlas.lib.Pair<String,String> abbrev(Map<String,String> prefixesMap, String uriStr, boolean turtleSafeLocalPart)
      Abbreviate a uriStr, return the prefix and local parts, using a Map of prefix string to URI string. This does not guarantee that the result is suitable for all RDF syntaxes. In addition, perform a fast check for legal turtle local parts using isSafeLocalPart(java.lang.String). This covers the majority of real work cases and allows the code to find a probably-legal abbrev pair if an illegal one is found. (In practice, illegal local names arise only when one prefix URI is a substring of another.)
    • expand

      public static String expand(PrefixMap prefixes, String prefixedName)
      Expand a prefixedName which must include a ':'
    • expand

      public static String expand(PrefixMap prefixes, String prefix, String localName)
      Expand a prefix, local name pair.
    • isSafeLocalPart

      public static boolean isSafeLocalPart(String localName)
      Is a local name safe? This is a partial, fast check for Turtle-like local names.
      Parameters:
      localName - Local name
      Returns:
      True if safe, false otherwise