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

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 Details

    • components

      default Stream<?> components()
      Specified by:
      components in interface HasComponents
      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 interface OWLObject
      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 interface HasHashIndex
      Returns:
      index for this type. This is not a hashcode for instances, rather a hashcode for the types.
    • typeIndex

      default int typeIndex()
      Specified by:
      typeIndex in interface HasIndex
      Returns:
      index for this type. This is not a hashcode for instances, rather a sorting index for the types.
    • isRDFPlainLiteral

      default 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

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

      default String getLang()
      Description copied from interface: HasLang
      Gets the language tag of the literal.
      Specified by:
      getLang in interface HasLang
      Returns:
      A string representing the language tag of a 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.
    • 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

      default boolean hasLang()
      Determines if this literal has a language tag.
      Returns:
      true if this literal has a non-empty language tag, otherwise false
    • hasLang

      default boolean hasLang(@Nullable String lang)
      Determines if this OWLLiteral 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 to lang, otherwise false.
    • 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, otherwise false.
    • 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, otherwise false.
    • 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, otherwise false.
    • 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, otherwise false.
    • 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

      default Optional<OWLLiteral> asLiteral()
      Specified by:
      asLiteral in interface OWLAnnotationValue
      Returns:
      if the value is a literal, return an optional containing it. Return Optional.absent otherwise.
    • accept

      default void accept(OWLDataVisitor visitor)
      Parameters:
      visitor - visitor
    • accept

      default <O> O accept(OWLDataVisitorEx<O> visitor)
      Type Parameters:
      O - visitor return type
      Parameters:
      visitor - visitor
      Returns:
      visitor return value
    • accept

      default void accept(OWLObjectVisitor visitor)
      Description copied from interface: OWLObject
      Accepts a visitor
      Specified by:
      accept in interface OWLObject
      Parameters:
      visitor - The visitor
    • accept

      default <O> O accept(OWLObjectVisitorEx<O> visitor)
      Description copied from interface: OWLObject
      Accepts a visitor
      Specified by:
      accept in interface OWLObject
      Type Parameters:
      O - visitor return type
      Parameters:
      visitor - The visitor
      Returns:
      visitor value
    • accept

      default void accept(OWLAnnotationValueVisitor visitor)
      Specified by:
      accept in interface OWLAnnotationValue
      Parameters:
      visitor - visitor to accept
    • accept

      default <O> O accept(OWLAnnotationValueVisitorEx<O> visitor)
      Specified by:
      accept in interface OWLAnnotationValue
      Type Parameters:
      O - visitor return type
      Parameters:
      visitor - visitor to accept
      Returns:
      visitor value
    • isLiteral

      default boolean isLiteral()
      Specified by:
      isLiteral in interface OWLAnnotationValue
      Returns:
      true if the annotation value is a literal