org.opentox.toxotis.ontology
Class LiteralValue<T>

java.lang.Object
  extended by org.opentox.toxotis.ontology.LiteralValue<T>
Type Parameters:
T - Generic for the (Java) datatype of the value.
All Implemented Interfaces:
Serializable

public class LiteralValue<T>
extends Object
implements Serializable

A simple wrapper for a value (usually String) and its datatype according to the XSD specidcation (find online documentation at RNC and the complete specification at the W3C web page. Literal values are atomic values characterized by some datatype, according to the XSD specifications. As we read at http://www.w3.org/TR/rdf-concepts/#section-Literals:

Literals are used to identify values such as numbers and dates by means of a lexical representation. Anything represented by a literal could also be represented by a URI, but it is often more convenient or intuitive to use literals. A literal may be the object of an RDF statement, but not the subject or the predicate.
This class aims at providing the Java interface to RDF literal values.

Author:
Pantelis Sopasakis, Charalampos Chomenides
See Also:
Serialized Form

Constructor Summary
LiteralValue()
          Dummy constructor for the class LiteralValue which initializes a new instance of it with null value and default class java.lang.String, or in terms of xsd datatypes, XSDDatatype.XSDstring.
LiteralValue(T value)
          Create a Typed value with no explicit type declaration.
LiteralValue(T value, com.hp.hpl.jena.datatypes.xsd.XSDDatatype type)
          Create a new typed value with given value and XSD datatype.
 
Method Summary
 boolean equals(Object obj)
           
 long getHash()
          Getter fot the hash code of the current LiteralValue object.
 com.hp.hpl.jena.datatypes.xsd.XSDDatatype getType()
          Retrieve the datatype
 T getValue()
          Retrieve the value
 String getValueAsString()
          Returns a String representation of the underlying value.
 int hashCode()
           
 com.hp.hpl.jena.rdf.model.Literal inModel(com.hp.hpl.jena.ontology.OntModel model)
          Creates a typed literal in an ontological data model.
 void setHash(long hashCode)
          Required so that the class can be persistent using Hibernate.
 void setType(com.hp.hpl.jena.datatypes.xsd.XSDDatatype type)
           
 void setValue(T value)
           
 void setValueAsString(String value)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LiteralValue

public LiteralValue()
Dummy constructor for the class LiteralValue which initializes a new instance of it with null value and default class java.lang.String, or in terms of xsd datatypes, XSDDatatype.XSDstring.


LiteralValue

public LiteralValue(T value,
                    com.hp.hpl.jena.datatypes.xsd.XSDDatatype type)
Create a new typed value with given value and XSD datatype.

Parameters:
value - The value
type - Datatype for the value

LiteralValue

public LiteralValue(T value)
Create a Typed value with no explicit type declaration. The type will be specified by the type mapper according to the Java generic T.

Parameters:
value - The value
Method Detail

getType

public com.hp.hpl.jena.datatypes.xsd.XSDDatatype getType()
Retrieve the datatype

Returns:
The type of the value

setType

public void setType(com.hp.hpl.jena.datatypes.xsd.XSDDatatype type)

setValue

public void setValue(T value)

getValueAsString

public String getValueAsString()
Returns a String representation of the underlying value. This is different from the method toString() defined in this class.

Returns:
The value as String or null in case the value is null.

setValueAsString

public void setValueAsString(String value)

getValue

public T getValue()
Retrieve the value

Returns:
The value itself

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

inModel

public com.hp.hpl.jena.rdf.model.Literal inModel(com.hp.hpl.jena.ontology.OntModel model)
Creates a typed literal in an ontological data model.

Parameters:
model - Ontological model to be used for the construction of the typed literal. This parameter must be not null.
Returns:
Returns the typed literal as a Jena object.

getHash

public long getHash()
Getter fot the hash code of the current LiteralValue object. Notice that a difference from the ordinary method hashCode() is that the latter returns the result as an integer while this custom method returns a long hash.

Returns:
Long hash code.

setHash

public void setHash(long hashCode)
Required so that the class can be persistent using Hibernate. In fact this method has empty body and does nothing whatsoever.

Parameters:
hashCode - hash code which will not be used anywhere.


Copyright © 2011-2012 OpenTox. All Rights Reserved.