Package org.apache.any23.writer

## Class TripleWriterHandler

- java.lang.Object
- - org.apache.any23.writer.TripleWriterHandler

- All Implemented Interfaces:
    `AutoCloseable`, `org.apache.any23.writer.TripleHandler`, `org.apache.any23.writer.TripleWriter`
  Direct Known Subclasses:
    `JSONWriter`, `RDFWriterTripleHandler`, `URIListWriter`

      public abstract class TripleWriterHandler
      extends Object
      implements org.apache.any23.writer.TripleHandler, org.apache.any23.writer.TripleWriter

  This class connects a `TripleHandler` to a `TripleWriter` by writing received data.
  Author:
    Hans Brende (hansbrende@apache.org)

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `TripleWriterHandler()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `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.
    `void` | `openContext​(org.apache.any23.extractor.ExtractionContext context)` | Writers may override this method to handle an "openContext" extraction event.
    `void` | `receiveNamespace​(String prefix, String uri, org.apache.any23.extractor.ExtractionContext context)` | Writers may override this method to handle a "receiveNamespace" extraction event.
    `void` | `receiveTriple​(org.eclipse.rdf4j.model.Resource s, org.eclipse.rdf4j.model.IRI p, org.eclipse.rdf4j.model.Value o, org.eclipse.rdf4j.model.IRI g, org.apache.any23.extractor.ExtractionContext context)` | Writers may override this method to handle a "receiveTriple" extraction event.
    `void` | `setContentLength​(long contentLength)` | Writers may override this method to handle a "setContentLength" extraction event.
    `void` | `startDocument​(org.eclipse.rdf4j.model.IRI documentIRI)` | Writers may override this method to handle a "startDocument" extraction event.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.any23.writer.TripleHandler

      `close`

    - ### Methods inherited from interface org.apache.any23.writer.TripleWriter

      `close, writeNamespace, writeTriple`

- - ### Constructor Detail

    - #### TripleWriterHandler

          public TripleWriterHandler()

  - ### Method Detail

    - #### receiveTriple

          public void receiveTriple​(org.eclipse.rdf4j.model.Resource s,
                                    org.eclipse.rdf4j.model.IRI p,
                                    org.eclipse.rdf4j.model.Value o,
                                    org.eclipse.rdf4j.model.IRI g,
                                    org.apache.any23.extractor.ExtractionContext context)
                             throws org.apache.any23.writer.TripleHandlerException

      Writers may override this method to handle a "receiveTriple" extraction event. The default implementation calls:

               this.writeTriple(s, p, o, context == null || g != null ? g : context.getDocumentIRI())

      Specified by:
        `receiveTriple` in interface `org.apache.any23.writer.TripleHandler`
      Parameters:
        `s` - the subject received
        `p` - the predicate received
        `o` - the object received
        `g` - the graph name received, or null
        `context` - the extraction context
      Throws:
        `org.apache.any23.writer.TripleHandlerException` - if there was an error responding to a received triple

    - #### receiveNamespace

          public void receiveNamespace​(String prefix,
                                       String uri,
                                       org.apache.any23.extractor.ExtractionContext context)
                                throws org.apache.any23.writer.TripleHandlerException

      Writers may override this method to handle a "receiveNamespace" extraction event. The default implementation calls:

               this.writeNamespace(prefix, uri)

      Specified by:
        `receiveNamespace` in interface `org.apache.any23.writer.TripleHandler`
      Parameters:
        `prefix` - namespace prefix.
        `uri` - namespace IRI.
        `context` - the extraction context
      Throws:
        `org.apache.any23.writer.TripleHandlerException` - if there was an error responding to the received namepsace.

    - #### startDocument

          public void startDocument​(org.eclipse.rdf4j.model.IRI documentIRI)
                             throws org.apache.any23.writer.TripleHandlerException

      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`
      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

      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`
      Parameters:
        `context` - the context that was opened
      Throws:
        `org.apache.any23.writer.TripleHandlerException` - if an error occurred while responding to a "startDocument" extraction event.

    - #### closeContext

          public void closeContext​(org.apache.any23.extractor.ExtractionContext context)
                            throws org.apache.any23.writer.TripleHandlerException

      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`
      Parameters:
        `context` - the context to be closed.
      Throws:
        `org.apache.any23.writer.TripleHandlerException` - if an error occurred while responding to a "closeContext" extraction event.

    - #### endDocument

          public void endDocument​(org.eclipse.rdf4j.model.IRI documentIRI)
                           throws org.apache.any23.writer.TripleHandlerException

      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`
      Parameters:
        `documentIRI` - the document IRI.
      Throws:
        `org.apache.any23.writer.TripleHandlerException` - if an error occurred while responding to a "endDocument" extraction event.

    - #### setContentLength

          public void setContentLength​(long contentLength)

      Writers may override this method to handle a "setContentLength" extraction event. The default implementation does nothing.
      Specified by:
        `setContentLength` in interface `org.apache.any23.writer.TripleHandler`
      Parameters:
        `contentLength` - length of the content being processed.