LiteralTerm class

Literal value in RDF

Literals represent values like strings, numbers, dates, etc. Each literal has a lexical value (string) and a datatype IRI that defines how to interpret the string. Additionally, string literals can have language tags.

Literals can only appear in the object position of a triple, never as subjects or predicates.

In RDF 1.1, all literals have a datatype:

  • Plain literals use xsd:string by default
  • Language-tagged literals use rdf:langString
  • Typed literals use an explicit datatype IRI (typically an XSD datatype)

Examples in Turtle syntax:

  • Simple string: "Hello World"
  • Typed number: "42"^^xsd:integer
  • Language-tagged string: "Hello"@en
Inheritance

Constructors

LiteralTerm(String value, {IriTerm? datatype, String? language})
Creates a literal with an optional datatype or language tag
const
LiteralTerm.boolean(bool value)
Create a boolean literal
factory
LiteralTerm.decimal(double value)
Create a decimal literal
factory
LiteralTerm.integer(int value)
Create an integer literal
factory
LiteralTerm.string(String value)
Create a plain string literal
factory
LiteralTerm.typed(String value, String xsdType)
Create a typed literal with XSD datatype
factory
LiteralTerm.withLanguage(String value, String langTag)
Create a language-tagged literal
factory

Properties

datatype IriTerm
The datatype IRI defining the literal's type
final
hashCode int
Provides a consistent hash code for this literal term based on its components.
no setteroverride
language String?
Optional language tag for language-tagged string literals
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value String
The lexical value of the literal as a string
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
Returns a string representation of this literal term in a Turtle-like syntax.
override

Operators

operator ==(Object other) bool
Compares this literal term with another object for equality.
override