org.eclipse.rdf4j.rio.helpers

## Class RDFStarUtil

- java.lang.Object
- - org.eclipse.rdf4j.rio.helpers.RDFStarUtil

-     public class RDFStarUtil
      extends Object

  Utility methods for RDF* triples.
  Author:
    Pavel Mihaylov

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `TRIPLE_PREFIX` IRI prefix for RDF* triples encoded as IRIs.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RDFStarUtil()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T extends Value> T` | `fromRDFEncodedValue(T encodedValue)` Converts the supplied value from an RDF-compatible representation to an RDF* value.
    `static boolean` | `isEncodedTriple(Value value)` Checks if the supplied `Value` represents an RDF* triple encoded as an IRI.
    `static <T extends Value> T` | `toRDFEncodedValue(T value)` Converts the supplied value from RDF* to an RDF-compatible representation.

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

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

- - ### Field Detail

    - #### TRIPLE_PREFIX

          public static final String TRIPLE_PREFIX

      IRI prefix for RDF* triples encoded as IRIs.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### RDFStarUtil

          public RDFStarUtil()

  - ### Method Detail

    - #### toRDFEncodedValue

          public static <T extends Value> T toRDFEncodedValue(T value)

      Converts the supplied value from RDF* to an RDF-compatible representation.

      RDF* 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* values are valid in RDF as well and remain unchanged.

      Type Parameters:
        `T` -
      Parameters:
        `value` - a RDF* `Value` to encode.
      Returns:
        the RDF-compatible encoded value, if a `Triple` 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* value.

      See `toRDFEncodedValue(Value)`.

      Type Parameters:
        `T` -
      Parameters:
        `encodedValue` - an RDF `Value` to convert to RDF*.
      Returns:
        the decoded RDF* triple, if a `Triple` encoded as `IRI` was supplied, or the supplied value otherwise.
      Throws:
        `IllegalArgumentException` - if the supplied value looked like an RDF* 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* triple encoded as an IRI.
      Parameters:
        `value` - the value to check.
      Returns:
        True if the value is an RDF* triple encoded as an IRI, false otherwise.

Copyright © 2015-2021 Eclipse Foundation. All Rights Reserved.