Package com.inrupt.rdf.wrapping.jena
Class ValueMappings
- java.lang.Object
-
- com.inrupt.rdf.wrapping.jena.ValueMappings
-
public final class ValueMappings extends Object
Common mappings from RDF terms to other values. For use in wrapping classes.- Author:
- Samu Lang
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends org.apache.jena.rdf.model.RDFNode>
ValueMapping<T>as(Class<T> view)
A factory for mappings from a node to a view.static String
iriAsString(org.apache.jena.rdf.model.RDFNode node)
Maps a resource node to its IRI.static URI
iriAsUri(org.apache.jena.rdf.model.RDFNode node)
Maps a resource node to its IRI.static Boolean
literalAsBoolean(org.apache.jena.rdf.model.RDFNode node)
Maps a literal node to a boolean.static Instant
literalAsInstant(org.apache.jena.rdf.model.RDFNode node)
Maps a literal node to a point in time.static Integer
literalAsIntegerOrNull(org.apache.jena.rdf.model.RDFNode node)
Maps a literal node to an integer.static String
literalAsString(org.apache.jena.rdf.model.RDFNode node)
Maps a literal node to its lexical form.
-
-
-
Method Detail
-
literalAsString
public static String literalAsString(org.apache.jena.rdf.model.RDFNode node)
Maps a literal node to its lexical form.- Parameters:
node
- the node to map- Returns:
- the lexical form of the node as a string
- Throws:
NullPointerException
- if the node is nullorg.apache.jena.rdf.model.LiteralRequiredException
- if the node is not a literal
-
iriAsUri
public static URI iriAsUri(org.apache.jena.rdf.model.RDFNode node)
Maps a resource node to its IRI.- Parameters:
node
- the node to convert- Returns:
- the IRI of the node as a string
- Throws:
NullPointerException
- if the node is nullorg.apache.jena.rdf.model.ResourceRequiredException
- if the node is not a resource
-
iriAsString
public static String iriAsString(org.apache.jena.rdf.model.RDFNode node)
Maps a resource node to its IRI.- Parameters:
node
- the node to convert- Returns:
- the IRI of the node as a string
- Throws:
NullPointerException
- if the node is nullorg.apache.jena.rdf.model.ResourceRequiredException
- if the node is not a resource
-
literalAsInstant
public static Instant literalAsInstant(org.apache.jena.rdf.model.RDFNode node)
Maps a literal node to a point in time.- Parameters:
node
- the node to map- Returns:
- the point in time represented by the node's lexical form as an
Instant
- Throws:
NullPointerException
- if the node is nullorg.apache.jena.rdf.model.LiteralRequiredException
- if the node is not a literalDateTimeParseException
- if the node's lexical form cannot be parsed as anInstant
-
literalAsBoolean
public static Boolean literalAsBoolean(org.apache.jena.rdf.model.RDFNode node)
Maps a literal node to a boolean.- Parameters:
node
- the node to map- Returns:
- the boolean represented by the node's lexical form as a
Boolean
- Throws:
NullPointerException
- if the node is nullorg.apache.jena.rdf.model.LiteralRequiredException
- if the node is not a literal
-
literalAsIntegerOrNull
public static Integer literalAsIntegerOrNull(org.apache.jena.rdf.model.RDFNode node)
Maps a literal node to an integer.- Parameters:
node
- the node to map- Returns:
- the integer represented by the node's lexical form or null if the form can not be parsed
- Throws:
NullPointerException
- if the node is nullorg.apache.jena.rdf.model.LiteralRequiredException
- if the node is not a literal
-
as
public static <T extends org.apache.jena.rdf.model.RDFNode> ValueMapping<T> as(Class<T> view)
A factory for mappings from a node 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 node to the supplied implementation type
- Throws:
NullPointerException
- if the view is null- See Also:
the returned mapping function (including exceptions it throws)
-
-