|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
An RDF Literal.
In RDF2003 literals can be typed. If typed then the literal comprises a datatype, a lexical form and a value (together with an optional xml:lang string). Old style literals have no type and are termed "plain" literals.
Implementations of this interface should be able to support both plain and typed literals. In the case of typed literals the primitive accessor methods such as getInt() determine if the literal value can be coerced to an appropriate java wrapper class. If so then the class is unwrapped to extract the primitive value returned. If the coercion fails then a runtime DatatypeFormatException is thrown.
In the case of plain literals then the primitve accessor methods duplicate the behvaiour of jena1. The literal is internally stored in lexical form but the accessor methods such as getInt will attempt to parse the lexical form and if successful will return the primitive value.
Object (i.e. non-primitive) values are supported. In the case of typed literals
then a global TypeMapper registry determines what datatype representation to
use for a given Object type. In the case of plain literals then the object
will be stored in the lexical form given by its toString
method.
Factory objects, provided by the application, are needed in that case to covert
the lexical form back into the appropriate object type.
Method Summary | |
boolean |
equals(java.lang.Object o)
Test whether another object is equal to this object. |
boolean |
getBoolean()
If the literal is interpretable as a Boolean return its value as a boolean. |
byte |
getByte()
If the literal is interpretable as a Byte return its value. |
char |
getChar()
If the literal is interpretable as a Char return its value. |
RDFDatatype |
getDatatype()
Return the datatype of the literal. |
java.lang.String |
getDatatypeURI()
Return the uri of the datatype of the literal. |
double |
getDouble()
If the literal is interpretable as a Double return its value. |
float |
getFloat()
If the literal is interpretable as a Float return its value. |
int |
getInt()
If the literal is interpretable as a Integer return its value. |
java.lang.String |
getLanguage()
If a language is defined for this literal return it |
java.lang.String |
getLexicalForm()
Return the lexical form of the literal. |
long |
getLong()
If the literal is interpretable as a Long return its value. |
java.lang.Object |
getObject(ObjectF f)
In the case of plain literals this recreates an object from its lexical form using the given factory. |
short |
getShort()
If the literal is interpretable as a Short return its value. |
java.lang.String |
getString()
If the literal is interpretable as a string return its value. |
java.lang.Object |
getValue()
Return the value of the literal. |
boolean |
getWellFormed()
Return whether Literal is well formed XML |
boolean |
isLiteral()
Answer true. |
boolean |
sameValueAs(Literal other)
Test that two literals are semantically equivalent. |
Methods inherited from interface com.hp.hpl.jena.rdf.model.RDFNode |
as, asNode, canAs, inModel, toString, visitWith |
Method Detail |
public boolean isLiteral()
public java.lang.Object getValue()
public RDFDatatype getDatatype()
public java.lang.String getDatatypeURI()
public java.lang.String getLexicalForm()
public boolean getBoolean()
public byte getByte()
public short getShort()
public int getInt()
public long getLong()
public char getChar()
public float getFloat()
public double getDouble()
public java.lang.String getString()
public java.lang.Object getObject(ObjectF f)
f
- A factory object for creating the returned object.
public java.lang.String getLanguage()
public boolean getWellFormed()
public boolean equals(java.lang.Object o)
A plain Literal is equal to another object only if the object is also a plain Literal and the string value and language of both literals are equal. In the case of a typed literal equality is defined by the datatype equality function on the value spaces and may or may not include comparison of the lang strings.
o
- The object to test against
public boolean sameValueAs(Literal other)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |