org.eclipse.rdf4j.model.base

## Class AbstractLiteral

- java.lang.Object
- - org.eclipse.rdf4j.model.base.AbstractLiteral

- All Implemented Interfaces:
    Serializable, Literal, Value
  Direct Known Subclasses:
    SimpleLiteral

      public abstract class AbstractLiteral
      extends Object
      implements Literal

  Base class for `Literal`, offering common functionality.
  Since:
    3.5.0
  Author:
    Alessandro Bollini
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractLiteral()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `booleanValue()` Returns the `boolean` value of this literal.
    `byte` | `byteValue()` Returns the `byte` value of this literal.
    `XMLGregorianCalendar` | `calendarValue()` Returns the `XMLGregorianCalendar` value of this literal.
    `BigDecimal` | `decimalValue()` Returns the decimal value of this literal.
    `double` | `doubleValue()` Returns the `double` value of this literal.
    `boolean` | `equals(Object o)` Compares this literal to another object.
    `float` | `floatValue()` Returns the `float` value of this literal.
    `int` | `hashCode()` Computes the hash code of this literal.
    `BigInteger` | `integerValue()` Returns the integer value of this literal.
    `int` | `intValue()` Returns the `int` value of this literal.
    `long` | `longValue()` Returns the `long` value of this literal.
    `short` | `shortValue()` Returns the `short` value of this literal.
    `String` | `stringValue()` Returns the String-value of a `Value` object.
    `java.time.temporal.TemporalAccessor` | `temporalAccessorValue()` Retrieves the `temporal accessor` value of this literal.
    `java.time.temporal.TemporalAmount` | `temporalAmountValue()` Retrieves the `temporal amount` value of this literal.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.eclipse.rdf4j.model.Literal

      `getDatatype, getLabel, getLanguage, isLiteral`

    - ### Methods inherited from interface org.eclipse.rdf4j.model.Value

      `isBNode, isIRI, isResource, isTriple`

- - ### Constructor Detail

    - #### AbstractLiteral

          public AbstractLiteral()

  - ### Method Detail

    - #### stringValue

          public String stringValue()

      Description copied from interface: `Value`
      Returns the String-value of a `Value` object. This returns either a `Literal`'s label, a `IRI`'s URI or a `BNode`'s ID.
      Specified by:
        `stringValue` in interface `Value`

    - #### booleanValue

          public boolean booleanValue()

      Description copied from interface: `Literal`
      Returns the `boolean` value of this literal.
      Specified by:
        `booleanValue` in interface `Literal`
      Returns:
        The `boolean` value of the literal.

    - #### byteValue

          public byte byteValue()

      Description copied from interface: `Literal`
      Returns the `byte` value of this literal.
      Specified by:
        `byteValue` in interface `Literal`
      Returns:
        The `byte` value of the literal.

    - #### shortValue

          public short shortValue()

      Description copied from interface: `Literal`
      Returns the `short` value of this literal.
      Specified by:
        `shortValue` in interface `Literal`
      Returns:
        The `short` value of the literal.

    - #### intValue

          public int intValue()

      Description copied from interface: `Literal`
      Returns the `int` value of this literal.
      Specified by:
        `intValue` in interface `Literal`
      Returns:
        The `int` value of the literal.

    - #### longValue

          public long longValue()

      Description copied from interface: `Literal`
      Returns the `long` value of this literal.
      Specified by:
        `longValue` in interface `Literal`
      Returns:
        The `long` value of the literal.

    - #### floatValue

          public float floatValue()

      Description copied from interface: `Literal`
      Returns the `float` value of this literal.
      Specified by:
        `floatValue` in interface `Literal`
      Returns:
        The `float` value of the literal.

    - #### doubleValue

          public double doubleValue()

      Description copied from interface: `Literal`
      Returns the `double` value of this literal.
      Specified by:
        `doubleValue` in interface `Literal`
      Returns:
        The `double` value of the literal.

    - #### integerValue

          public BigInteger integerValue()

      Description copied from interface: `Literal`
      Returns the integer value of this literal.
      Specified by:
        `integerValue` in interface `Literal`
      Returns:
        The integer value of the literal.

    - #### decimalValue

          public BigDecimal decimalValue()

      Description copied from interface: `Literal`
      Returns the decimal value of this literal.
      Specified by:
        `decimalValue` in interface `Literal`
      Returns:
        The decimal value of the literal.

    - #### temporalAccessorValue

          public java.time.temporal.TemporalAccessor temporalAccessorValue()
                                                                    throws java.time.DateTimeException

      Description copied from interface: `Literal`
      Retrieves the `temporal accessor` value of this literal.

      A temporal accessor representation can be given for literals whose label conforms to the syntax of the following XML Schema 1.1 date/time datatypes:

      - xsd:dateTime,
      - xsd:time,
      - xsd:date,
      - xsd:gYearMonth,
      - xsd:gYear,
      - xsd:gMonthDay,
      - xsd:gDay,
      - xsd:gMonth.

      Temporal accessor representations may be converted to specific `java.time` values like `OffsetDateTime` using target static factory methods, for instance `OffsetDateTime.from(literal.temporalAccessorValue())`.

      Note however that `java.time` doesn't include dedicated classes for some legal XML Schema date/time values, like offset dates (for instance, `2020-11-16+01:00`) and `xsd:gDay` (for instance, `---16`).

      Specified by:
        `temporalAccessorValue` in interface `Literal`
      Returns:
        the temporal accessor value of this literal
      Throws:
        `java.time.DateTimeException` - if this literal cannot be represented by a `TemporalAccessor` value
      See Also:
        The Java™ Tutorials – Trail: Date Time

    - #### temporalAmountValue

          public java.time.temporal.TemporalAmount temporalAmountValue()
                                                                throws java.time.DateTimeException

      Description copied from interface: `Literal`
      Retrieves the `temporal amount` value of this literal.

      A temporal amount representation can be given for literals whose label conforms to the syntax of the XML Schema 2 xsd:duration datatype.

      The adoption of the XML Schema 2 definition is a known deviation from the RDF 1.1 standard; well-formedness rules are relaxed to consider all duration components as optional and freely mixable.

      Temporal amount representations may be converted to specific `java.time` values like `Duration` using target static factory methods, for instance `Duration.from(literal.temporalAmountValue())`.

      Note however that `java.time` doesn't include dedicated classes for legal XML Schema duration values including both date and time components (for instance, `P1YT23H`).

      Specified by:
        `temporalAmountValue` in interface `Literal`
      Returns:
        the temporal amount value of this literal
      Throws:
        `java.time.DateTimeException` - if this literal cannot be represented by a `TemporalAmount` value
      See Also:
        The Java™ Tutorials – Trail: Date Time

    - #### calendarValue

          public XMLGregorianCalendar calendarValue()

      Description copied from interface: `Literal`
      Returns the `XMLGregorianCalendar` value of this literal. A calendar representation can be given for literals whose label conforms to the syntax of the following XML Schema datatypes: `dateTime`, `time`, `date`, `gYearMonth`, `gMonthDay`, `gYear`, `gMonth` or `gDay`.
      Specified by:
        `calendarValue` in interface `Literal`
      Returns:
        The calendar value of the literal.

    - #### equals

          public boolean equals(Object o)

      Description copied from interface: `Literal`
      Compares this literal to another object.
      Specified by:
        `equals` in interface `Literal`
      Overrides:
        `equals` in class `Object`
      Parameters:
        `o` - the object to compare this literal to
      Returns:
        `true`, if the other object is an instance of `Literal` and if their labels, language tags and datatypes are equal

    - #### hashCode

          public int hashCode()

      Description copied from interface: `Literal`
      Computes the hash code of this literal.
      Specified by:
        `hashCode` in interface `Literal`
      Overrides:
        `hashCode` in class `Object`
      Returns:
        a hash code for this literal computed as `Literal.getLabel()``.hashCode()`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2015-2022 Eclipse Foundation. All Rights Reserved.