org.universAAL.middleware.rdf
Class TypeMapper

Package class diagram package TypeMapper
java.lang.Object
  extended by org.universAAL.middleware.rdf.TypeMapper

public final class TypeMapper
extends Object

This class handles the mapping between java objects and the according representation in XML namespace.

Author:
mtazari - Saied Tazari, mfreddi, Carsten Stockloew

Field Summary
static String XSD_NAMESPACE
          xsd namespace.
 
Method Summary
static Object asLiteral(Object o)
          Tries to interpret the specified object as RDF literal.
static XMLGregorianCalendar getCurrentDateTime()
          Get the current date and time as representation for W3C XML Schema 1.0 date/time datatypes.
static DatatypeFactory getDataTypeFactory()
          Return an instance of DatatypeFactory.
static String getDatatypeURI(Class c)
          Return the XSD type given a java class, according to the list of predefined types.
static String getDatatypeURI(Object o)
          Return the XSD type given a java object, according to the list of predefined types.
static Class getJavaClass(String datatypeURI)
          Return the Java class given an XSD String, according to the list of predefined types.
static Object getJavaInstance(String lexicalForm, String xsdType)
          Return a Java object from an XML literal and its type.
static String[] getXMLInstance(Object o)
          Return the lexical string and XSD type from an object which can be mapped to XSD type.
static boolean isCompatible(String supertypeURI, String subtypeURI)
          Determines if the first specified URI is a super type of the second specified URI.
static boolean isLiteral(Object o)
          Determines if the specified object is a Resource that is either an XML Literal or an XSD Literal.
static boolean isRegisteredDatatypeURI(String datatypeURI)
          Determines if an object is registered for the specified URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XSD_NAMESPACE

public static final String XSD_NAMESPACE
xsd namespace.

See Also:
Constant Field Values
Method Detail

getCurrentDateTime

public static XMLGregorianCalendar getCurrentDateTime()
Get the current date and time as representation for W3C XML Schema 1.0 date/time datatypes.


getDataTypeFactory

public static DatatypeFactory getDataTypeFactory()
Return an instance of DatatypeFactory.

Returns:
DatatypeFactory

getXMLInstance

public static String[] getXMLInstance(Object o)
Return the lexical string and XSD type from an object which can be mapped to XSD type.

Parameters:
o - The Object to be serialized.
Returns:
An array of 2 strings with the lexical XML form and associated XSD type.

getJavaInstance

public static Object getJavaInstance(String lexicalForm,
                                     String xsdType)
Return a Java object from an XML literal and its type.

Parameters:
lexicalForm - The serialized string.
xsdType - The XSD type of the object.
Returns:
A Java object or null if it can not be mapped to an appropriate object.

asLiteral

public static Object asLiteral(Object o)
Tries to interpret the specified object as RDF literal. If the parameter is a List, the return value is a new RDF List. If the the parameter can be serialized as XML Literal, the return value is a copy of the input. If the parameter is an xsd literal, the return value is exactly the input parameter.

Parameters:
o - The object to interpret.

getDatatypeURI

public static String getDatatypeURI(Class c)
Return the XSD type given a java class, according to the list of predefined types.

Parameters:
c - The Java class.
Returns:
the XSD String associated with class or null if it can not be mapped to an appropriate object.

getDatatypeURI

public static String getDatatypeURI(Object o)
Return the XSD type given a java object, according to the list of predefined types.

Parameters:
o - The Java instance.
Returns:
the XSD String associated with class or null if it can not be mapped to an appropriate object.

getJavaClass

public static Class getJavaClass(String datatypeURI)
Return the Java class given an XSD String, according to the list of predefined types.

Parameters:
datatypeURI - The XSD String.
Returns:
The Java class associated to the XSD String or null if it can not be mapped to an appropriate object.

isCompatible

public static boolean isCompatible(String supertypeURI,
                                   String subtypeURI)
Determines if the first specified URI is a super type of the second specified URI. Both URIs must start with the XSD prefix.

Parameters:
supertypeURI - URI of the super type.
subtypeURI - URI that is to be tested to be a sub type of the specified super type.
Returns:
true, if super type is a super type of sub type.

isLiteral

public static boolean isLiteral(Object o)
Determines if the specified object is a Resource that is either an XML Literal or an XSD Literal.


isRegisteredDatatypeURI

public static boolean isRegisteredDatatypeURI(String datatypeURI)
Determines if an object is registered for the specified URI.



Copyright © 2014 universAAL Consortium. All Rights Reserved.