Package org.eclipse.rdf4j.rio.helpers
Class RDFStarUtil
- java.lang.Object
-
- org.eclipse.rdf4j.rio.helpers.RDFStarUtil
-
public class RDFStarUtil extends java.lang.Object
Utility methods for RDF-star triples.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
TRIPLE_PREFIX
IRI prefix for RDF-star triples encoded as IRIs.private static ValueFactory
VF
-
Constructor Summary
Constructors Constructor Description RDFStarUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.lang.String
decode(java.lang.String s)
private static java.lang.String
encode(java.lang.String s)
static <T extends Value>
TfromRDFEncodedValue(T encodedValue)
Converts the supplied value from an RDF-compatible representation to an RDF-star value.static <T extends Value>
TfromRDFEncodedValue(T encodedValue, ValueFactory valueFactory)
Converts the supplied value from an RDF-compatible representation to an RDF-star value.static boolean
isEncodedTriple(Value value)
Checks if the suppliedValue
represents an RDF-star triple encoded as an IRI.static <T extends Value>
TtoRDFEncodedValue(T value)
Converts the supplied value from RDF-star to an RDF-compatible representation.
-
-
-
Field Detail
-
TRIPLE_PREFIX
public static final java.lang.String TRIPLE_PREFIX
IRI prefix for RDF-star triples encoded as IRIs.- See Also:
- Constant Field Values
-
VF
private static final ValueFactory VF
-
-
Method Detail
-
toRDFEncodedValue
public static <T extends Value> T toRDFEncodedValue(T value)
Converts the supplied value from RDF-star to an RDF-compatible representation.RDF-star 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-star values are valid in RDF as well and remain unchanged.
-
fromRDFEncodedValue
public static <T extends Value> T fromRDFEncodedValue(T encodedValue)
Converts the supplied value from an RDF-compatible representation to an RDF-star value.- Type Parameters:
T
-- Parameters:
encodedValue
- an RDFValue
to convert to RDF-star.- Returns:
- the decoded RDF-star triple, if a
Triple
encoded asIRI
was supplied, or the supplied value otherwise. - Throws:
java.lang.IllegalArgumentException
- if the supplied value looked like an RDF-star triple 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-star value.- Type Parameters:
T
-- Parameters:
encodedValue
- an RDFValue
to convert to RDF-star.valueFactory
- theValueFactory
to use for parsing the triple.- Returns:
- the decoded RDF-star triple, if a
Triple
encoded asIRI
was supplied, or the supplied value otherwise. - Throws:
java.lang.IllegalArgumentException
- if the supplied value looked like an RDF-star triple encoded as an IRI but it could not be decoded successfully.
-
isEncodedTriple
public static boolean isEncodedTriple(Value value)
Checks if the suppliedValue
represents an RDF-star triple encoded as an IRI.- Parameters:
value
- the value to check.- Returns:
- True if the value is an RDF-star triple encoded as an IRI, false otherwise.
-
encode
private static java.lang.String encode(java.lang.String s)
-
decode
private static java.lang.String decode(java.lang.String s)
-
-