Class NTriplesUtil

java.lang.Object
com.stardog.stark.io.ntriples.NTriplesUtil

public final class NTriplesUtil extends Object

Utilities for reading and writing NTriples

  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    Escapes a Unicode string to an all-ASCII character sequence.
    static void
    escapeString(String label, Appendable appendable)
    Escapes a Unicode string to an all-ASCII character sequence.
    static void
    escapeString(String label, Appendable appendable, boolean escapeUnicode)
    Escapes a Unicode string to an N-Triples compatible character sequence.
    static boolean
     
    static boolean
    isLetter(int c)
    Checks whether the supplied character is a letter according to the N-Triples specification.
    static boolean
    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
    Is the var valid as the first char in a bnode label?
    static String
    toHexString(int decimal, int stringLength)
    Converts a decimal value to a hexadecimal string represention of the specified length.
    static String
    Unescapes an escaped Unicode string.

    Methods inherited from class java.lang.Object

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

    • 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

      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 String unescapeString(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:
      IllegalArgumentException - If the supplied string is not a correctly escaped N-Triples string.
    • escapeString

      public static String escapeString(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(String label, Appendable appendable) throws 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:
      IOException
    • escapeString

      public static void escapeString(String label, Appendable appendable, boolean escapeUnicode) throws 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:
      IOException
      Since:
      2.8.0
    • toHexString

      public static 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.