Class NTriplesUtil


  • public final class NTriplesUtil
    extends java.lang.Object

    Utilities for reading and writing NTriples

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String escapeString​(java.lang.String label)
      Escapes a Unicode string to an all-ASCII character sequence.
      static void escapeString​(java.lang.String label, java.lang.Appendable appendable)
      Escapes a Unicode string to an all-ASCII character sequence.
      static void escapeString​(java.lang.String label, java.lang.Appendable appendable, boolean escapeUnicode)
      Escapes a Unicode string to an N-Triples compatible character sequence.
      static boolean isBnodeLabelChar​(int c)  
      static boolean isLetter​(int c)
      Checks whether the supplied character is a letter according to the N-Triples specification.
      static boolean isLetterOrNumber​(int c)
      Checks whether the supplied character is a letter or number according to the N-Triples specification.
      static boolean isNumber​(int c)
      Checks whether the supplied character is a number according to the N-Triples specification.
      static boolean isStartingBnodeLabelChar​(int c)
      Is the var valid as the first char in a bnode label?
      static java.lang.String toHexString​(int decimal, int stringLength)
      Converts a decimal value to a hexadecimal string represention of the specified length.
      static java.lang.String unescapeString​(java.lang.String s)
      Unescapes an escaped Unicode string.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • isLetterOrNumber

        public static boolean isLetterOrNumber​(int c)
        Checks whether the supplied character is a letter or number according to the N-Triples specification.
        See Also:
        isLetter(int), isNumber(int)
      • isLetter

        public static boolean isLetter​(int c)
        Checks whether the supplied character is a letter according to the N-Triples specification. N-Triples letters are A - Z and a - z.
      • isNumber

        public static boolean isNumber​(int c)
        Checks whether the supplied character is a number according to the N-Triples specification. N-Triples numbers are 0 - 9.
      • isStartingBnodeLabelChar

        public static boolean isStartingBnodeLabelChar​(int c)
        Is the var valid as the first char in a bnode label?
      • isBnodeLabelChar

        public static boolean isBnodeLabelChar​(int c)
      • unescapeString

        public static java.lang.String unescapeString​(java.lang.String s)
        Unescapes an escaped Unicode string. Any Unicode sequences ( \uxxxx and \Uxxxxxxxx) are restored to the value indicated by the hexadecimal argument and any backslash-escapes ( \", \\, etc.) are decoded to their original form.
        Parameters:
        s - An escaped Unicode string.
        Returns:
        The unescaped string.
        Throws:
        java.lang.IllegalArgumentException - If the supplied string is not a correctly escaped N-Triples string.
      • escapeString

        public static java.lang.String escapeString​(java.lang.String label)
        Escapes a Unicode string to an all-ASCII character sequence. Any special characters are escaped using backslashes (" becomes \", etc.), and non-ascii/non-printable characters are escaped using Unicode escapes (\uxxxx and \Uxxxxxxxx).
      • escapeString

        public static void escapeString​(java.lang.String label,
                                        java.lang.Appendable appendable)
                                 throws java.io.IOException
        Escapes a Unicode string to an all-ASCII character sequence. Any special characters are escaped using backslashes (" becomes \", etc.), and non-ascii/non-printable characters are escaped using Unicode escapes (\uxxxx and \Uxxxxxxxx).
        Throws:
        java.io.IOException
      • escapeString

        public static void escapeString​(java.lang.String label,
                                        java.lang.Appendable appendable,
                                        boolean escapeUnicode)
                                 throws java.io.IOException
        Escapes a Unicode string to an N-Triples compatible character sequence. Any special characters are escaped using backslashes (" becomes \", etc.), and non-ascii/non-printable characters are escaped using Unicode escapes (\uxxxx and \Uxxxxxxxx) if the option is selected.
        Throws:
        java.io.IOException
        Since:
        2.8.0
      • toHexString

        public static java.lang.String toHexString​(int decimal,
                                                   int stringLength)
        Converts a decimal value to a hexadecimal string represention of the specified length.
        Parameters:
        decimal - A decimal value.
        stringLength - The length of the resulting string.