Class AbstractRDFInserter

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map<java.lang.String,​BNode> bNodesMap
      Map used to keep track of which blank node IDs have been mapped to which BNode object in case preserveBNodeIDs is false.
      protected Resource[] contexts
      The contexts to add the statements to.
      private java.util.Map<java.lang.String,​java.lang.String> namespaceMap
      Map that stores namespaces that are reported during the evaluation of the query.
      private boolean preserveBNodeIDs
      Flag indicating whether blank node IDs should be preserved.
      private ValueFactory valueFactory
      ValueFactory used to create BNodes.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractRDFInserter​(ValueFactory vf)
      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

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract void addNamespace​(java.lang.String prefix, java.lang.String name)  
      protected abstract void addStatement​(Resource subj, IRI pred, Value obj, Resource ctxt)  
      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​(java.lang.String prefix, java.lang.String name)
      Handles a namespace declaration/definition.
      void handleStatement​(Statement st)
      Handles a statement.
      private BNode mapBNode​(BNode bNode)
      Maps the supplied BNode, which comes from the data, to a new BNode object.
      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 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • contexts

        protected Resource[] 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 preserveBNodeIDs
        Flag indicating whether blank node IDs should be preserved.
      • namespaceMap

        private final java.util.Map<java.lang.String,​java.lang.String> namespaceMap
        Map that stores namespaces that are reported during the evaluation of the query. Key is the namespace prefix, value is the namespace name.
      • bNodesMap

        private final java.util.Map<java.lang.String,​BNode> bNodesMap
        Map used to keep track of which blank node IDs have been mapped to which BNode object in case preserveBNodeIDs is false.
      • valueFactory

        private final ValueFactory valueFactory
        ValueFactory used to create BNodes.
    • Constructor Detail

      • AbstractRDFInserter

        protected AbstractRDFInserter​(ValueFactory vf)
        Creates a new RDFInserter object that preserves bnode IDs and that does not enforce any context upon statements that are reported to it.
    • 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 an empty array if no contexts is enforced.
      • addNamespace

        protected abstract void addNamespace​(java.lang.String prefix,
                                             java.lang.String name)
                                      throws RDF4JException
        Throws:
        RDF4JException
      • handleNamespace

        public void handleNamespace​(java.lang.String prefix,
                                    java.lang.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 AbstractRDFHandler
        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.
      • mapBNode

        private BNode mapBNode​(BNode bNode)
        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