Package org.eclipse.rdf4j.rio.turtle

## 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 String` | `decodeString​(String s)` | Decodes an encoded Turtle string.
    `static String` | `encodeLongString​(String s)` | Encodes the supplied string for inclusion as a long string in a Turtle document.
    `static String` | `encodeString​(String s)` | Encodes the supplied string for inclusion as a 'normal' string in a Turtle document.
    `static String` | `encodeURIString​(String s)` | Deprecated.
    `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.
    `static boolean` | `isBLANK_NODE_LABEL_Char​(int codePoint)` | Check if the supplied code point represents a valid blank node label character.
    `static boolean` | `isBLANK_NODE_LABEL_EndChar​(int codePoint)` | Check if the supplied code point represents a valid blank node label end character.
    `static boolean` | `isBLANK_NODE_LABEL_StartChar​(int codePoint)` | Check if the supplied code point represents a valid start character for a blank node label.
    `static boolean` | `isLanguageChar​(int codePoint)` | Check if the supplied code point represents a valid language tag character.
    `static boolean` | `isLanguageStartChar​(int codePoint)` | Check if the supplied code point represents a valid language tag start character.
    `static boolean` | `isLocalEscapedChar​(int codePoint)` | Check if the supplied code point represents a valid local escaped character.
    `static boolean` | `isNameChar​(int codePoint)` | Check if the supplied code point represents a valid name character.
    `static boolean` | `isNameEndChar​(int codePoint)` | Check if the supplied code point represents a valid name end character.
    `static boolean` | `isNameStartChar​(int codePoint)` | Check if the supplied code point represents a valid name start character.
    `static boolean` | `isPERCENT​(String name)` |
    `static boolean` | `isPLX_INTERNAL​(String name)` |
    `static boolean` | `isPLX_START​(String name)` |
    `static boolean` | `isPN_CHARS​(int codePoint)` | Check if the supplied code point represents a valid prefixed name character.
    `static boolean` | `isPN_CHARS_BASE​(int codePoint)` | Check if the supplied code point represents a valid prefixed name base character.
    `static boolean` | `isPN_CHARS_U​(int codePoint)` | Check if the supplied code point represents either a valid prefixed name base character or an underscore.
    `static boolean` | `isPN_LOCAL​(String name)` |
    `static boolean` | `isPN_LOCAL_ESC​(String name)` |
    `static boolean` | `isPN_PREFIX​(String prefix)` | Checks if the supplied prefix string is a valid Turtle namespace prefix.
    `static boolean` | `isPrefixChar​(int codePoint)` | Check if the supplied code point represents a valid prefix character.
    `static boolean` | `isPrefixStartChar​(int codePoint)` | Check if the supplied code point represents a valid prefixed name start character.
    `static boolean` | `isWhitespace​(int codePoint)` | Check if the supplied code point represents a whitespace character

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### LOCAL_ESCAPED_CHARS

          public static final char[] LOCAL_ESCAPED_CHARS

  - ### Constructor Detail

    - #### TurtleUtil

          public TurtleUtil()

  - ### 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:
        `true` if the supplied code point represents a whitespace character, `false` otherwise.

    - #### 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:
        `true` if 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:
        `true` if the supplied code point represents a valid blank node label start char, `false` otherwise.

    - #### 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:
        `true` if the supplied code point represents a valid blank node label char, `false` otherwise.

    - #### 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:
        `true` if the supplied code point represents a valid blank node label end char, `false` otherwise.

    - #### 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:
        `true` if the supplied code point represents a valid name start char, `false` otherwise.

    - #### 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:
        `true` if the supplied code point represents a valid name char, `false` otherwise.

    - #### 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:
        `true` if the supplied code point represents a valid name end char, `false` otherwise.

    - #### 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:
        `true` if the supplied code point represents a valid local escaped char, `false` otherwise.

    - #### 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:
        `true` if the supplied code point represents a valid prefix char, `false` otherwise.

    - #### 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:
        `true` if the supplied code point represents a valid language tag start char, `false` otherwise.

    - #### 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:
        `true` if the supplied code point represents a valid language tag char, `false` otherwise.

    - #### 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.