Class LiteralImpl

All Implemented Interfaces:
FrontsNode, Literal, RDFNode

public class LiteralImpl extends EnhNode implements Literal
An implementation of Literal.
  • Field Details

  • Constructor Details

  • Method Details

    • visitWith

      public Object visitWith(RDFVisitor rv)
      Description copied from interface: RDFNode
      Apply the appropriate method of the visitor to this node's content and return the result.
      Specified by:
      visitWith in interface RDFNode
      Parameters:
      rv - an RDFVisitor with a method for URI/blank/literal nodes
      Returns:
      the result returned by the selected method
    • inModel

      public Literal inModel(Model m)
      Literals are not in any particular model, and so inModel can return this.
      Specified by:
      inModel in interface Literal
      Specified by:
      inModel in interface RDFNode
      Parameters:
      m - a model to move the literal into
      Returns:
      this
    • asLiteral

      public Literal asLiteral()
      Description copied from interface: RDFNode
      If this node is a Literal, answer that literal; otherwise throw an exception.
      Specified by:
      asLiteral in interface RDFNode
    • asResource

      public Resource asResource()
      Description copied from interface: RDFNode
      If this node is a Resource, answer that resource; otherwise throw an exception.
      Specified by:
      asResource in interface RDFNode
    • getModel

      public Model getModel()
      Answer the model this literal was created in, if any, otherwise null.
      Specified by:
      getModel in interface RDFNode
      Returns:
      The model associated with this resource.
    • toString

      public String toString()
      Description copied from interface: RDFNode
      Answer a String representation of the node. The form of the string depends on the type of the node and is intended for human consumption, not machine analysis.
      Specified by:
      toString in interface RDFNode
      Overrides:
      toString in class Object
    • getValue

      public Object getValue()
      Return the value of the literal. In the case of plain literals this will return the literal string. In the case of typed literals it will return a java object representing the value. In the case of typed literals representing a java primitive then the appropriate java wrapper class (Integer etc) will be returned.
      Specified by:
      getValue in interface Literal
    • getDatatype

      public RDFDatatype getDatatype()
      Return the datatype of the literal. This will be null in the case of plain literals.
      Specified by:
      getDatatype in interface Literal
    • getDatatypeURI

      public String getDatatypeURI()
      Return the uri of the datatype of the literal. This will be null in the case of plain literals.
      Specified by:
      getDatatypeURI in interface Literal
    • getLexicalForm

      public String getLexicalForm()
      Return the lexical form of the literal.
      Specified by:
      getLexicalForm in interface Literal
    • getBoolean

      public boolean getBoolean()
      Description copied from interface: Literal
      If the literal is interpretable as a Boolean return its value as a boolean. Plain literals are interpreted by parsing their lexical representation, typed literals are interpreted by coercion of the java object representing their value.
      Specified by:
      getBoolean in interface Literal
      Returns:
      the literal interpreted as a boolean
    • getByte

      public byte getByte()
      Description copied from interface: Literal
      If the literal is interpretable as a Byte return its value. Plain literals are interpreted by parsing their lexical representation, typed literals are interpreted by coercion of the java object representing their value.
      Specified by:
      getByte in interface Literal
      Returns:
      the literal interpreted as a byte
    • getShort

      public short getShort()
      Description copied from interface: Literal
      If the literal is interpretable as a Short return its value. Plain literals are interpreted by parsing their lexical representation, typed literals are interpreted by coercion of the java object representing their value.
      Specified by:
      getShort in interface Literal
      Returns:
      the literal interpreted as a short
    • getInt

      public int getInt()
      Description copied from interface: Literal
      If the literal is interpretable as a Integer return its value. Plain literals are interpreted by parsing their lexical representation, typed literals are interpreted by coercion of the java object representing their value.
      Specified by:
      getInt in interface Literal
      Returns:
      the literal interpreted as an int
    • getLong

      public long getLong()
      Description copied from interface: Literal
      If the literal is interpretable as a Long return its value. Plain literals are interpreted by parsing their lexical representation, typed literals are interpreted by coercion of the java object representing their value.
      Specified by:
      getLong in interface Literal
      Returns:
      the literal interpreted as a long
    • getChar

      public char getChar()
      Description copied from interface: Literal
      If the literal is interpretable as a Char return its value. Plain literals are interpreted by parsing their lexical representation, typed literals are interpreted by coercion of the java object representing their value.
      Specified by:
      getChar in interface Literal
      Returns:
      the literal interpreted as a char
    • getFloat

      public float getFloat()
      Description copied from interface: Literal
      If the literal is interpretable as a Float return its value. Plain literals are interpreted by parsing their lexical representation, typed literals are interpreted by coercion of the java object representing their value.
      Specified by:
      getFloat in interface Literal
      Returns:
      the literal interpreted as a float
    • getDouble

      public double getDouble()
      Description copied from interface: Literal
      If the literal is interpretable as a Double return its value. Plain literals are interpreted by parsing their lexical representation, typed literals are interpreted by coercion of the java object representing their value.
      Specified by:
      getDouble in interface Literal
      Returns:
      the literal interpreted as a double
    • getString

      public String getString()
      Description copied from interface: Literal
      If the literal is interpretable as a string return its value.
      Specified by:
      getString in interface Literal
      Returns:
      the literal string or its lexical value
    • getLanguage

      public String getLanguage()
      Description copied from interface: Literal
      If a language is defined for this literal return it
      Specified by:
      getLanguage in interface Literal
      Returns:
      the language for this literal if it exists, or empty string if none
    • getTextDirection

      public String getTextDirection()
      Description copied from interface: Literal
      If a text direction is defined for this literal return it
      Specified by:
      getTextDirection in interface Literal
      Returns:
      the text direction for this literal if it exists, or null if none
    • sameValueAs

      public boolean sameValueAs(Literal other)
      Test that two literals are semantically equivalent. In some cases this may be the same as equals, in others equals is stricter. For example, two xsd:int literals with the same value but different language tag are semantically equivalent but distinguished by the java equality function in order to support round tripping.
      Specified by:
      sameValueAs in interface Literal