Class PrefixLib


  • public class PrefixLib
    extends java.lang.Object
    Algorithms over PrefixMap to abbreviate and expand
    • Constructor Summary

      Constructors 
      Constructor Description
      PrefixLib()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.apache.jena.atlas.lib.Pair<java.lang.String,​java.lang.String> abbrev​(java.util.Map<java.lang.String,​java.lang.String> prefixesMap, java.lang.String uriStr, boolean turtleSafeLocalPart)
      Abbreviate a uriStr, return the prefix and local parts, using a Map of prefix string to URI string.
      static org.apache.jena.atlas.lib.Pair<java.lang.String,​java.lang.String> abbrev​(PrefixMap prefixes, java.lang.String uriStr)
      Abbreviate a uriStr, return the prefix and local parts.
      static java.lang.String abbreviate​(PrefixMap prefixes, java.lang.String uriStr)
      Abbreviate a uriStr, giving a string as a short form.
      static Node canonicalGraphName​(Node graphName)
      Canonical name for graphs
      static java.lang.String canonicalPrefix​(java.lang.String prefix)
      Remove ":" from a prefix if necessary to make it canonical.
      static java.lang.String expand​(PrefixMap prefixes, java.lang.String prefixedName)
      Expand a prefixedName which must include a ':'
      static java.lang.String expand​(PrefixMap prefixes, java.lang.String prefix, java.lang.String localName)
      Expand a prefix, local name pair.
      static boolean isSafeLocalPart​(java.lang.String localName)
      Is a local name safe? This is a partial, fast check for Turtle-like local names.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PrefixLib

        public PrefixLib()
    • Method Detail

      • canonicalPrefix

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

        public static Node canonicalGraphName​(Node graphName)
        Canonical name for graphs
      • abbreviate

        public static java.lang.String abbreviate​(PrefixMap prefixes,
                                                  java.lang.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<java.lang.String,​java.lang.String> abbrev​(PrefixMap prefixes,
                                                                                                     java.lang.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<java.lang.String,​java.lang.String> abbrev​(java.util.Map<java.lang.String,​java.lang.String> prefixesMap,
                                                                                                     java.lang.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 java.lang.String expand​(PrefixMap prefixes,
                                              java.lang.String prefixedName)
        Expand a prefixedName which must include a ':'
      • expand

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

        public static boolean isSafeLocalPart​(java.lang.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