public interface RDF
A RDF
implementation can create instances of the RDFTerm
types IRI
, BlankNode
and Literal
, as well as creating
instances of the types Triple
, Quad
, Graph
or
Dataset
.
A partial RDF implementation should be clearly documented as such,
and may throw UnsupportedOperationException
where applicable, e.g. if
it does not support creating Dataset
s or Quad
s.
Instances of RDF
work like a factory for creating Commons RDF
instances. spezializations of this interface may also provide methods for
conversions from/to their underlying RDF framework.
If a factory method of a particular implementation does not allow or support
a provided parameter, e.g. because an IRI is considered invalid, then it
SHOULD throw IllegalArgumentException
.
Modifier and Type | Method and Description |
---|---|
BlankNode |
createBlankNode()
Create a new blank node.
|
BlankNode |
createBlankNode(String name)
Create a blank node based on the given name.
|
Dataset |
createDataset()
Create a new dataset.
|
Graph |
createGraph()
Create a new graph.
|
IRI |
createIRI(String iri)
Create an IRI from a (possibly escaped) String.
|
Literal |
createLiteral(String lexicalForm)
Create a simple literal.
|
Literal |
createLiteral(String lexicalForm,
IRI dataType)
Create a literal with the specified data type.
|
Literal |
createLiteral(String lexicalForm,
String languageTag)
Create a language-tagged literal.
|
Quad |
createQuad(BlankNodeOrIRI graphName,
BlankNodeOrIRI subject,
IRI predicate,
RDFTerm object)
Create a quad.
|
Triple |
createTriple(BlankNodeOrIRI subject,
IRI predicate,
RDFTerm object)
Create a triple.
|
BlankNode createBlankNode()
The returned blank node MUST NOT be equal to any existing
BlankNode
instances according to
BlankNode.equals(Object)
.
BlankNode
BlankNode createBlankNode(String name)
All BlankNode
s created with the given name
on a
particular instance of RDF
MUST be equivalent according
to BlankNode.equals(Object)
,
The returned BlankNode MUST NOT be equal to BlankNode
instances returned for any other name
or those returned from
createBlankNode()
.
The returned BlankNode SHOULD NOT be equivalent to any BlankNodes created
on a different RDF
instance, e.g. different
instances of RDF
should produce different blank nodes for
the same name
unless they purposely are intending to create
equivalent BlankNode
instances (e.g. a reinstated
Serializable
factory).
name
- A non-empty, non-null, String that is unique to this blank
node in the context of this RDF
.Graph createGraph()
Dataset createDataset()
IRI createIRI(String iri) throws IllegalArgumentException
iri
- Internationalized Resource IdentifierIllegalArgumentException
- If the provided string is not acceptable, e.g. does not
conform to the RFC3987 syntax.Literal createLiteral(String lexicalForm) throws IllegalArgumentException
Literal.getLexicalForm()
that is
equal to the provided lexical form, MUST NOT have a
Literal.getLanguageTag()
present, and SHOULD return a
Literal.getDatatype()
that is equal to the IRI
http://www.w3.org/2001/XMLSchema#string
.lexicalForm
- The literal value in plain textIllegalArgumentException
- If the provided lexicalForm is not acceptable, e.g. because
it is too large for an underlying storage.Literal createLiteral(String lexicalForm, IRI dataType) throws IllegalArgumentException
Literal.getLexicalForm()
that
is equal to the provided lexicalForm, MUST NOT have a
Literal.getLanguageTag()
present, and MUST return a
Literal.getDatatype()
that is equivalent to the provided dataType
IRI.lexicalForm
- The literal valuedataType
- The data type IRI for the literal value, e.g.
http://www.w3.org/2001/XMLSchema#integer
IllegalArgumentException
- If any of the provided arguments are not acceptable, e.g.
because the provided dataType is not permitted.Literal createLiteral(String lexicalForm, String languageTag) throws IllegalArgumentException
en
.
The provided language tag
MAY be converted to lower case.
The returned Literal SHOULD have a Literal.getLexicalForm()
which
is equal to the provided lexicalForm, MUST return a
Literal.getDatatype()
that is equal to the IRI
http://www.w3.org/1999/02/22-rdf-syntax-ns#langString
, and
MUST have a Literal.getLanguageTag()
present which SHOULD be
equal to the provided language tag (compared as
String.toLowerCase(Locale)
using Locale.ENGLISH
).lexicalForm
- The literal valuelanguageTag
- The non-empty language tag as defined by
BCP47IllegalArgumentException
- If the provided values are not acceptable, e.g. because the
languageTag was syntactically invalid.Triple createTriple(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) throws IllegalArgumentException
Triple.getSubject()
that is
equal to the provided subject, a Triple.getPredicate()
that is
equal to the provided predicate, and a Triple.getObject()
that is
equal to the provided object.subject
- The IRI or BlankNode that is the subject of the triplepredicate
- The IRI that is the predicate of the tripleobject
- The IRI, BlankNode or Literal that is the object of the tripleIllegalArgumentException
- If any of the provided arguments are not acceptable, e.g.
because a Literal has a lexicalForm that is too large for an
underlying storage.Quad createQuad(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) throws IllegalArgumentException
The returned Quad SHOULD have a Quad.getGraphName()
that is equal
to the provided graphName, a Quad.getSubject()
that is equal to
the provided subject, a Quad.getPredicate()
that is equal to the
provided predicate, and a Quad.getObject()
that is equal to the
provided object.
graphName
- The IRI or BlankNode that this quad belongs to, or
null
for the public graphsubject
- The IRI or BlankNode that is the subject of the quadpredicate
- The IRI that is the predicate of the quadobject
- The IRI, BlankNode or Literal that is the object of the quadIllegalArgumentException
- If any of the provided arguments are not acceptable, e.g.
because a Literal has a lexicalForm that is too large for an
underlying storage.Copyright © 2015–2018 The Apache Software Foundation. All rights reserved.