Class LangString

  • All Implemented Interfaces:
    RdfLiteral, RdfTerm

    public class LangString
    extends Literal
    implements RdfLiteral
    Represents an RDF language-tagged string.

    A LangString is an RDF literal that consists of a lexical value (the value of the literal), a datatype, an optional language tag, and an optional direction (left-to-right or right-to-left). It implements the RdfLiteral interface and provides methods for retrieving the lexical value, datatype, language tag, and direction of the language-tagged string.

    • Constructor Summary

      Constructors 
      Constructor Description
      LangString​(java.lang.String lexicalValue, java.lang.String datatype, java.lang.String langTag, RdfLiteral.Direction direction)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Optional<RdfLiteral.Direction> direction()
      Returns the direction of the literal, which can be either left-to-right (LTR) or right-to-left (RTL).
      boolean equals​(java.lang.Object obj)
      Compares this RDF term to the specified object.
      int hashCode()
      Returns a hash code value for this RDF term.
      java.util.Optional<java.lang.String> language()
      Returns an optional language tag associated with the literal.
      static LangString of​(java.lang.String lexicalValue, java.lang.String datatype, java.lang.String langTag)
      Factory method to create a LangString with the specified lexical value, datatype, and language tag.
      static LangString of​(java.lang.String lexicalValue, java.lang.String datatype, java.lang.String langTag, RdfLiteral.Direction direction)
      Factory method to create a LangString with the specified lexical value, datatype, language tag, and direction.
      static LangString of​(java.lang.String lexicalValue, java.lang.String datatype, java.lang.String langTag, java.lang.String direction)
      Factory method to create a LangString with the specified lexical value, datatype, language tag, and direction.
      java.lang.String toString()
      Returns a string representation of this RDF term.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • LangString

        LangString​(java.lang.String lexicalValue,
                   java.lang.String datatype,
                   java.lang.String langTag,
                   RdfLiteral.Direction direction)
    • Method Detail

      • of

        public static LangString of​(java.lang.String lexicalValue,
                                    java.lang.String datatype,
                                    java.lang.String langTag)
        Factory method to create a LangString with the specified lexical value, datatype, and language tag.
        Parameters:
        lexicalValue - the lexical value of the language-tagged string
        datatype - the datatype of the literal (e.g., rdf:langString)
        langTag - the language tag (e.g., "en", "fr")
        Returns:
        a new LangString instance
      • of

        public static LangString of​(java.lang.String lexicalValue,
                                    java.lang.String datatype,
                                    java.lang.String langTag,
                                    java.lang.String direction)
        Factory method to create a LangString with the specified lexical value, datatype, language tag, and direction.
        Parameters:
        lexicalValue - the lexical value of the language-tagged string
        datatype - the datatype of the literal (e.g., rdf:langString)
        langTag - the language tag (e.g., "en", "fr")
        direction - the text direction (LTR or RTL)
        Returns:
        a new LangString instance
      • of

        public static LangString of​(java.lang.String lexicalValue,
                                    java.lang.String datatype,
                                    java.lang.String langTag,
                                    RdfLiteral.Direction direction)
        Factory method to create a LangString with the specified lexical value, datatype, language tag, and direction.
        Parameters:
        lexicalValue - the lexical value of the language-tagged string
        datatype - the datatype of the literal (e.g., rdf:langString)
        langTag - the language tag (e.g., "en", "fr")
        direction - the text direction (LTR or RTL)
        Returns:
        a new LangString instance
      • language

        public java.util.Optional<java.lang.String> language()
        Description copied from interface: RdfLiteral
        Returns an optional language tag associated with the literal.

        If the literal is a language-tagged string (e.g. rdf:langString), this method returns the language tag; otherwise, it returns Optional.empty().

        Specified by:
        language in interface RdfLiteral
        Overrides:
        language in class Literal
        Returns:
        an Optional containing the language tag if present, or Optional.empty() if not set
      • direction

        public java.util.Optional<RdfLiteral.Direction> direction()
        Description copied from interface: RdfLiteral
        Returns the direction of the literal, which can be either left-to-right (LTR) or right-to-left (RTL).
        Specified by:
        direction in interface RdfLiteral
        Overrides:
        direction in class Literal
        Returns:
        an Optional containing the direction if present, or Optional.empty() if not set
      • equals

        public boolean equals​(java.lang.Object obj)
        Description copied from interface: RdfTerm
        Compares this RDF term to the specified object. Implementations must override this method to provide equality checks appropriate to the term type.
        Specified by:
        equals in interface RdfTerm
        Overrides:
        equals in class Literal
        Parameters:
        obj - the object to compare with this term.
        Returns:
        true if the specified object is equal to this term; false otherwise.
      • toString

        public java.lang.String toString()
        Description copied from interface: RdfTerm
        Returns a string representation of this RDF term.
        Specified by:
        toString in interface RdfTerm
        Overrides:
        toString in class Literal
        Returns:
        a string describing this RDF term.