gate.creole.ontology
Class Literal

java.lang.Object
  extended by gate.creole.ontology.Literal

public class Literal
extends Object

The class Literal represents a literal value as defined in section 6.5 of http://www.w3.org/TR/rdf-concepts . A literal value consists of a lexical form which is represented as a unicode string and in addition optionally either a language tag or a datatype.

Author:
Niraj Aswani, Johann Petrak

Constructor Summary
Literal(String value)
          Create a plain literal (i.e an untyped literal) without a language tag (the language is null).
Literal(String value, DataType dataType)
          Create a typed literal.
Literal(String value, Locale language)
          Deprecated. Use the constructor Literal(String value, String languagetag) instead
Literal(String value, String languagetag)
          Create a plain literal associated with a language tag.
 
Method Summary
 boolean equals(Object obj)
           
 DataType getDataType()
          Gets the datatype of the literal.
 Locale getLanguage()
          Deprecated. Use the method getLanguageTag() instead.
 String getLanguageTag()
          The language tag of the literal as a two-character lowercase language code or null if no language tag is associated.
 String getValue()
          Returns the value (lexical form) associated with this instance of literal.
 int hashCode()
           
 String toString()
          This method always returns the string representation of the literal value in the same way as getValue().
 String toTurtle()
          The representation of the literal in Turtle language (see http://www.w3.org/TeamSubmission/turtle/) Note that datatype URIs for typed literals will always be represented as full URIs and not use the xsd namespace.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Literal

public Literal(String value)
Create a plain literal (i.e an untyped literal) without a language tag (the language is null). A plain literal cannot have a data type (the datatype will always be null).


Literal

@Deprecated
public Literal(String value,
                          Locale language)
Deprecated. Use the constructor Literal(String value, String languagetag) instead

Create a plain literal (i.e. an untyped literal) with a language tag that corresponds to the string returned by language.getLanguage(). Any information stored in the Java Locale object other than the language code is ignored and discarded when stored in the ontology. A plain literal cannot have a data type (the datatype will alwats be null).

Parameters:
value -
language -

Literal

public Literal(String value,
               String languagetag)
Create a plain literal associated with a language tag. A language tag should be an official two-character lowercase language code.

Parameters:
value -
languagetag -

Literal

public Literal(String value,
               DataType dataType)
        throws InvalidValueException
Create a typed literal. A typed literal is associated with a datatype and cannot have a language tag (the language will always be null).

Parameters:
value -
dataType -
Throws:
InvalidValueException
Method Detail

getDataType

public DataType getDataType()
Gets the datatype of the literal. This will return null for all plain literals (i.e. literals that are not associated with a data type).


getValue

public String getValue()
Returns the value (lexical form) associated with this instance of literal.


getLanguage

@Deprecated
public Locale getLanguage()
Deprecated. Use the method getLanguageTag() instead.

Returns the language associated with this literal represented as a Locale object. Note that the only useful information in the Locale object is the language code which can be retrieved with the getLanguage() method of the Locale object.


getLanguageTag

public String getLanguageTag()
The language tag of the literal as a two-character lowercase language code or null if no language tag is associated. This always returns null for typed literals (literals associated with a data type).

Returns:
the language tag as String

toString

public String toString()
This method always returns the string representation of the literal value in the same way as getValue(). For a representation that also includes the language tag or data type, use toTurtle().

Overrides:
toString in class Object
Returns:
The value of the literal as String, identical to getValue()

toTurtle

public String toTurtle()
The representation of the literal in Turtle language (see http://www.w3.org/TeamSubmission/turtle/) Note that datatype URIs for typed literals will always be represented as full URIs and not use the xsd namespace.

Returns:
A String that contains the representation of the literal in Turtle language

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

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