org.semanticweb.owlapi.model
Interface OWLLiteral

All Superinterfaces:
java.lang.Comparable<OWLObject>, OWLAnnotationObject, OWLAnnotationValue, OWLObject, OWLPropertyAssertionObject
All Known Implementing Classes:
OWLLiteralImpl

public interface OWLLiteral
extends OWLObject, OWLAnnotationObject, OWLAnnotationValue, OWLPropertyAssertionObject

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

Represents a Literal in the OWL 2 Specification.

Each literal consists of a lexical form, which is a string, and a datatype. A literal consisting of a lexical form "abc" and a datatype identified by the IRI datatypeIRI is written as "abc"^^datatypeIRI.

Note that literals whose datatype is rdf:PlainLiteral can be abbreviated. For example, literals of the form "abc@"^^rdf:PlainLiteral can be abbreviated in the functional-style syntax, and other concrete syntaxes to "abc". Literals of the form "abc@langTag"^^rdf:PlainLiteral where "langTag" is not empty are abbreviated in functional-style syntax documents (and other concrete syntaxes) to "abc"@langTag whenever possible.


Method Summary
 void accept(OWLDataVisitor visitor)
           
<O> O
accept(OWLDataVisitorEx<O> visitor)
           
 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 interface org.semanticweb.owlapi.model.OWLAnnotationValue
accept, accept
 

Method Detail

isRDFPlainLiteral

boolean isRDFPlainLiteral()
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.

Returns:
true if the datatype of this literal is rdf:PlainLiteral, otherwise false.

getLiteral

java.lang.String getLiteral()
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.

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).

getDatatype

OWLDatatype getDatatype()
Gets the OWLDatatype which types this literal.

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.

hasLang

boolean hasLang()
Determines if this literal has a language tag.

Returns:
true if this literal has a non-empty language tag, otherwise false

getLang

java.lang.String getLang()
Gets the language tag of this literal.

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

boolean hasLang(java.lang.String lang)
Determines if this OWLLiteral has a particular language tag.

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.

isInteger

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

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

int parseInteger()
                 throws java.lang.NumberFormatException
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)

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

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

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

boolean parseBoolean()
                     throws java.lang.NumberFormatException
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).

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

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

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

double parseDouble()
                   throws java.lang.NumberFormatException
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).

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

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

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

float parseFloat()
                 throws java.lang.NumberFormatException
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).

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.

accept

void accept(OWLDataVisitor visitor)

accept

<O> O accept(OWLDataVisitorEx<O> visitor)