Class TurtleUtil
- java.lang.Object
-
- org.eclipse.rdf4j.rio.turtle.TurtleUtil
-
public class TurtleUtil extends Object
Utility methods for Turtle encoding/decoding.- See Also:
- Turtle: Terse RDF Triple Language
-
-
Field Summary
Fields Modifier and Type Field Description static char[]LOCAL_ESCAPED_CHARS
-
Constructor Summary
Constructors Constructor Description TurtleUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static StringdecodeString(String s)Decodes an encoded Turtle string.static StringencodeLongString(String s)Encodes the supplied string for inclusion as a long string in a Turtle document.static StringencodeString(String s)Encodes the supplied string for inclusion as a 'normal' string in a Turtle document.static StringencodeURIString(String s)Deprecated.static intfindURISplitIndex(String uri)Tries to find an index where the supplied URI can be split into a namespace and a local name that comply with the serialization constraints of the Turtle format.static booleanisBLANK_NODE_LABEL_Char(int codePoint)Check if the supplied code point represents a valid blank node label character.static booleanisBLANK_NODE_LABEL_EndChar(int codePoint)Check if the supplied code point represents a valid blank node label end character.static booleanisBLANK_NODE_LABEL_StartChar(int codePoint)Check if the supplied code point represents a valid start character for a blank node label.static booleanisLanguageChar(int codePoint)Check if the supplied code point represents a valid language tag character.static booleanisLanguageStartChar(int codePoint)Check if the supplied code point represents a valid language tag start character.static booleanisLocalEscapedChar(int codePoint)Check if the supplied code point represents a valid local escaped character.static booleanisNameChar(int codePoint)Check if the supplied code point represents a valid name character.static booleanisNameEndChar(int codePoint)Check if the supplied code point represents a valid name end character.static booleanisNameStartChar(int codePoint)Check if the supplied code point represents a valid name start character.static booleanisPERCENT(String name)static booleanisPLX_INTERNAL(String name)static booleanisPLX_START(String name)static booleanisPN_CHARS(int codePoint)Check if the supplied code point represents a valid prefixed name character.static booleanisPN_CHARS_BASE(int codePoint)Check if the supplied code point represents a valid prefixed name base character.static booleanisPN_CHARS_U(int codePoint)Check if the supplied code point represents either a valid prefixed name base character or an underscore.static booleanisPN_LOCAL(String name)static booleanisPN_LOCAL_ESC(String name)static booleanisPN_PREFIX(String prefix)Checks if the supplied prefix string is a valid Turtle namespace prefix.static booleanisPrefixChar(int codePoint)Check if the supplied code point represents a valid prefix character.static booleanisPrefixStartChar(int codePoint)Check if the supplied code point represents a valid prefixed name start character.static booleanisWhitespace(int codePoint)Check if the supplied code point represents a whitespace character
-
-
-
Method Detail
-
findURISplitIndex
public static int findURISplitIndex(String uri)
Tries to find an index where the supplied URI can be split into a namespace and a local name that comply with the serialization constraints of the Turtle format.- Parameters:
uri- The URI to split.- Returns:
- The index where the supplied URI can be split, or -1 if the URI cannot be split.
-
isWhitespace
public static boolean isWhitespace(int codePoint)
Check if the supplied code point represents a whitespace character- Parameters:
codePoint- a Unicode code point- Returns:
trueif the supplied code point represents a whitespace character,falseotherwise.
-
isPN_CHARS_BASE
public static boolean isPN_CHARS_BASE(int codePoint)
Check if the supplied code point represents a valid prefixed name base character.From Turtle Spec:
http://www.w3.org/TR/turtle/#grammar-production-PN_CHARS_BASE
[163s] PN_CHARS_BASE ::= [A-Z] | [a-z] | [#x00C0-#x00D6] | [#x00D8-#x00F6] | [#x00F8-#x02FF] | [#x0370-#x037D] | [#x037F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
-
isPN_CHARS_U
public static boolean isPN_CHARS_U(int codePoint)
Check if the supplied code point represents either a valid prefixed name base character or an underscore.From Turtle Spec:
http://www.w3.org/TR/turtle/#grammar-production-PN_CHARS_U
[164s] PN_CHARS_U ::= PN_CHARS_BASE | '_'
-
isPN_CHARS
public static boolean isPN_CHARS(int codePoint)
Check if the supplied code point represents a valid prefixed name character.From Turtle Spec:
http://www.w3.org/TR/turtle/#grammar-production-PN_CHARS
[166s] PN_CHARS ::= PN_CHARS_U | '-' | [0-9] | #x00B7 | [#x0300-#x036F] | [#x203F-#x2040]
-
isPrefixStartChar
public static boolean isPrefixStartChar(int codePoint)
Check if the supplied code point represents a valid prefixed name start character.- Parameters:
codePoint- a Unicode code point.- Returns:
trueif the supplied code point represents a valid prefixed name start char, false otherwise.
-
isBLANK_NODE_LABEL_StartChar
public static boolean isBLANK_NODE_LABEL_StartChar(int codePoint)
Check if the supplied code point represents a valid start character for a blank node label.- Parameters:
codePoint- a Unicode code point.- Returns:
trueif the supplied code point represents a valid blank node label start char,falseotherwise.
-
isBLANK_NODE_LABEL_Char
public static boolean isBLANK_NODE_LABEL_Char(int codePoint)
Check if the supplied code point represents a valid blank node label character.- Parameters:
codePoint- a Unicode code point.- Returns:
trueif the supplied code point represents a valid blank node label char,falseotherwise.
-
isBLANK_NODE_LABEL_EndChar
public static boolean isBLANK_NODE_LABEL_EndChar(int codePoint)
Check if the supplied code point represents a valid blank node label end character.- Parameters:
codePoint- a Unicode code point.- Returns:
trueif the supplied code point represents a valid blank node label end char,falseotherwise.
-
isNameStartChar
public static boolean isNameStartChar(int codePoint)
Check if the supplied code point represents a valid name start character.- Parameters:
codePoint- a Unicode code point.- Returns:
trueif the supplied code point represents a valid name start char,falseotherwise.
-
isNameChar
public static boolean isNameChar(int codePoint)
Check if the supplied code point represents a valid name character.- Parameters:
codePoint- a Unicode code point.- Returns:
trueif the supplied code point represents a valid name char,falseotherwise.
-
isNameEndChar
public static boolean isNameEndChar(int codePoint)
Check if the supplied code point represents a valid name end character.- Parameters:
codePoint- a Unicode code point.- Returns:
trueif the supplied code point represents a valid name end char,falseotherwise.
-
isLocalEscapedChar
public static boolean isLocalEscapedChar(int codePoint)
Check if the supplied code point represents a valid local escaped character.- Parameters:
codePoint- a Unicode code point.- Returns:
trueif the supplied code point represents a valid local escaped char,falseotherwise.
-
isPrefixChar
public static boolean isPrefixChar(int codePoint)
Check if the supplied code point represents a valid prefix character.- Parameters:
codePoint- a Unicode code point.- Returns:
trueif the supplied code point represents a valid prefix char,falseotherwise.
-
isLanguageStartChar
public static boolean isLanguageStartChar(int codePoint)
Check if the supplied code point represents a valid language tag start character.- Parameters:
codePoint- a Unicode code point.- Returns:
trueif the supplied code point represents a valid language tag start char,falseotherwise.
-
isLanguageChar
public static boolean isLanguageChar(int codePoint)
Check if the supplied code point represents a valid language tag character.- Parameters:
codePoint- a Unicode code point.- Returns:
trueif the supplied code point represents a valid language tag char,falseotherwise.
-
isPN_PREFIX
public static boolean isPN_PREFIX(String prefix)
Checks if the supplied prefix string is a valid Turtle namespace prefix. From Turtle Spec:http://www.w3.org/TR/turtle/#grammar-production-PN_PREFIX
[167s] PN_PREFIX ::= PN_CHARS_BASE ((PN_CHARS | '.')* PN_CHARS)?
- Parameters:
prefix- a prefix string.- Returns:
- true if the supplied prefix conforms to Turtle grammar rules
-
isPLX_START
public static boolean isPLX_START(String name)
-
isPERCENT
public static boolean isPERCENT(String name)
-
isPLX_INTERNAL
public static boolean isPLX_INTERNAL(String name)
-
isPN_LOCAL_ESC
public static boolean isPN_LOCAL_ESC(String name)
-
isPN_LOCAL
public static boolean isPN_LOCAL(String name)
-
encodeString
public static String encodeString(String s)
Encodes the supplied string for inclusion as a 'normal' string in a Turtle document.- Parameters:
s-- Returns:
- encoded string
-
encodeLongString
public static String encodeLongString(String s)
Encodes the supplied string for inclusion as a long string in a Turtle document.- Parameters:
s-- Returns:
- encoded long string
-
encodeURIString
@Deprecated public static String encodeURIString(String s)
Deprecated.Encodes the supplied string for inclusion as a (relative) URI in a Turtle document.- Parameters:
s-
-
decodeString
public static String decodeString(String s)
Decodes an encoded Turtle string. Any \-escape sequences are substituted with their decoded value.- Parameters:
s- An encoded Turtle string.- Returns:
- The unencoded string.
- Throws:
IllegalArgumentException- If the supplied string is not a correctly encoded Turtle string.
-
-