Class AbstractRDFInserter
java.lang.Object
org.eclipse.rdf4j.rio.helpers.AbstractRDFHandler
org.eclipse.rdf4j.repository.util.AbstractRDFInserter
- All Implemented Interfaces:
RDFHandler
- Direct Known Subclasses:
RDFInferencerInserter, RDFInserter, RDFSailInserter
An RDFHandler that adds RDF data to some RDF sink.
-
Field Summary
FieldsModifier and TypeFieldDescriptionMap used to keep track of which blank node IDs have been mapped to which BNode object in case preserveBNodeIDs is false.protected Resource[]The contexts to add the statements to.Map that stores namespaces that are reported during the evaluation of the query.private booleanFlag indicating whether blank node IDs should be preserved.private final ValueFactoryValueFactory used to create BNodes. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new RDFInserter object that preserves bnode IDs and that does not enforce any context upon statements that are reported to it. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidaddNamespace(String prefix, String name) protected abstract voidaddStatement(Resource subj, IRI pred, Value obj, Resource ctxt) voidendRDF()Signals the end of the RDF data.voidenforceContext(Resource... contexts) Enforces the supplied contexts upon all statements that are reported to this RDFInserter.booleanChecks whether this RDFInserter enforces its contexts upon all statements that are reported to it.Resource[]Gets the contexts that this RDFInserter enforces upon all statements that are reported to it (in case enforcesContext() returns true).voidhandleNamespace(String prefix, String name) Handles a namespace declaration/definition.voidHandles a statement.private BNodeMaps the supplied BNode, which comes from the data, to a new BNode object.booleanChecks whether this RDFInserter preserves blank node IDs.voidsetPreserveBNodeIDs(boolean preserveBNodeIDs) Sets whether this RDFInserter should preserve blank node IDs.Methods inherited from class AbstractRDFHandler
handleComment, startRDF
-
Field Details
-
contexts
The contexts to add the statements to. If this variable is a non-empty array, statements will be added to the corresponding contexts. -
preserveBNodeIDs
private boolean preserveBNodeIDsFlag indicating whether blank node IDs should be preserved. -
namespaceMap
-
bNodesMap
-
valueFactory
ValueFactory used to create BNodes.
-
-
Constructor Details
-
AbstractRDFInserter
Creates a new RDFInserter object that preserves bnode IDs and that does not enforce any context upon statements that are reported to it.
-
-
Method Details
-
setPreserveBNodeIDs
public void setPreserveBNodeIDs(boolean preserveBNodeIDs) Sets whether this RDFInserter should preserve blank node IDs.- Parameters:
preserveBNodeIDs- The new value for this flag.
-
preservesBNodeIDs
public boolean preservesBNodeIDs()Checks whether this RDFInserter preserves blank node IDs. -
enforceContext
Enforces the supplied contexts upon all statements that are reported to this RDFInserter.- Parameters:
contexts- the contexts to use. Use an empty array (not null!) to indicate no context(s) should be enforced.
-
enforcesContext
public boolean enforcesContext()Checks whether this RDFInserter enforces its contexts upon all statements that are reported to it.- Returns:
- true if it enforces its contexts, false otherwise.
-
getContexts
Gets the contexts that this RDFInserter enforces upon all statements that are reported to it (in case enforcesContext() returns true).- Returns:
- A Resource[] identifying the contexts, or an empty array if no contexts is enforced.
-
addNamespace
- Throws:
RDF4JException
-
addStatement
protected abstract void addStatement(Resource subj, IRI pred, Value obj, Resource ctxt) throws RDF4JException - Throws:
RDF4JException
-
endRDF
Description copied from interface:RDFHandlerSignals the end of the RDF data. This method is called when all data has been reported.- Specified by:
endRDFin interfaceRDFHandler- Overrides:
endRDFin classAbstractRDFHandler- Throws:
RDFHandlerException- If the RDF handler has encountered an unrecoverable error.
-
handleNamespace
Description copied from interface:RDFHandlerHandles a namespace declaration/definition. A namespace declaration associates a (short) prefix string with the namespace's URI. The prefix for default namespaces, which do not have an associated prefix, are represented as empty strings.- Specified by:
handleNamespacein interfaceRDFHandler- Overrides:
handleNamespacein classAbstractRDFHandler- Parameters:
prefix- The prefix for the namespace, or an empty string in case of a default namespace.name- The URI that the prefix maps to.
-
handleStatement
Description copied from interface:RDFHandlerHandles a statement.- Specified by:
handleStatementin interfaceRDFHandler- Overrides:
handleStatementin classAbstractRDFHandler- Parameters:
st- The statement.- Throws:
RDFHandlerException- If the RDF handler has encountered an unrecoverable error.
-
mapBNode
Maps the supplied BNode, which comes from the data, to a new BNode object. Consecutive calls with equal BNode objects returns the same object everytime.- Throws:
RepositoryException
-