Interface Literal
- All Superinterfaces:
RDFTerm
- All Known Subinterfaces:
JsonLdLiteral
,RDF4JLiteral
- All Known Implementing Classes:
JsonLdLiteralImpl
,LiteralImpl
,LiteralImpl
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Check it this Literal is equal to another Literal.The IRI identifying the datatype that determines how the lexical form maps to a literal value.If and only if the datatype IRI is http://www.w3.org/1999/02/22-rdf-syntax-ns#langString, the language tag for this Literal is a non-empty language tag as defined by BCP47.
If the datatype IRI is not http://www.w3.org/1999/02/22-rdf-syntax-ns#langString, this method must returnOptional.empty()
.The lexical form of this literal, represented by a Unicode string.int
hashCode()
Calculate a hash code for this Literal.Methods inherited from interface org.apache.commons.rdf.api.RDFTerm
ntriplesString
-
Method Details
-
getLexicalForm
String getLexicalForm()The lexical form of this literal, represented by a Unicode string.- Returns:
- The lexical form of this literal.
- See Also:
-
getDatatype
IRI getDatatype()The IRI identifying the datatype that determines how the lexical form maps to a literal value. If the datatype IRI is http://www.w3.org/1999/02/22-rdf-syntax-ns#langString,getLanguageTag()
must not returnOptional.empty()
, and it must return a valid BCP47 language tag.- Returns:
- The datatype IRI for this literal.
- See Also:
-
getLanguageTag
If and only if the datatype IRI is http://www.w3.org/1999/02/22-rdf-syntax-ns#langString, the language tag for this Literal is a non-empty language tag as defined by BCP47.
If the datatype IRI is not http://www.w3.org/1999/02/22-rdf-syntax-ns#langString, this method must returnOptional.empty()
.The value space of language tags is always in lower case; although RDF implementations MAY convert all language tags to lower case, safe comparisons of language tags should be done using
String.toLowerCase(Locale)
with the localeLocale.ROOT
.Implementation note: If your application requires
Serializable
objects, it is best not to store anOptional
in a field. It is recommended to useOptional.ofNullable(Object)
to create the return value for this method.- Returns:
- The
Optional
language tag for this literal. IfOptional.isPresent()
returns true, the value returned byOptional.get()
must be a non-empty language tag string conforming to BCP47. - See Also:
-
equals
Check it this Literal is equal to another Literal.Literal term equality: Two literals are term-equal (the same RDF literal) if and only if the two lexical forms, the two datatype IRIs, and the two language tags (if any) compare equal, character by character. Thus, two literals can have the same value without being the same RDF term.
As the value space for language tags is lower-space, if they are present, they MUST be compared character by character using the equivalent ofString.toLowerCase(java.util.Locale)
with the localeLocale.ROOT
.Implementations MUST also override
hashCode()
so that two equal Literals produce the same hash code. -
hashCode
int hashCode()Calculate a hash code for this Literal.The returned hash code MUST be equal to the result of
Objects.hash(Object...)
with the argumentsgetLexicalForm()
,getDatatype()
,getLanguageTag()
.map(s->s.toLowerString(Locale.ROOT))
.This method MUST be implemented in conjunction with
equals(Object)
so that two equal Literals produce the same hash code.
-