Class JsonLdRDF
- java.lang.Object
-
- org.apache.commons.rdf.jsonldjava.JsonLdRDF
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.lang.StringbnodePrefix
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonLdDatasetasDataset(com.github.jsonldjava.core.RDFDataset rdfDataSet)Adapt a JsonLdRDFDatasetas a Commons RDFDataset.JsonLdGraphasGraph(com.github.jsonldjava.core.RDFDataset rdfDataSet)Adapt a JsonLdRDFDatasetas a Commons RDFGraph.com.github.jsonldjava.core.RDFDataset.NodeasJsonLdNode(RDFTerm term)com.github.jsonldjava.core.RDFDataset.QuadasJsonLdQuad(Quad quad)Adapt a Commons RDFQuadas a JsonLdRDFDataset.Quad.com.github.jsonldjava.core.RDFDataset.QuadasJsonLdQuad(Triple triple)Adapt a Commons RDFTripleas a JsonLdRDFDataset.Quad.(package private) java.lang.StringasJsonLdString(BlankNodeOrIRI blankNodeOrIRI)JsonLdQuadasQuad(com.github.jsonldjava.core.RDFDataset.Quad quad)Adapt a JsonLdRDFDataset.Quadas a Commons RDFQuad.JsonLdTermasRDFTerm(com.github.jsonldjava.core.RDFDataset.Node node)Adapt a JsonLdRDFDataset.Nodeas a Commons RDFRDFTerm.(package private) JsonLdTermasRDFTerm(com.github.jsonldjava.core.RDFDataset.Node node, java.lang.String blankNodePrefix)JsonLdTripleasTriple(com.github.jsonldjava.core.RDFDataset.Quad quad)Adapt a JsonLdRDFDataset.Quadas a Commons RDFTriple.JsonLdUnionGraphasUnionGraph(com.github.jsonldjava.core.RDFDataset rdfDataSet)Adapt a JsonLdRDFDatasetas a Commons RDFGraph.JsonLdBlankNodecreateBlankNode()Create a new blank node.JsonLdBlankNodecreateBlankNode(java.lang.String name)Create a blank node based on the given name.JsonLdDatasetcreateDataset()Create a new dataset.JsonLdGraphcreateGraph()Create a new graph.JsonLdIRIcreateIRI(java.lang.String iri)Create an IRI from a (possibly escaped) String.(package private) com.github.jsonldjava.core.RDFDataset.QuadcreateJsonLdQuad(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object)JsonLdLiteralcreateLiteral(java.lang.String literal)Create a simple literal.JsonLdLiteralcreateLiteral(java.lang.String literal, java.lang.String language)Create a language-tagged literal.JsonLdLiteralcreateLiteral(java.lang.String literal, IRI dataType)Create a literal with the specified data type.JsonLdQuadcreateQuad(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object)Create a quad.JsonLdTriplecreateTriple(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)Create a triple.
-
-
-
Method Detail
-
asDataset
public JsonLdDataset asDataset(com.github.jsonldjava.core.RDFDataset rdfDataSet)
Adapt a JsonLdRDFDatasetas a Commons RDFDataset.Changes to the Commons RDF
Datasetare reflected in the JsonLdRDFDatasetand vice versa.- Parameters:
rdfDataSet- JsonLdRDFDatasetto adapt- Returns:
- Adapted
Dataset - See Also:
asGraph(RDFDataset)
-
asGraph
public JsonLdGraph asGraph(com.github.jsonldjava.core.RDFDataset rdfDataSet)
Adapt a JsonLdRDFDatasetas a Commons RDFGraph.Only triples in the default graph are included. To retrieve any other graph,
asDataset(RDFDataset)together withDataset.getGraph(BlankNodeOrIRI).Changes to the Commons RDF
Graphare reflected in the JsonLdRDFDatasetand vice versa.- Parameters:
rdfDataSet- JsonLdRDFDatasetto adapt- Returns:
- Adapted
Graphcovering the default graph - See Also:
asDataset(RDFDataset),asUnionGraph(RDFDataset)
-
asJsonLdNode
public com.github.jsonldjava.core.RDFDataset.Node asJsonLdNode(RDFTerm term)
-
asJsonLdQuad
public com.github.jsonldjava.core.RDFDataset.Quad asJsonLdQuad(Quad quad)
Adapt a Commons RDFQuadas a JsonLdRDFDataset.Quad.- Parameters:
quad- Commons RDFQuadto adapt- Returns:
- Adapted JsonLd
RDFDataset.Quad
-
asJsonLdQuad
public com.github.jsonldjava.core.RDFDataset.Quad asJsonLdQuad(Triple triple)
Adapt a Commons RDFTripleas a JsonLdRDFDataset.Quad.- Parameters:
triple- Commons RDFTripleto adapt- Returns:
- Adapted JsonLd
RDFDataset.Quad
-
asQuad
public JsonLdQuad asQuad(com.github.jsonldjava.core.RDFDataset.Quad quad)
Adapt a JsonLdRDFDataset.Quadas a Commons RDFQuad.The underlying JsonLd quad can be retrieved with
JsonLdTripleLike.asJsonLdQuad().- Parameters:
quad- A JsonLdRDFDataset.Quadto adapt- Returns:
- Adapted
JsonLdQuad
-
asRDFTerm
public JsonLdTerm asRDFTerm(com.github.jsonldjava.core.RDFDataset.Node node)
Adapt a JsonLdRDFDataset.Nodeas a Commons RDFRDFTerm.The underlying node can be retrieved with
JsonLdTerm.asJsonLdNode().- Parameters:
node- A JsonLdRDFDataset.Nodeto adapt- Returns:
- Adapted
JsonLdTerm
-
asTriple
public JsonLdTriple asTriple(com.github.jsonldjava.core.RDFDataset.Quad quad)
Adapt a JsonLdRDFDataset.Quadas a Commons RDFTriple.The underlying JsonLd quad can be retrieved with
JsonLdTripleLike.asJsonLdQuad().- Parameters:
quad- A JsonLdRDFDataset.Quadto adapt- Returns:
- Adapted
JsonLdTriple
-
asUnionGraph
public JsonLdUnionGraph asUnionGraph(com.github.jsonldjava.core.RDFDataset rdfDataSet)
Adapt a JsonLdRDFDatasetas a Commons RDFGraph.The graph can be seen as a union graph as it will contains all the triples across all the graphs of the underlying
RDFDataset.Note that some triple operations on a union graph can be inefficient as they need to remove any duplicate triples across the graphs.
Changes to the Commons RDF
Graphare reflected in the JsonLdRDFDatasetand vice versa. Triples removed from the graph are removed from all graphs, while triples added are added to the default graph.- Parameters:
rdfDataSet- JsonLdRDFDatasetto adapt- Returns:
- Adapted
Dataset
-
createBlankNode
public JsonLdBlankNode createBlankNode()
Description copied from interface:RDFCreate a new blank node.The returned blank node MUST NOT be equal to any existing
BlankNodeinstances according toBlankNode.equals(Object).- Specified by:
createBlankNodein interfaceRDF- Returns:
- A new, unique
BlankNode
-
createBlankNode
public JsonLdBlankNode createBlankNode(java.lang.String name)
Description copied from interface:RDFCreate a blank node based on the given name.All
BlankNodes created with the givennameon a particular instance ofRDFMUST be equivalent according toBlankNode.equals(Object),The returned BlankNode MUST NOT be equal to
BlankNodeinstances returned for any othernameor those returned fromRDF.createBlankNode().The returned BlankNode SHOULD NOT be equivalent to any BlankNodes created on a different
RDFinstance, e.g. different instances ofRDFshould produce different blank nodes for the samenameunless they purposely are intending to create equivalentBlankNodeinstances (e.g. a reinstatedSerializablefactory).- Specified by:
createBlankNodein interfaceRDF- Parameters:
name- A non-empty, non-null, String that is unique to this blank node in the context of thisRDF.- Returns:
- A BlankNode for the given name
-
createDataset
public JsonLdDataset createDataset()
Description copied from interface:RDFCreate a new dataset. It is undefined if the dataset will be persisted by any underlying storage mechanism.- Specified by:
createDatasetin interfaceRDF- Returns:
- A new Dataset
-
createGraph
public JsonLdGraph createGraph()
Description copied from interface:RDFCreate a new graph. It is undefined if the graph will be persisted by any underlying storage mechanism.- Specified by:
createGraphin interfaceRDF- Returns:
- A new Graph
-
createIRI
public JsonLdIRI createIRI(java.lang.String iri)
Description copied from interface:RDFCreate an IRI from a (possibly escaped) String. The provided iri string MUST be valid according to the W3C RDF-1.1 IRI definition.
-
createLiteral
public JsonLdLiteral createLiteral(java.lang.String literal)
Description copied from interface:RDFCreate a simple literal. The provided lexical form should not be escaped in any sense, e.g. should not include "quotes" unless those are part of the literal value. The returned Literal MUST have aLiteral.getLexicalForm()that is equal to the provided lexical form, MUST NOT have aLiteral.getLanguageTag()present, and SHOULD return aLiteral.getDatatype()that is equal to the IRIhttp://www.w3.org/2001/XMLSchema#string.- Specified by:
createLiteralin interfaceRDF- Parameters:
literal- The literal value in plain text- Returns:
- The created Literal
-
createLiteral
public JsonLdLiteral createLiteral(java.lang.String literal, IRI dataType)
Description copied from interface:RDFCreate a literal with the specified data type. The provided lexical form should not be escaped in any sense, e.g. should not include "quotes" unless those are part of the literal value. It is RECOMMENDED that the provided dataType is one of the RDF-compatible XSD types. The provided lexical form SHOULD be in the lexical space of the provided dataType. The returned Literal SHOULD have aLiteral.getLexicalForm()that is equal to the provided lexicalForm, MUST NOT have aLiteral.getLanguageTag()present, and MUST return aLiteral.getDatatype()that is equivalent to the provided dataType IRI.- Specified by:
createLiteralin interfaceRDF- Parameters:
literal- The literal valuedataType- The data type IRI for the literal value, e.g.http://www.w3.org/2001/XMLSchema#integer- Returns:
- The created Literal
-
createLiteral
public JsonLdLiteral createLiteral(java.lang.String literal, java.lang.String language)
Description copied from interface:RDFCreate a language-tagged literal. The provided lexical form should not be escaped in any sense, e.g. should not include "quotes" unless those are part of the literal value. The provided language tag MUST be valid according to BCP47, e.g.en. The provided language tag MAY be converted to lower case. The returned Literal SHOULD have aLiteral.getLexicalForm()which is equal to the provided lexicalForm, MUST return aLiteral.getDatatype()that is equal to the IRIhttp://www.w3.org/1999/02/22-rdf-syntax-ns#langString, and MUST have aLiteral.getLanguageTag()present which SHOULD be equal to the provided language tag (compared asString.toLowerCase(Locale)usingLocale.ENGLISH).- Specified by:
createLiteralin interfaceRDF- Parameters:
literal- The literal valuelanguage- The non-empty language tag as defined by BCP47- Returns:
- The created Literal
-
createQuad
public JsonLdQuad createQuad(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object) throws java.lang.IllegalArgumentException, java.lang.UnsupportedOperationException
Description copied from interface:RDFCreate a quad.The returned Quad SHOULD have a
Quad.getGraphName()that is equal to the provided graphName, aQuad.getSubject()that is equal to the provided subject, aQuad.getPredicate()that is equal to the provided predicate, and aQuad.getObject()that is equal to the provided object.- Specified by:
createQuadin interfaceRDF- Parameters:
graphName- The IRI or BlankNode that this quad belongs to, ornullfor 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 quad- Returns:
- The created Quad
- Throws:
java.lang.IllegalArgumentException- 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.java.lang.UnsupportedOperationException
-
createTriple
public JsonLdTriple createTriple(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
Description copied from interface:RDFCreate a triple. The returned Triple SHOULD have aTriple.getSubject()that is equal to the provided subject, aTriple.getPredicate()that is equal to the provided predicate, and aTriple.getObject()that is equal to the provided object.- Specified by:
createTriplein interfaceRDF- Parameters:
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 triple- Returns:
- The created Triple
-
asJsonLdString
java.lang.String asJsonLdString(BlankNodeOrIRI blankNodeOrIRI)
-
asRDFTerm
JsonLdTerm asRDFTerm(com.github.jsonldjava.core.RDFDataset.Node node, java.lang.String blankNodePrefix)
-
createJsonLdQuad
com.github.jsonldjava.core.RDFDataset.Quad createJsonLdQuad(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
-
-