org.eclipse.rdf4j.model

## Interface Literal

- All Superinterfaces:
    Serializable, Value
  All Known Implementing Classes:
    BooleanLiteral, BooleanLiteralImpl, BooleanMemLiteral, CalendarLiteral, CalendarMemLiteral, DecimalLiteral, DecimalMemLiteral, IntegerLiteral, IntegerMemLiteral, LiteralImpl, MemLiteral, NativeLiteral, NumericLiteral, NumericMemLiteral, SimpleLiteral

      public interface Literal
      extends Value

  An RDF-1.1 literal consisting of a label (the lexical value), a datatype, and optionally a language tag.
  Author:
    Arjohn Kampman
  See Also:
    RDF-1.1 Concepts and Abstract Syntax

- - ### Method Summary

    All Methods Instance Methods Abstract 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 other)` Compares a literal object to another object.
    `float` | `floatValue()` Returns the `float` value of this literal.
    `IRI` | `getDatatype()` Gets the datatype for this literal.
    `String` | `getLabel()` Gets the label (the lexical value) of this literal.
    `Optional<String>` | `getLanguage()` Gets the language tag for this literal, normalized to lower case.
    `int` | `hashCode()` Returns the literal's hash code.
    `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.

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

      `stringValue`

- - ### Method Detail

    - #### getLabel

          String getLabel()

      Gets the label (the lexical value) of this literal.
      Returns:
        The literal's label.

    - #### getLanguage

          Optional<String> getLanguage()

      Gets the language tag for this literal, normalized to lower case.
      Returns:
        The language tag for this literal, or `Optional.empty()` if it doesn't have one.

    - #### getDatatype

          IRI getDatatype()

      Gets the datatype for this literal. If `getLanguage()` returns a non-empty value than this must return `RDF.LANGSTRING`. If no datatype was assigned to this literal by the creator, then this method must return `XMLSchema.STRING`.
      Returns:
        The datatype for this literal.

    - #### equals

          boolean equals(Object other)

      Compares a literal object to another object.
      Overrides:
        `equals` in class `Object`
      Parameters:
        `other` - 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

          int hashCode()

      Returns the literal's hash code. The hash code of a literal is defined as the hash code of its label: `label.hashCode()`.
      Overrides:
        `hashCode` in class `Object`
      Returns:
        A hash code for the literal.

    - #### byteValue

          byte byteValue()

      Returns the `byte` value of this literal.
      Returns:
        The `byte value of the literal. @throws NumberFormatException If the literal cannot be represented by a `byte`.`

    - #### shortValue

          short shortValue()

      Returns the `short` value of this literal.
      Returns:
        The `short` value of the literal.
      Throws:
        `NumberFormatException` - If the literal's label cannot be represented by a `short`.

    - #### intValue

          int intValue()

      Returns the `int` value of this literal.
      Returns:
        The `int` value of the literal.
      Throws:
        `NumberFormatException` - If the literal's label cannot be represented by a `int`.

    - #### longValue

          long longValue()

      Returns the `long` value of this literal.
      Returns:
        The `long` value of the literal.
      Throws:
        `NumberFormatException` - If the literal's label cannot be represented by to a `long` .

    - #### integerValue

          BigInteger integerValue()

      Returns the integer value of this literal.
      Returns:
        The integer value of the literal.
      Throws:
        `NumberFormatException` - If the literal's label is not a valid integer.

    - #### decimalValue

          BigDecimal decimalValue()

      Returns the decimal value of this literal.
      Returns:
        The decimal value of the literal.
      Throws:
        `NumberFormatException` - If the literal's label is not a valid decimal.

    - #### floatValue

          float floatValue()

      Returns the `float` value of this literal.
      Returns:
        The `float` value of the literal.
      Throws:
        `NumberFormatException` - If the literal's label cannot be represented by a `float`.

    - #### doubleValue

          double doubleValue()

      Returns the `double` value of this literal.
      Returns:
        The `double` value of the literal.
      Throws:
        `NumberFormatException` - If the literal's label cannot be represented by a `double`.

    - #### booleanValue

          boolean booleanValue()

      Returns the `boolean` value of this literal.
      Returns:
        The `long` value of the literal.
      Throws:
        `IllegalArgumentException` - If the literal's label cannot be represented by a `boolean` .

    - #### calendarValue

          XMLGregorianCalendar calendarValue()

      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`.
      Returns:
        The calendar value of the literal.
      Throws:
        `IllegalArgumentException` - If the literal cannot be represented by a `XMLGregorianCalendar`.

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