Package org.eclipse.rdf4j.rio.helpers
Class ContextStatementCollector
- java.lang.Object
-
- org.eclipse.rdf4j.rio.helpers.AbstractRDFHandler
-
- org.eclipse.rdf4j.rio.helpers.ContextStatementCollector
-
- All Implemented Interfaces:
RDFHandler
- Direct Known Subclasses:
StatementCollector
public class ContextStatementCollector extends AbstractRDFHandler
A RDFHandler that can be used to collect reported statements in collections.
-
-
Field Summary
Fields Modifier and Type Field Description private Resource[]
contexts
private java.util.Map<java.lang.String,java.lang.String>
namespaces
private java.util.Collection<Statement>
statements
private ValueFactory
vf
-
Constructor Summary
Constructors Constructor Description ContextStatementCollector(java.util.Collection<Statement> statements, java.util.Map<java.lang.String,java.lang.String> namespaces, ValueFactory vf, Resource... contexts)
Creates a new StatementCollector that stores reported statements and namespaces in the supplied containers.ContextStatementCollector(java.util.Collection<Statement> statements, ValueFactory vf, Resource... contexts)
Creates a new StatementCollector that stores reported statements in the supplied collection and that uses a new LinkedHashMap to store the reported namespaces.ContextStatementCollector(ValueFactory vf, Resource... contexts)
Creates a new StatementCollector that uses a new ArrayList to store the reported statements and a new LinkedHashMap to store the reported namespaces.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear the set of collected statements.java.util.Map<java.lang.String,java.lang.String>
getNamespaces()
Gets the map that contains the collected namespaces.java.util.Collection<Statement>
getStatements()
Gets the collection that contains the collected statements.void
handleNamespace(java.lang.String prefix, java.lang.String uri)
Handles a namespace declaration/definition.void
handleStatement(Statement st)
Handles a statement.-
Methods inherited from class org.eclipse.rdf4j.rio.helpers.AbstractRDFHandler
endRDF, handleComment, startRDF
-
-
-
-
Field Detail
-
statements
private final java.util.Collection<Statement> statements
-
namespaces
private final java.util.Map<java.lang.String,java.lang.String> namespaces
-
contexts
private final Resource[] contexts
-
vf
private final ValueFactory vf
-
-
Constructor Detail
-
ContextStatementCollector
public ContextStatementCollector(ValueFactory vf, Resource... contexts)
Creates a new StatementCollector that uses a new ArrayList to store the reported statements and a new LinkedHashMap to store the reported namespaces.
-
ContextStatementCollector
public ContextStatementCollector(java.util.Collection<Statement> statements, ValueFactory vf, Resource... contexts)
Creates a new StatementCollector that stores reported statements in the supplied collection and that uses a new LinkedHashMap to store the reported namespaces.
-
ContextStatementCollector
public ContextStatementCollector(java.util.Collection<Statement> statements, java.util.Map<java.lang.String,java.lang.String> namespaces, ValueFactory vf, Resource... contexts)
Creates a new StatementCollector that stores reported statements and namespaces in the supplied containers.
-
-
Method Detail
-
clear
public void clear()
Clear the set of collected statements.
-
getStatements
public java.util.Collection<Statement> getStatements()
Gets the collection that contains the collected statements.
-
getNamespaces
public java.util.Map<java.lang.String,java.lang.String> getNamespaces()
Gets the map that contains the collected namespaces.
-
handleNamespace
public void handleNamespace(java.lang.String prefix, java.lang.String uri) throws RDFHandlerException
Description copied from interface:RDFHandler
Handles 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:
handleNamespace
in interfaceRDFHandler
- Overrides:
handleNamespace
in classAbstractRDFHandler
- Parameters:
prefix
- The prefix for the namespace, or an empty string in case of a default namespace.uri
- The URI that the prefix maps to.- Throws:
RDFHandlerException
- If the RDF handler has encountered an unrecoverable error.
-
handleStatement
public void handleStatement(Statement st)
Description copied from interface:RDFHandler
Handles a statement.- Specified by:
handleStatement
in interfaceRDFHandler
- Overrides:
handleStatement
in classAbstractRDFHandler
- Parameters:
st
- The statement.
-
-