Package com.inrupt.rdf.wrapping.commons
Class ValueMappings
java.lang.Object
com.inrupt.rdf.wrapping.commons.ValueMappings
Common mappings from RDF terms to other values. For use in wrapping classes.
- Author:
- Samu Lang
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends RDFTerm>
ValueMapping<T>A factory for mappings from a term to a view.static String
iriAsString
(RDFTerm term, Graph graph) Maps an IRI term to its IRI string.static URI
Maps an IRI term to aURI
created from its IRI string.static Boolean
literalAsBoolean
(RDFTerm term, Graph graph) Maps a literal term to a boolean.static Instant
literalAsInstant
(RDFTerm term, Graph graph) Maps a literal term to a point in time.static Integer
literalAsIntegerOrNull
(RDFTerm term, Graph graph) Maps a literal term to an integer or null.static String
literalAsString
(RDFTerm term, Graph graph) Maps a literal term to its lexical form.
-
Method Details
-
literalAsString
Maps a literal term to its lexical form.- Parameters:
term
- the term to mapgraph
- ignored- Returns:
- the lexical form of the term as a string
- Throws:
NullPointerException
- if the term is nullIllegalStateException
- if the term is not a literal
-
iriAsUri
Maps an IRI term to aURI
created from its IRI string.- Parameters:
term
- the term to convertgraph
- ignored- Returns:
- the IRI of the term as a URI
- Throws:
NullPointerException
- if the term is nullIllegalStateException
- if the term is not an IRI
-
iriAsString
Maps an IRI term to its IRI string.- Parameters:
term
- the term to convertgraph
- ignored- Returns:
- the IRI of the term as a string
- Throws:
NullPointerException
- if the term is nullIllegalStateException
- if the term is not an IRI
-
literalAsInstant
Maps a literal term to a point in time.- Parameters:
term
- the term to mapgraph
- ignored- Returns:
- the point in time represented by the term's lexical form as an
Instant
- Throws:
NullPointerException
- if the term is nullIllegalStateException
- if the term is not a literalDateTimeParseException
- if the term's lexical form cannot be parsed as anInstant
-
literalAsBoolean
Maps a literal term to a boolean.- Parameters:
term
- the term to mapgraph
- ignored- Returns:
- the boolean represented by the term's lexical form as a
boolean
- Throws:
NullPointerException
- if the term is nullIllegalStateException
- if the term is not a literal
-
literalAsIntegerOrNull
Maps a literal term to an integer or null.- Parameters:
term
- the term to mapgraph
- ignored- Returns:
- the integer represented by the term's lexical form or null if the form can not be parsed
- Throws:
NullPointerException
- if the term is nullIllegalStateException
- if the term is not a literal
-
as
A factory for mappings from a term to a view.- Type Parameters:
T
- the type of the target class to map to- Parameters:
view
- the target class to map to- Returns:
- a mapping that converts the term to the supplied implementation type
- Throws:
NullPointerException
- if the view is null- See Also:
-
the returned mapping function (including exceptions it throws)
-