uk.ac.manchester.cs.owl.owlapi
Class OWLLiteralImpl

java.lang.Object
  extended by uk.ac.manchester.cs.owl.owlapi.OWLObjectImpl
      extended by uk.ac.manchester.cs.owl.owlapi.OWLLiteralImpl
All Implemented Interfaces:
java.lang.Comparable<OWLObject>, OWLAnnotationObject, OWLAnnotationValue, OWLLiteral, OWLObject, OWLPropertyAssertionObject

public class OWLLiteralImpl
extends OWLObjectImpl
implements OWLLiteral

Author: Matthew Horridge
The University Of Manchester
Bio-Health Informatics Group
Date: 26-Oct-2006


Constructor Summary
OWLLiteralImpl(OWLDataFactory dataFactory, java.lang.String literal, OWLDatatype datatype)
           
OWLLiteralImpl(OWLDataFactory dataFactory, java.lang.String literal, java.lang.String lang)
           
 
Method Summary
 void accept(OWLAnnotationValueVisitor visitor)
           
<O> O
accept(OWLAnnotationValueVisitorEx<O> visitor)
           
 void accept(OWLDataVisitor visitor)
           
<O> O
accept(OWLDataVisitorEx<O> visitor)
           
 void accept(OWLObjectVisitor visitor)
           
<O> O
accept(OWLObjectVisitorEx<O> visitor)
           
protected  int compareObjectOfSameType(OWLObject object)
           
 boolean equals(java.lang.Object obj)
           
 OWLDatatype getDatatype()
          Gets the OWLDatatype which types this literal.
 java.lang.String getLang()
          Gets the language tag of this literal.
 java.lang.String getLiteral()
          Gets the lexical value of this literal.
 boolean hasLang()
          Determines if this literal has a language tag.
 boolean hasLang(java.lang.String lang)
          Determines if this OWLLiteral has a particular language tag.
 boolean isBoolean()
          Determines if this literal is typed with a datatype that has an IRI that is "http://www.w3.org/2001/XMLSchema#"boolean.
 boolean isDouble()
          Determines if this literal is typed with a datatype that has an IRI that is "http://www.w3.org/2001/XMLSchema#"double.
 boolean isFloat()
          Determines if this literal is typed with a datatype that has an IRI that is "http://www.w3.org/2001/XMLSchema#"float.
 boolean isInteger()
          Determines if this literal is typed with a datatype that has an IRI that is "http://www.w3.org/2001/XMLSchema#"integer.
 boolean isRDFPlainLiteral()
          Determines if the datatype of this literal is rdf:PlainLiteral.
 boolean parseBoolean()
          Parses the lexical value of this literal into a boolean.
 double parseDouble()
          Parses the lexical value of this literal into a double.
 float parseFloat()
          Parses the lexical value of this literal into a float.
 int parseInteger()
          Parses the lexical value of this literal into an integer.
 
Methods inherited from class uk.ac.manchester.cs.owl.owlapi.OWLObjectImpl
compareSets, compareTo, getClassesInSignature, getDataPropertiesInSignature, getDatatypesInSignature, getIndividualsInSignature, getNestedClassExpressions, getObjectPropertiesInSignature, getOWLDataFactory, getSignature, hashCode, isBottomEntity, isTopEntity, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OWLLiteralImpl

public OWLLiteralImpl(OWLDataFactory dataFactory,
                      java.lang.String literal,
                      OWLDatatype datatype)

OWLLiteralImpl

public OWLLiteralImpl(OWLDataFactory dataFactory,
                      java.lang.String literal,
                      java.lang.String lang)
Method Detail

getLiteral

public java.lang.String getLiteral()
Description copied from interface: OWLLiteral
Gets the lexical value of this literal. Note that if the datatype is rdf:PlainLiteral then the abbreviated lexical form will be returned. That is, the language tag is not included.

Specified by:
getLiteral in interface OWLLiteral
Returns:
The lexical value of this literal. If the datatype is rdf:PlainLiteral then the return values are as follows: If the literal is of the form "abc@"^^rdf:PlainLiteral then the return value will be "abc" (without the language tag included). If the literal is of the form "abc@langTag"^^rdf:PlainLiteral then the return value will be "abc" (without the language tag included).

isRDFPlainLiteral

public boolean isRDFPlainLiteral()
Description copied from interface: OWLLiteral
Determines if the datatype of this literal is rdf:PlainLiteral. Note that literals that are abbreviated in the functional syntax (and other concrete syntaxes) and are of the form "abc" or "abc"@langTag will be of the type rdf:PlainLiteral after parsing.

Specified by:
isRDFPlainLiteral in interface OWLLiteral
Returns:
true if the datatype of this literal is rdf:PlainLiteral, otherwise false.

hasLang

public boolean hasLang()
Description copied from interface: OWLLiteral
Determines if this literal has a language tag.

Specified by:
hasLang in interface OWLLiteral
Returns:
true if this literal has a non-empty language tag, otherwise false

isInteger

public boolean isInteger()
Description copied from interface: OWLLiteral
Determines if this literal is typed with a datatype that has an IRI that is "http://www.w3.org/2001/XMLSchema#"integer.

Specified by:
isInteger in interface OWLLiteral
Returns:
true if this literal is typed with "http://www.w3.org/2001/XMLSchema#"integer, i.e. this literal represents an integer, otherwise false.

parseInteger

public int parseInteger()
                 throws java.lang.NumberFormatException
Description copied from interface: OWLLiteral
Parses the lexical value of this literal into an integer. The lexical value of this literal should be in the lexical space of the integer datatype ("http://www.w3.org/2001/XMLSchema#"integer)

Specified by:
parseInteger in interface OWLLiteral
Returns:
An integer value that is represented by this literal.
Throws:
java.lang.NumberFormatException - if the lexical form could not be parsed into an integer because it is not in the lexical space of the integer datatype.

isBoolean

public boolean isBoolean()
Description copied from interface: OWLLiteral
Determines if this literal is typed with a datatype that has an IRI that is "http://www.w3.org/2001/XMLSchema#"boolean.

Specified by:
isBoolean in interface OWLLiteral
Returns:
true if this literal is typed with "http://www.w3.org/2001/XMLSchema#"boolean, i.e. this literal represents a boolean, otherwise false.

parseBoolean

public boolean parseBoolean()
                     throws java.lang.NumberFormatException
Description copied from interface: OWLLiteral
Parses the lexical value of this literal into a boolean. The lexical value of this literal should be in the lexical space of the boolean datatype ("http://www.w3.org/2001/XMLSchema#"boolean).

Specified by:
parseBoolean in interface OWLLiteral
Returns:
A boolean value that is represented by this literal.
Throws:
java.lang.NumberFormatException - if the lexical form could not be parsed into a boolean because it is not in the lexical space of the boolean datatype.

isDouble

public boolean isDouble()
Description copied from interface: OWLLiteral
Determines if this literal is typed with a datatype that has an IRI that is "http://www.w3.org/2001/XMLSchema#"double.

Specified by:
isDouble in interface OWLLiteral
Returns:
true if this literal is typed with "http://www.w3.org/2001/XMLSchema#"double, i.e. this literal represents a double, otherwise false.

parseDouble

public double parseDouble()
                   throws java.lang.NumberFormatException
Description copied from interface: OWLLiteral
Parses the lexical value of this literal into a double. The lexical value of this literal should be in the lexical space of the double datatype ("http://www.w3.org/2001/XMLSchema#"double).

Specified by:
parseDouble in interface OWLLiteral
Returns:
A double value that is represented by this literal.
Throws:
java.lang.NumberFormatException - if the lexical form could not be parsed into a double because it is not in the lexical space of the double datatype.

isFloat

public boolean isFloat()
Description copied from interface: OWLLiteral
Determines if this literal is typed with a datatype that has an IRI that is "http://www.w3.org/2001/XMLSchema#"float.

Specified by:
isFloat in interface OWLLiteral
Returns:
true if this literal is typed with "http://www.w3.org/2001/XMLSchema#"float, i.e. this literal represents a float, otherwise false.

parseFloat

public float parseFloat()
                 throws java.lang.NumberFormatException
Description copied from interface: OWLLiteral
Parses the lexical value of this literal into a float. The lexical value of this literal should be in the lexical space of the float datatype ("http://www.w3.org/2001/XMLSchema#"float).

Specified by:
parseFloat in interface OWLLiteral
Returns:
A float value that is represented by this literal.
Throws:
java.lang.NumberFormatException - if the lexical form could not be parsed into a float because it is not in the lexical space of the float datatype.

getLang

public java.lang.String getLang()
Description copied from interface: OWLLiteral
Gets the language tag of this literal.

Specified by:
getLang in interface OWLLiteral
Returns:
The language tag of this literal. If the literal does not have a language tag, because it is not of the type rdf:PlainLiteral, or because its language tag is empty, then the empty string will be returned. (The null value is never returned).

hasLang

public boolean hasLang(java.lang.String lang)
Description copied from interface: OWLLiteral
Determines if this OWLLiteral has a particular language tag.

Specified by:
hasLang in interface OWLLiteral
Parameters:
lang - The specific lang to test for. The tag will be normalised - white space will be trimmed from the end and it will be converted to lower case.
Returns:
true if this literal has a language tag equal to lang, otherwise false.

getDatatype

public OWLDatatype getDatatype()
Description copied from interface: OWLLiteral
Gets the OWLDatatype which types this literal.

Specified by:
getDatatype in interface OWLLiteral
Returns:
The OWLDatatype that types this literal. Note that for strings with language tag (previously considered to be untyped literals) the datatype will be rdf:PlainLiteral. The return value is never null.

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class OWLObjectImpl

accept

public void accept(OWLDataVisitor visitor)
Specified by:
accept in interface OWLLiteral

accept

public <O> O accept(OWLDataVisitorEx<O> visitor)
Specified by:
accept in interface OWLLiteral

accept

public void accept(OWLAnnotationValueVisitor visitor)
Specified by:
accept in interface OWLAnnotationValue

accept

public <O> O accept(OWLAnnotationValueVisitorEx<O> visitor)
Specified by:
accept in interface OWLAnnotationValue

compareObjectOfSameType

protected int compareObjectOfSameType(OWLObject object)
Specified by:
compareObjectOfSameType in class OWLObjectImpl

accept

public void accept(OWLObjectVisitor visitor)
Specified by:
accept in interface OWLObject

accept

public <O> O accept(OWLObjectVisitorEx<O> visitor)
Specified by:
accept in interface OWLObject