Package com.inrupt.rdf.wrapping.commons
Class ValueMappings
- java.lang.Object
 - 
- com.inrupt.rdf.wrapping.commons.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.commons.rdf.api.RDFTerm>
ValueMapping<T>as(Class<T> view)A factory for mappings from a term to a view.static StringiriAsString(org.apache.commons.rdf.api.RDFTerm term, org.apache.commons.rdf.api.Graph graph)Maps an IRI term to its IRI string.static URIiriAsUri(org.apache.commons.rdf.api.RDFTerm term, org.apache.commons.rdf.api.Graph graph)Maps an IRI term to aURIcreated from its IRI string.static BooleanliteralAsBoolean(org.apache.commons.rdf.api.RDFTerm term, org.apache.commons.rdf.api.Graph graph)Maps a literal term to a boolean.static InstantliteralAsInstant(org.apache.commons.rdf.api.RDFTerm term, org.apache.commons.rdf.api.Graph graph)Maps a literal term to a point in time.static IntegerliteralAsIntegerOrNull(org.apache.commons.rdf.api.RDFTerm term, org.apache.commons.rdf.api.Graph graph)Maps a literal term to an integer or null.static StringliteralAsString(org.apache.commons.rdf.api.RDFTerm term, org.apache.commons.rdf.api.Graph graph)Maps a literal term to its lexical form. 
 - 
 
- 
- 
Method Detail
- 
literalAsString
public static String literalAsString(org.apache.commons.rdf.api.RDFTerm term, org.apache.commons.rdf.api.Graph graph)
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
public static URI iriAsUri(org.apache.commons.rdf.api.RDFTerm term, org.apache.commons.rdf.api.Graph graph)
Maps an IRI term to aURIcreated 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
public static String iriAsString(org.apache.commons.rdf.api.RDFTerm term, org.apache.commons.rdf.api.Graph graph)
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
public static Instant literalAsInstant(org.apache.commons.rdf.api.RDFTerm term, org.apache.commons.rdf.api.Graph graph)
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
public static Boolean literalAsBoolean(org.apache.commons.rdf.api.RDFTerm term, org.apache.commons.rdf.api.Graph graph)
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
public static Integer literalAsIntegerOrNull(org.apache.commons.rdf.api.RDFTerm term, org.apache.commons.rdf.api.Graph graph)
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
public static <T extends org.apache.commons.rdf.api.RDFTerm> ValueMapping<T> as(Class<T> view)
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)
 
 - 
 
 -