Interface RDFTerm
- All Known Subinterfaces:
BlankNode, BlankNodeOrIRI, IRI, JsonLdBlankNode, JsonLdIRI, JsonLdLiteral, JsonLdTerm, Literal, RDF4JBlankNode, RDF4JBlankNodeOrIRI, RDF4JIRI, RDF4JLiteral, RDF4JTerm, SimpleRDF.SimpleRDFTerm
- All Known Implementing Classes:
AbstractRDFTerm, BlankNodeImpl, BlankNodeImpl, IRIImpl, IRIImpl, JsonLdBlankNodeImpl, JsonLdIRIImpl, JsonLdLiteralImpl, JsonLdTermImpl, LiteralImpl, LiteralImpl, Types, W3CRDFSyntax.FormatIRI
A RDFTerm object in Commons RDF is considered
immutable, that is, over its life time it will have
consistent behaviour for its equals(Object) and hashCode(),
and objects returned from its getter methods (e.g. IRI.getIRIString()
and Literal.getLanguageTag()) will have consistent
equals(Object) behaviour.
Note that methods in RDFTerm and its Commons RDF specialisations
IRI, BlankNode and Literal are not required to return
object identical (==) instances as long as they are equivalent
according to their Object.equals(Object). Further specialisations may
provide additional methods that are documented to be mutable.
Methods in RDFTerm and its Commons RDF specialisations
IRI, BlankNode and Literal are
thread-safe, however further specialisations may add
additional methods that are documented to not be thread-safe.
RDFTerms can be safely used in hashing collections like
HashSet and HashMap.
Any RDFTerm can be used interchangeably across Commons RDF
implementations.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanCheck it this RDFTerm is equal to another RDFTerm.inthashCode()Calculate a hash code for this RDFTerm.Return the term serialised as specified by the RDF-1.1 N-Triples Canonical form.
-
Method Details
-
ntriplesString
String ntriplesString()Return the term serialised as specified by the RDF-1.1 N-Triples Canonical form.- Returns:
- The term serialised as RDF-1.1 N-Triples.
- See Also:
-
equals
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
hashCode()so that two equal Literals produce the same hash code. -
hashCode
int hashCode()Calculate a hash code for this RDFTerm.As an
RDFTermis immutable, this method will always return the same hashCode over the lifetime of this object.This method MUST be implemented in conjunction with
equals(Object)so that two equal RDFTerm produce the same hash code.
-