Class TripleTermUtil

java.lang.Object
org.eclipse.rdf4j.rio.helpers.TripleTermUtil

public class TripleTermUtil extends Object
Utility methods for RDF 1.2 triples.
Author:
Pavel Mihaylov
  • Field Details

    • TRIPLE_PREFIX

      public static final String TRIPLE_PREFIX
      IRI prefix for RDF 1.2 triples encoded as IRIs.
      See Also:
  • Constructor Details

    • TripleTermUtil

      public TripleTermUtil()
  • Method Details

    • toRDFEncodedValue

      public static <T extends Value> T toRDFEncodedValue(T value)
      Converts the supplied value from RDF 1.2 to an RDF-compatible representation.

      RDF 1.2 triples are encoded as IRIs that start with TRIPLE_PREFIX, followed by the base64 encoding of the N-Triples serialization of the triple.

      All other RDF 1.2 values are valid in RDF as well and remain unchanged.

      Type Parameters:
      T -
      Parameters:
      value - a RDF 1.2 Value to encode.
      Returns:
      the RDF-compatible encoded value, if a TripleTerm was supplied, or the supplied value otherwise.
    • fromRDFEncodedValue

      public static <T extends Value> T fromRDFEncodedValue(T encodedValue)
      Converts the supplied value from an RDF-compatible representation to an RDF 1.2 value.

      See toRDFEncodedValue(Value).

      Type Parameters:
      T -
      Parameters:
      encodedValue - an RDF Value to convert to RDF 1.2.
      Returns:
      the decoded RDF 1.2 tripleTerm, if a TripleTerm encoded as IRI was supplied, or the supplied value otherwise.
      Throws:
      IllegalArgumentException - if the supplied value looked like an RDF 1.2 tripleTerm encoded as an IRI but it could not be decoded successfully.
    • fromRDFEncodedValue

      public static <T extends Value> T fromRDFEncodedValue(T encodedValue, ValueFactory valueFactory)
      Converts the supplied value from an RDF-compatible representation to an RDF 1.2 value.

      See toRDFEncodedValue(Value).

      Type Parameters:
      T -
      Parameters:
      encodedValue - an RDF Value to convert to RDF 1.2.
      valueFactory - the ValueFactory to use for parsing the triple.
      Returns:
      the decoded RDF 1.2 triple, if a
      invalid reference
      Triple
      encoded as IRI was supplied, or the supplied value otherwise.
      Throws:
      IllegalArgumentException - if the supplied value looked like an RDF 1.2 triple encoded as an IRI but it could not be decoded successfully.
    • isEncodedTriple

      public static boolean isEncodedTriple(Value value)
      Checks if the supplied Value represents an RDF 1.2 triple encoded as an IRI.
      Parameters:
      value - the value to check.
      Returns:
      True if the value is an RDF 1.2 triple encoded as an IRI, false otherwise.