com.hp.hpl.jena.datatypes
Class TypeMapper

java.lang.Object
  extended by com.hp.hpl.jena.datatypes.TypeMapper

public class TypeMapper
extends Object

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.

Version:
$Revision: 1.2 $ on $Date: 2009-08-21 15:42:01 $
Author:
Dave Reynolds

Constructor Summary
TypeMapper()
           
 
Method Summary
static TypeMapper getInstance()
          Return the single global instance of the TypeMapper.
 RDFDatatype getSafeTypeByName(String uri)
          Version of getTypeByName which will treat unknown URIs as typed literals but with just the default implementation
 RDFDatatype getTypeByClass(Class<?> clazz)
          Look up a datatype suitable for representing instances of the given Java class.
 RDFDatatype getTypeByName(String uri)
          Lookup a known datatype.
 RDFDatatype getTypeByValue(Object value)
          Method getTypeByValue.
 Iterator<RDFDatatype> listTypes()
          List all the known datatypes
static void main(String[] args)
           
 void registerDatatype(RDFDatatype type)
          Register a new datatype
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeMapper

public TypeMapper()
Method Detail

getInstance

public static TypeMapper 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.


getSafeTypeByName

public RDFDatatype getSafeTypeByName(String uri)
Version of getTypeByName which will treat unknown URIs as typed literals but with just the default implementation

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

public RDFDatatype getTypeByName(String uri)
Lookup a known datatype. An unkown 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

public RDFDatatype getTypeByValue(Object value)
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

public Iterator<RDFDatatype> listTypes()
List all the known datatypes


getTypeByClass

public RDFDatatype getTypeByClass(Class<?> clazz)
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

public void registerDatatype(RDFDatatype type)
Register a new datatype


main

public static void main(String[] args)


Licenced under the Apache License, Version 2.0