org.openrdf.repository.util
Class RDFInserter

java.lang.Object
  extended by org.openrdf.rio.helpers.RDFHandlerBase
      extended by org.openrdf.repository.util.RDFInserter
All Implemented Interfaces:
RDFHandler

public class RDFInserter
extends RDFHandlerBase

An RDFHandler that adds RDF data to a repository.

Author:
jeen

Constructor Summary
RDFInserter(RepositoryConnection con)
          Creates a new RDFInserter object that preserves bnode IDs and that does not enforce any context upon statements that are reported to it.
 
Method Summary
 void endRDF()
          Signals the end of the RDF data.
 void enforceContext(Resource... contexts)
          Enforces the supplied contexts upon all statements that are reported to this RDFInserter.
 boolean enforcesContext()
          Checks whether this RDFInserter enforces its contexts upon all statements that are reported to it.
 Resource[] getContexts()
          Gets the contexts that this RDFInserter enforces upon all statements that are reported to it (in case enforcesContext() returns true).
 void handleNamespace(String prefix, String name)
          Handles a namespace declaration/definition.
 void handleStatement(Statement st)
          Handles a statement.
 boolean preservesBNodeIDs()
          Checks whether this RDFInserter preserves blank node IDs.
 void setPreserveBNodeIDs(boolean preserveBNodeIDs)
          Sets whether this RDFInserter should preserve blank node IDs.
 
Methods inherited from class org.openrdf.rio.helpers.RDFHandlerBase
handleComment, startRDF
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RDFInserter

public RDFInserter(RepositoryConnection con)
Creates a new RDFInserter object that preserves bnode IDs and that does not enforce any context upon statements that are reported to it.

Parameters:
con - The connection to use for the add operations.
Method Detail

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

public void enforceContext(Resource... contexts)
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

public Resource[] 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 null if no contexts is enforced.

endRDF

public void endRDF()
            throws RDFHandlerException
Description copied from interface: RDFHandler
Signals the end of the RDF data. This method is called when all data has been reported.

Specified by:
endRDF in interface RDFHandler
Overrides:
endRDF in class RDFHandlerBase
Throws:
RDFHandlerException - If the RDF handler has encountered an unrecoverable error.

handleNamespace

public void handleNamespace(String prefix,
                            String name)
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 interface RDFHandler
Overrides:
handleNamespace in class RDFHandlerBase
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

public void handleStatement(Statement st)
                     throws RDFHandlerException
Description copied from interface: RDFHandler
Handles a statement.

Specified by:
handleStatement in interface RDFHandler
Overrides:
handleStatement in class RDFHandlerBase
Parameters:
st - The statement.
Throws:
RDFHandlerException - If the RDF handler has encountered an unrecoverable error.


Copyright © 2001-2008 Aduna. All Rights Reserved.