org.openanzo.glitter.rdf
Class TypedLiteral

java.lang.Object
  extended by org.openanzo.glitter.rdf.Literal
      extended by org.openanzo.glitter.rdf.TypedLiteral
All Implemented Interfaces:
ILiteralTerm, ITypedLiteralTerm, RDFTerm, TriplePatternComponent

public class TypedLiteral
extends Literal
implements ITypedLiteralTerm

An implementation of ITypedLiteralTerm that maintains the typed literal's lexical form, datatype, and native value (as a native Java object).

Author:
lee

Constructor Summary
TypedLiteral(java.lang.Object nativeObject)
          Creates a typed literal by inferring a datatype and lexical form from a native Java object.
TypedLiteral(java.lang.String value, java.lang.String datatype)
          Create a typed literal from a lexical form and datatype.
TypedLiteral(java.lang.String value, java.net.URI datatype)
          Create a typed literal from a lexical form and datatype.
 
Method Summary
 void changeDatatype(java.net.URI newDatatype)
          To change the datatype, we take the lexical form of the current datatype and recast it using the new datatype.
 int compareTo(TriplePatternComponent o)
          Compares to TriplePatternComponents for ordering.
 java.net.URI getDatatype()
           
 java.lang.String getLexicalForm()
           
 java.lang.Object getNativeValue()
           
 boolean isPlainLiteral()
           
 boolean isTypedLiteral()
           
 java.lang.String toString()
           
 
Methods inherited from class org.openanzo.glitter.rdf.Literal
equals, hashCode
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TypedLiteral

public TypedLiteral(java.lang.String value,
                    java.net.URI datatype)
Create a typed literal from a lexical form and datatype.

Parameters:
value - The lexical form of the literal.
datatype - The typed literal's datatype.

TypedLiteral

public TypedLiteral(java.lang.String value,
                    java.lang.String datatype)
             throws java.net.URISyntaxException
Create a typed literal from a lexical form and datatype.

Parameters:
value - The lexical form of the literal.
datatype - The typed literal's datatype.
Throws:
java.net.URISyntaxException - If the given datatype is not a valid URI.

TypedLiteral

public TypedLiteral(java.lang.Object nativeObject)
Creates a typed literal by inferring a datatype and lexical form from a native Java object.

Parameters:
nativeObject -
Method Detail

getNativeValue

public java.lang.Object getNativeValue()
Specified by:
getNativeValue in interface ITypedLiteralTerm
Returns:
A native Java object capturing the value of this typed literal.

getDatatype

public java.net.URI getDatatype()
Specified by:
getDatatype in interface ITypedLiteralTerm
Returns:
The datatype of this typed literal. Must be a valid URI

getLexicalForm

public java.lang.String getLexicalForm()
Specified by:
getLexicalForm in interface ILiteralTerm
Specified by:
getLexicalForm in class Literal
Returns:
The lexical form of the literal.

changeDatatype

public void changeDatatype(java.net.URI newDatatype)
To change the datatype, we take the lexical form of the current datatype and recast it using the new datatype. This may change the lexical form so we zero that out. (It will be recreated on-demand.)

Parameters:
newDatatype - The new datatype for this typed literal.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(TriplePatternComponent o)
Description copied from interface: TriplePatternComponent
Compares to TriplePatternComponents for ordering.

Specified by:
compareTo in interface TriplePatternComponent
Returns:
-1 if this comes before other; 0 if TriplePatternComponent.equals(Object) is true, and 1 otherwise.

isPlainLiteral

public boolean isPlainLiteral()
Specified by:
isPlainLiteral in interface ILiteralTerm
Returns:
whether or not this is a plain literal.

isTypedLiteral

public boolean isTypedLiteral()
Specified by:
isTypedLiteral in interface ILiteralTerm
Returns:
whether or not this is a typed literal.


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.