Class RDFWriterTripleHandler

  • All Implemented Interfaces:
    AutoCloseable, org.apache.any23.writer.FormatWriter, org.apache.any23.writer.TripleHandler, org.apache.any23.writer.TripleWriter
    Direct Known Subclasses:
    JSONLDWriter, NQuadsWriter, NTriplesWriter, RDFXMLWriter, TriXWriter, TurtleWriter

    public abstract class RDFWriterTripleHandler
    extends TripleWriterHandler
    implements org.apache.any23.writer.FormatWriter
    A TripleHandler that writes triples to a Sesame RDFWriter, eg for serialization using one of Sesame's writers.
    Author:
    Richard Cyganiak (richard@cyganiak.de), Michele Mostarda (mostarda@fbk.eu), Hans Brende (hansbrende@apache.org)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      void closeContext​(org.apache.any23.extractor.ExtractionContext context)
      Writers may override this method to handle a "closeContext" extraction event.
      void endDocument​(org.eclipse.rdf4j.model.IRI documentIRI)
      Writers may override this method to handle an "endDocument" extraction event.
      boolean isAnnotated()
      If true then the produced RDF is annotated with the extractors used to generate the specific statements.
      void openContext​(org.apache.any23.extractor.ExtractionContext context)
      Writers may override this method to handle an "openContext" extraction event.
      void setAnnotated​(boolean f)
      Sets the annotation flag.
      void startDocument​(org.eclipse.rdf4j.model.IRI documentIRI)
      Writers may override this method to handle a "startDocument" extraction event.
      void writeNamespace​(String prefix, String uri)  
      void writeTriple​(org.eclipse.rdf4j.model.Resource s, org.eclipse.rdf4j.model.IRI p, org.eclipse.rdf4j.model.Value o, org.eclipse.rdf4j.model.Resource g)  
      • Methods inherited from interface org.apache.any23.writer.TripleHandler

        receiveNamespace, receiveTriple, setContentLength
    • Method Detail

      • isAnnotated

        public boolean isAnnotated()
        If true then the produced RDF is annotated with the extractors used to generate the specific statements.
        Specified by:
        isAnnotated in interface org.apache.any23.writer.FormatWriter
        Returns:
        the annotation flag value.
      • setAnnotated

        public void setAnnotated​(boolean f)
        Sets the annotation flag.
        Specified by:
        setAnnotated in interface org.apache.any23.writer.FormatWriter
        Parameters:
        f - If true then the produced RDF is annotated with the extractors used to generate the specific statements.
      • startDocument

        public void startDocument​(org.eclipse.rdf4j.model.IRI documentIRI)
                           throws org.apache.any23.writer.TripleHandlerException
        Description copied from class: TripleWriterHandler
        Writers may override this method to handle a "startDocument" extraction event. The default implementation does nothing.
        Specified by:
        startDocument in interface org.apache.any23.writer.TripleHandler
        Overrides:
        startDocument in class TripleWriterHandler
        Parameters:
        documentIRI - the name of the document that was started
        Throws:
        org.apache.any23.writer.TripleHandlerException - if an error occurred while responding to a "startDocument" extraction event.
      • openContext

        public void openContext​(org.apache.any23.extractor.ExtractionContext context)
                         throws org.apache.any23.writer.TripleHandlerException
        Description copied from class: TripleWriterHandler
        Writers may override this method to handle an "openContext" extraction event. The default implementation does nothing.
        Specified by:
        openContext in interface org.apache.any23.writer.TripleHandler
        Overrides:
        openContext in class TripleWriterHandler
        Parameters:
        context - the context that was opened
        Throws:
        org.apache.any23.writer.TripleHandlerException - if an error occurred while responding to a "startDocument" extraction event.
      • writeTriple

        public void writeTriple​(org.eclipse.rdf4j.model.Resource s,
                                org.eclipse.rdf4j.model.IRI p,
                                org.eclipse.rdf4j.model.Value o,
                                org.eclipse.rdf4j.model.Resource g)
                         throws org.apache.any23.writer.TripleHandlerException
        Specified by:
        writeTriple in interface org.apache.any23.writer.TripleWriter
        Throws:
        org.apache.any23.writer.TripleHandlerException
      • writeNamespace

        public void writeNamespace​(String prefix,
                                   String uri)
                            throws org.apache.any23.writer.TripleHandlerException
        Specified by:
        writeNamespace in interface org.apache.any23.writer.TripleWriter
        Throws:
        org.apache.any23.writer.TripleHandlerException
      • closeContext

        public void closeContext​(org.apache.any23.extractor.ExtractionContext context)
                          throws org.apache.any23.writer.TripleHandlerException
        Description copied from class: TripleWriterHandler
        Writers may override this method to handle a "closeContext" extraction event. The default implementation does nothing.
        Specified by:
        closeContext in interface org.apache.any23.writer.TripleHandler
        Overrides:
        closeContext in class TripleWriterHandler
        Parameters:
        context - the context to be closed.
        Throws:
        org.apache.any23.writer.TripleHandlerException - if an error occurred while responding to a "closeContext" extraction event.
      • close

        public void close()
                   throws org.apache.any23.writer.TripleHandlerException
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface org.apache.any23.writer.TripleHandler
        Specified by:
        close in interface org.apache.any23.writer.TripleWriter
        Throws:
        org.apache.any23.writer.TripleHandlerException
      • endDocument

        public void endDocument​(org.eclipse.rdf4j.model.IRI documentIRI)
                         throws org.apache.any23.writer.TripleHandlerException
        Description copied from class: TripleWriterHandler
        Writers may override this method to handle an "endDocument" extraction event. The default implementation does nothing.
        Specified by:
        endDocument in interface org.apache.any23.writer.TripleHandler
        Overrides:
        endDocument in class TripleWriterHandler
        Parameters:
        documentIRI - the document IRI.
        Throws:
        org.apache.any23.writer.TripleHandlerException - if an error occurred while responding to a "endDocument" extraction event.