java.lang.Object
org.apache.jena.datatypes.TypeMapper
The TypeMapper provides a global registry of known datatypes.
The datatypes can be retrieved by their URI or from the java class
that is used to represent them.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic TypeMapper
Return the single global instance of the TypeMapper.getSafeTypeByName
(String uri) Version of getTypeByName which will treat unknown URIs as typed literals but with just the default implementationgetTypeByClass
(Class<?> clazz) Look up a datatype suitable for representing instances of the given Java class.getTypeByName
(String uri) Lookup a known datatype.getTypeByValue
(Object value) Method getTypeByValue.List all the known datatypesvoid
registerDatatype
(RDFDatatype type) Register a new datatypestatic void
reset()
static void
setInstance
(TypeMapper typeMapper) void
Remove a datatype registration.
-
Constructor Details
-
TypeMapper
public TypeMapper()
-
-
Method Details
-
getInstance
Return the single global instance of the TypeMapper. Done this way rather than simply making the static field directly accessible to allow us to dynamically replace the entire mapper table if needed. -
setInstance
-
reset
public static void reset() -
getSafeTypeByName
Version of getTypeByName which will treat unknown URIs as typed literals but with just the default implementationRDF 1.1: null for
uri
returns null and it will meanxsd:string
because plain literals (no lang tag) and xsd:strings are now the same.- Parameters:
uri
- the URI of the desired datatype- Returns:
- Datatype the datatype definition registered at uri, if there is no such registered type it returns a new instance of the default datatype implementation, if the uri is null it returns null (indicating a plain RDF literal).
-
getTypeByName
Lookup a known datatype. An unknown datatype or a datatype with uri null will return null will mean that the value will be treated as a old-style plain literal.- Parameters:
uri
- the URI of the desired datatype- Returns:
- Datatype the datatype definition of null if not known.
-
getTypeByValue
Method getTypeByValue. Look up a datatype suitable for representing the given java value object.- Parameters:
value
- a value instance to be represented- Returns:
- Datatype a datatype whose value space matches the java class
of
value
-
listTypes
List all the known datatypes -
getTypeByClass
Look up a datatype suitable for representing instances of the given Java class.- Parameters:
clazz
- a Java class to be represented- Returns:
- a datatype whose value space matches the given java class
-
registerDatatype
Register a new datatype -
unregisterDatatype
Remove a datatype registration.
-