Package com.stardog.stark.io.ntriples
Class NTriplesUtil
java.lang.Object
com.stardog.stark.io.ntriples.NTriplesUtil
Utilities for reading and writing NTriples
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringescapeString(String label) Escapes a Unicode string to an all-ASCII character sequence.static voidescapeString(String label, Appendable appendable) Escapes a Unicode string to an all-ASCII character sequence.static voidescapeString(String label, Appendable appendable, boolean escapeUnicode) Escapes a Unicode string to an N-Triples compatible character sequence.static booleanisBnodeLabelChar(int c) static booleanisLetter(int c) Checks whether the supplied character is a letter according to the N-Triples specification.static booleanisLetterOrNumber(int c) Checks whether the supplied character is a letter or number according to the N-Triples specification.static booleanisNumber(int c) Checks whether the supplied character is a number according to the N-Triples specification.static booleanisStartingBnodeLabelChar(int c) Is the var valid as the first char in a bnode label?static StringtoHexString(int decimal, int stringLength) Converts a decimal value to a hexadecimal string represention of the specified length.static StringUnescapes an escaped Unicode string.
-
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
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
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
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
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.
-