Package org.semanticweb.owlapi.model
Interface OWLLiteral
- All Superinterfaces:
Comparable<OWLObject>
,HasAnnotationPropertiesInSignature
,HasAnnotationValue
,HasAnonymousIndividuals
,HasClassesInSignature
,HasComponents
,HasContainsEntityInSignature
,HasDataPropertiesInSignature
,HasDatatypesInSignature
,HasHashIndex
,HasIndex
,HasIndividualsInSignature
,HasLang
,HasObjectPropertiesInSignature
,HasSignature
,IsAnonymous
,OWLAnnotationObject
,OWLAnnotationValue
,OWLObject
,OWLPrimitive
,OWLPropertyAssertionObject
,Serializable
public interface OWLLiteral
extends OWLObject, OWLAnnotationObject, OWLAnnotationValue, OWLPropertyAssertionObject, OWLPrimitive, HasLang
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.
- Since:
- 2.0.0
- Author:
- Matthew Horridge, The University Of Manchester, Bio-Health Informatics Group
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
accept
(OWLAnnotationValueVisitor visitor) default <O> O
accept
(OWLAnnotationValueVisitorEx<O> visitor) default void
accept
(OWLDataVisitor visitor) default <O> O
accept
(OWLDataVisitorEx<O> visitor) default void
accept
(OWLObjectVisitor visitor) Accepts a visitordefault <O> O
accept
(OWLObjectVisitorEx<O> visitor) Accepts a visitordefault Optional<OWLLiteral>
default Stream<?>
Gets theOWLDatatype
which types this literal.default String
getLang()
Gets the language tag of the literal.Gets the lexical value of this literal.default int
default boolean
hasLang()
Determines if this literal has a language tag.default boolean
Determines if thisOWLLiteral
has a particular language tag.default int
default boolean
Determines if this literal is typed with a datatype that has an IRI that is"http://www.w3.org/2001/XMLSchema#"boolean
.default boolean
isDouble()
Determines if this literal is typed with a datatype that has an IRI that is"http://www.w3.org/2001/XMLSchema#"double
.default boolean
isFloat()
Determines if this literal is typed with a datatype that has an IRI that is"http://www.w3.org/2001/XMLSchema#"float
.default boolean
Determines if this literal is typed with a datatype that has an IRI that is"http://www.w3.org/2001/XMLSchema#"integer
.default boolean
default boolean
Determines if the datatype of this literal isrdf:PlainLiteral
.default boolean
Parses the lexical value of this literal into a boolean.default double
Parses the lexical value of this literal into a double.default float
Parses the lexical value of this literal into a float.default int
Parses the lexical value of this literal into an integer.default int
Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface org.semanticweb.owlapi.model.HasAnnotationPropertiesInSignature
annotationPropertiesInSignature, getAnnotationPropertiesInSignature
Methods inherited from interface org.semanticweb.owlapi.model.HasAnnotationValue
anonymousIndividualValue, ifAnonymousIndividual, ifAnonymousIndividualOrElse, ifIri, ifIriOrElse, ifLiteral, ifLiteralOrElse, ifValue, iriValue, literalValue, map, map, mapAnonymousIndividual, mapAnonymousIndividualOrElse, mapAnonymousIndividualOrElseGet, mapIri, mapIriOrElse, mapIriOrElseGet, mapLiteral, mapLiteralOrElse, mapLiteralOrElseGet, mapValue, when
Methods inherited from interface org.semanticweb.owlapi.model.HasAnonymousIndividuals
anonymousIndividuals, getAnonymousIndividuals
Methods inherited from interface org.semanticweb.owlapi.model.HasClassesInSignature
classesInSignature, getClassesInSignature
Methods inherited from interface org.semanticweb.owlapi.model.HasComponents
componentsAnnotationsFirst, componentsWithoutAnnotations
Methods inherited from interface org.semanticweb.owlapi.model.HasContainsEntityInSignature
containsEntityInSignature
Methods inherited from interface org.semanticweb.owlapi.model.HasDataPropertiesInSignature
dataPropertiesInSignature, getDataPropertiesInSignature
Methods inherited from interface org.semanticweb.owlapi.model.HasDatatypesInSignature
datatypesInSignature, getDatatypesInSignature
Methods inherited from interface org.semanticweb.owlapi.model.HasIndividualsInSignature
getIndividualsInSignature, individualsInSignature
Methods inherited from interface org.semanticweb.owlapi.model.HasObjectPropertiesInSignature
getObjectPropertiesInSignature, objectPropertiesInSignature
Methods inherited from interface org.semanticweb.owlapi.model.HasSignature
getSignature, signature, unsortedSignature
Methods inherited from interface org.semanticweb.owlapi.model.IsAnonymous
isAnonymous, isNamed
Methods inherited from interface org.semanticweb.owlapi.model.OWLAnnotationObject
asAnonymousIndividual, asIRI
Methods inherited from interface org.semanticweb.owlapi.model.OWLAnnotationValue
annotationValue
Methods inherited from interface org.semanticweb.owlapi.model.OWLObject
getNestedClassExpressions, hasSharedStructure, isAnonymousExpression, isAxiom, isBottomEntity, isIndividual, isIRI, isOntology, isTopEntity, nestedClassExpressions
-
Method Details
-
components
- Specified by:
components
in interfaceHasComponents
- Returns:
- components as a stream. The stream is ordered (by visit order) but not sorted. Implementations that override components() must ensure the order is compatible with equals() and hashCode().
-
initHashCode
default int initHashCode()- Specified by:
initHashCode
in interfaceOWLObject
- Returns:
- hash code for the object; called on first use, cached by OWLObjectImpl in the default implementation.
-
hashIndex
default int hashIndex()- Specified by:
hashIndex
in interfaceHasHashIndex
- Returns:
- index for this type. This is not a hashcode for instances, rather a hashcode for the types.
-
typeIndex
default int typeIndex() -
isRDFPlainLiteral
default boolean isRDFPlainLiteral()Determines if the datatype of this literal isrdf: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 typerdf:PlainLiteral
after parsing.- Returns:
true
if the datatype of this literal is rdf:PlainLiteral, otherwisefalse
.
-
getLiteral
String getLiteral()Gets the lexical value of this literal. Note that if the datatype isrdf: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).
-
getLang
Description copied from interface:HasLang
Gets the language tag of the literal. -
getDatatype
OWLDatatype getDatatype()Gets theOWLDatatype
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 nevernull
.
-
hasLang
default boolean hasLang()Determines if this literal has a language tag.- Returns:
true
if this literal has a non-empty language tag, otherwisefalse
-
hasLang
Determines if thisOWLLiteral
has a particular language tag.- Parameters:
lang
- The specific language tag to test for. The tag will be normalised - white space will be trimmed from the end and it will be converted to lower case. Null input will be treated as empty.- Returns:
true
if this literal has a language tag equal tolang
, otherwisefalse
.
-
isInteger
default 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, otherwisefalse
.
-
parseInteger
default int parseInteger()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:
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
default 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, otherwisefalse
.
-
parseBoolean
default boolean parseBoolean()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:
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
default 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, otherwisefalse
.
-
parseDouble
default double parseDouble()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:
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
default 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, otherwisefalse
.
-
parseFloat
default float parseFloat()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:
NumberFormatException
- if the lexical form could not be parsed into a float because it is not in the lexical space of the float datatype.
-
asLiteral
- Specified by:
asLiteral
in interfaceOWLAnnotationValue
- Returns:
- if the value is a literal, return an optional containing it. Return Optional.absent otherwise.
-
accept
- Parameters:
visitor
- visitor
-
accept
- Type Parameters:
O
- visitor return type- Parameters:
visitor
- visitor- Returns:
- visitor return value
-
accept
Description copied from interface:OWLObject
Accepts a visitor -
accept
Description copied from interface:OWLObject
Accepts a visitor -
accept
- Specified by:
accept
in interfaceOWLAnnotationValue
- Parameters:
visitor
- visitor to accept
-
accept
- Specified by:
accept
in interfaceOWLAnnotationValue
- Type Parameters:
O
- visitor return type- Parameters:
visitor
- visitor to accept- Returns:
- visitor value
-
isLiteral
default boolean isLiteral()- Specified by:
isLiteral
in interfaceOWLAnnotationValue
- Returns:
- true if the annotation value is a literal
-