com.hp.hpl.mesa.rdf.jena.model
Interface Literal

All Superinterfaces:
RDFNode
All Known Implementing Classes:
LiteralImpl

public interface Literal
extends RDFNode

An RDF Literal.

Literal objects can be interpreted as typed values. The literal string is considered to be a serialization of the typed value. Methods are provided for retrieving built in java types which are represented by the string produced by their toString method. A generic method for creating an arbitrary object using a factory is also provided.

This interface provides methods supporting typed literals. This means that methods are provided which will translate a built in type, or an object to an RDF Literal. This translation is done by invoking the toString() method of the object, or its built in equivalent. The reverse translation is also supported. This is built in for built in types. Factory objects, provided by the application, are used for application objects.

Version:
$Name: $ $Revision: 1.4 $ $Date: 2001/07/04 17:54:06 $
Author:
bwm

Method Summary
 boolean equals(java.lang.Object o)
          Test whether another object is equal to this object.
 boolean getBoolean()
          Interpret the literal as a String representation of a Boolean and return its value.
 byte getByte()
          Interpret the literal as a String representation of a byte and return its value.
 char getChar()
          Interpret the literal as a String representation of a char and return its value.
 double getDouble()
          Interpret the literal as a String representation of a double and return its value.
 float getFloat()
          Interpret the literal as a String representation of a float and return its value.
 int getInt()
          Interpret the literal as a String representation of an int and return its value.
 java.lang.String getLanguage()
          If a language is defined for this literal return it
 long getLong()
          Interpret the literal as a String representation of a long and return its value.
 java.lang.Object getObject(ObjectF f)
          Interpret the literal as a String representation of an object.
 short getShort()
          Interpret the literal as a String representation of a short and return its value.
 java.lang.String getString()
          Return the String value of the literal
 boolean getWellFormed()
          Return whether Literal is well formed XML
 
Methods inherited from interface com.hp.hpl.mesa.rdf.jena.model.RDFNode
toString
 

Method Detail

getBoolean

public boolean getBoolean()
                   throws RDFException
Interpret the literal as a String representation of a Boolean and return its value.
Returns:
the literal interpeted as a boolean
Throws:
RDFException - Generic RDF Exception

getByte

public byte getByte()
             throws RDFException
Interpret the literal as a String representation of a byte and return its value.
Returns:
the literal interpeted as a byte
Throws:
RDFException - Generic RDF Exception

getShort

public short getShort()
               throws RDFException
Interpret the literal as a String representation of a short and return its value.
Returns:
the literal interpeted as a short
Throws:
RDFException - Generic RDF Exception

getInt

public int getInt()
           throws RDFException
Interpret the literal as a String representation of an int and return its value.
Returns:
the literal interpeted as an int
Throws:
RDFException - Generic RDF Exception

getLong

public long getLong()
             throws RDFException
Interpret the literal as a String representation of a long and return its value.
Returns:
the literal interpeted as a long
Throws:
RDFException - Generic RDF Exception

getChar

public char getChar()
             throws RDFException
Interpret the literal as a String representation of a char and return its value.
Returns:
the literal interpeted as a char
Throws:
RDFException - Generic RDF Exception

getFloat

public float getFloat()
               throws RDFException
Interpret the literal as a String representation of a float and return its value.
Returns:
the literal interpeted as a float
Throws:
RDFException - Generic RDF Exception

getDouble

public double getDouble()
                 throws RDFException
Interpret the literal as a String representation of a double and return its value.
Returns:
the literal interpeted as a double
Throws:
RDFException - Generic RDF Exception

getString

public java.lang.String getString()
                           throws RDFException
Return the String value of the literal
Returns:
the literal string
Throws:
RDFException - Generic RDF Exception

getObject

public java.lang.Object getObject(ObjectF f)
                           throws RDFException
Interpret the literal as a String representation of an object.
Parameters:
f - A factory object for creating the returned object.
Returns:
the object created from the literal string
Throws:
RDFException - Generic RDF Exception

getLanguage

public java.lang.String getLanguage()
If a language is defined for this literal return it
Returns:
the language for this literal if it exists, or null

getWellFormed

public boolean getWellFormed()
Return whether Literal is well formed XML
Returns:
true if the literal is well formed XML, e.g. as would be produced from a parseType="Literal" element.

equals

public boolean equals(java.lang.Object o)
Test whether another object is equal to this object.

A Literal is equal to another object only if the object is also a Literal and the string value and language of both literals are equal.

Overrides:
equals in class java.lang.Object
Parameters:
o - The object to test against
Returns:
true if the the objects are equal, false otherwise


Copyright © 2001 Hewlett-Packard. All Rights Reserved.