Class Util


  • public class Util
    extends java.lang.Object
    Some utility functions.
    • Constructor Summary

      Constructors 
      Constructor Description
      Util()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean isLangString​(Node n)
      A Node is a language string if it has a language tag.
      static boolean isLangString​(Literal lit)
      Return true if the literal has a language tag.
      static boolean isSimpleString​(Node n)
      A Node is a simple string if: (RDF 1.0) No datatype and no language tag.
      static boolean isSimpleString​(Literal lit)
      Return true if the literal is a simple string.
      static boolean notNameChar​(char ch)
      answer true iff this is not a legal NCName character, ie, is a possible split-point start.
      static java.lang.String replace​(java.lang.String s, java.lang.String oldString, java.lang.String newString)  
      static int splitNamespaceXML​(java.lang.String uri)
      Given an absolute URI, determine the split point between the namespace part and the localname part.
      static java.lang.String substituteEntitiesInElementContent​(java.lang.String s)
      Answer s modified to replace <, >, and & by their corresponding entity references.
      static java.lang.String substituteEntitiesInEntityValue​(java.lang.String s)  
      static java.lang.String substituteStandardEntities​(java.lang.String s)  
      • Methods inherited from class java.lang.Object

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

      • Util

        public Util()
    • Method Detail

      • splitNamespaceXML

        public static int splitNamespaceXML​(java.lang.String uri)
        Given an absolute URI, determine the split point between the namespace part and the localname part. If there is no valid localname part then the length of the string is returned. The algorithm tries to find the longest NCName at the end of the uri, not immediately preceeded by the first colon in the string.

        This operation follows XML QName rules which are more complicated than needed for Turtle and TriG. For example, QName can't start with a digit.

        Parameters:
        uri -
        Returns:
        the index of the first character of the localname
        See Also:
        SplitIRI
      • notNameChar

        public static boolean notNameChar​(char ch)
        answer true iff this is not a legal NCName character, ie, is a possible split-point start.
      • substituteStandardEntities

        public static java.lang.String substituteStandardEntities​(java.lang.String s)
      • substituteEntitiesInEntityValue

        public static java.lang.String substituteEntitiesInEntityValue​(java.lang.String s)
      • substituteEntitiesInElementContent

        public static java.lang.String substituteEntitiesInElementContent​(java.lang.String s)
        Answer s modified to replace <, >, and & by their corresponding entity references.

        Implementation note: as a (possibly misguided) performance hack, the obvious cascade of replaceAll calls is replaced by an explicit loop that looks for all three special characters at once.

      • replace

        public static java.lang.String replace​(java.lang.String s,
                                               java.lang.String oldString,
                                               java.lang.String newString)
      • isSimpleString

        public static boolean isSimpleString​(Node n)
        A Node is a simple string if:
      • (RDF 1.0) No datatype and no language tag.
      • (RDF 1.1) xsd:string