Class LiteralImpl
- java.lang.Object
-
- org.apache.commons.rdf.rdf4j.impl.AbstractRDFTerm<org.eclipse.rdf4j.model.Literal>
-
- org.apache.commons.rdf.rdf4j.impl.LiteralImpl
-
- All Implemented Interfaces:
Literal
,RDFTerm
,RDF4JLiteral
,RDF4JTerm
final class LiteralImpl extends AbstractRDFTerm<org.eclipse.rdf4j.model.Literal> implements RDF4JLiteral
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
QUOTE
-
Fields inherited from class org.apache.commons.rdf.rdf4j.impl.AbstractRDFTerm
value
-
-
Constructor Summary
Constructors Constructor Description LiteralImpl(org.eclipse.rdf4j.model.Literal literal)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Check it this RDFTerm is equal to another RDFTerm.IRI
getDatatype()
The IRI identifying the datatype that determines how the lexical form maps to a literal value.java.util.Optional<java.lang.String>
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()
.java.lang.String
getLexicalForm()
The lexical form of this literal, represented by a Unicode string.int
hashCode()
Calculate a hash code for this RDFTerm.private static java.lang.String
lowerCase(java.lang.String langTag)
java.lang.String
ntriplesString()
Return the term serialised as specified by the RDF-1.1 N-Triples Canonical form.java.lang.String
toString()
-
Methods inherited from class org.apache.commons.rdf.rdf4j.impl.AbstractRDFTerm
asValue
-
-
-
-
Field Detail
-
QUOTE
private static final java.lang.String QUOTE
- See Also:
- Constant Field Values
-
-
Method Detail
-
lowerCase
private static java.lang.String lowerCase(java.lang.String langTag)
-
equals
public boolean equals(java.lang.Object obj)
Description copied from interface:RDFTerm
Check it this RDFTerm is equal to another RDFTerm.If this object is an
IRI
, equality is checked usingIRI.equals(Object)
, or if this object is aBlankNode
, equality is checked usingBlankNode.equals(Object)
, or if this object is aLiteral
, equality is checked usingLiteral.equals(Object)
.Implementations MUST also override
RDFTerm.hashCode()
so that two equal Literals produce the same hash code.- Specified by:
equals
in interfaceLiteral
- Specified by:
equals
in interfaceRDFTerm
- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- Another object- Returns:
- true if other is a RDFTerm and is equal to this
- See Also:
IRI.equals(Object)
,BlankNode.equals(Object)
,Literal.equals(Object)
-
getDatatype
public IRI getDatatype()
Description copied from interface:Literal
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,Literal.getLanguageTag()
must not returnOptional.empty()
, and it must return a valid BCP47 language tag.- Specified by:
getDatatype
in interfaceLiteral
- Returns:
- The datatype IRI for this literal.
- See Also:
- RDF-1.1 Literal datatype IRI
-
getLanguageTag
public java.util.Optional<java.lang.String> getLanguageTag()
Description copied from interface:Literal
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.- Specified by:
getLanguageTag
in interfaceLiteral
- 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:
- RDF-1.1 Literal language tag
-
getLexicalForm
public java.lang.String getLexicalForm()
Description copied from interface:Literal
The lexical form of this literal, represented by a Unicode string.- Specified by:
getLexicalForm
in interfaceLiteral
- Returns:
- The lexical form of this literal.
- See Also:
- RDF-1.1 Literal lexical form
-
hashCode
public int hashCode()
Description copied from interface:RDFTerm
Calculate a hash code for this RDFTerm.As an
RDFTerm
is immutable, this method will always return the same hashCode over the lifetime of this object.This method MUST be implemented in conjunction with
RDFTerm.equals(Object)
so that two equal RDFTerm produce the same hash code.- Specified by:
hashCode
in interfaceLiteral
- Specified by:
hashCode
in interfaceRDFTerm
- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- a hash code value for this RDFTerm.
- See Also:
IRI.hashCode()
,Literal.hashCode()
,BlankNode.hashCode()
-
ntriplesString
public java.lang.String ntriplesString()
Description copied from interface:RDFTerm
Return the term serialised as specified by the RDF-1.1 N-Triples Canonical form.- Specified by:
ntriplesString
in interfaceRDFTerm
- Returns:
- The term serialised as RDF-1.1 N-Triples.
- See Also:
- RDF-1.1 N-Triples Canonical form
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-