Package org.apache.any23.writer

## Class LoggingTripleHandler

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

- All Implemented Interfaces:
    `AutoCloseable`, `TripleHandler`

      public class LoggingTripleHandler
      extends Object
      implements TripleHandler

  Triple handler decorator useful for logging purposes.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `LoggingTripleHandler​(TripleHandler tripleHandler, PrintWriter destination)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `close()` | Will be called last and exactly once.
    `void` | `closeContext​(ExtractionContext context)` | Informs the handler that no more triples will come from a previously opened context.
    `void` | `endDocument​(org.eclipse.rdf4j.model.IRI documentIRI)` | Informs the handler that the end of the document has been reached.
    `void` | `openContext​(ExtractionContext context)` | Informs the handler that a new context has been established.
    `void` | `receiveNamespace​(String prefix, String uri, ExtractionContext context)` | Invoked with a currently open context, notifies the detection of a namespace.
    `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, ExtractionContext context)` | Invoked with a currently open context, notifies the detection of a triple.
    `void` | `setContentLength​(long contentLength)` | Sets the length of the content to be processed.
    `void` | `startDocument​(org.eclipse.rdf4j.model.IRI documentIRI)` |

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

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

- - ### Constructor Detail

    - #### LoggingTripleHandler

          public LoggingTripleHandler​(TripleHandler tripleHandler,
                                      PrintWriter destination)

  - ### Method Detail

    - #### startDocument

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

      Specified by:
        `startDocument` in interface `TripleHandler`
      Throws:
        `TripleHandlerException`

    - #### close

          public void close()
                     throws TripleHandlerException

      Description copied from interface: `TripleHandler`
      Will be called last and exactly once.
      Specified by:
        `close` in interface `AutoCloseable`
      Specified by:
        `close` in interface `TripleHandler`
      Throws:
        `TripleHandlerException` - if there is an error closing the `TripleHandler` implementation.

    - #### closeContext

          public void closeContext​(ExtractionContext context)
                            throws TripleHandlerException

      Description copied from interface: `TripleHandler`
      Informs the handler that no more triples will come from a previously opened context. All contexts are guaranteed to be closed before the final close(). The document context for each document is guaranteed to be closed after all local contexts of that document.
      Specified by:
        `closeContext` in interface `TripleHandler`
      Parameters:
        `context` - the context to be closed.
      Throws:
        `TripleHandlerException` - if there is an error closing the `ExtractionContext`.

    - #### openContext

          public void openContext​(ExtractionContext context)
                           throws TripleHandlerException

      Description copied from interface: `TripleHandler`
      Informs the handler that a new context has been established. Contexts are not guaranteed to receive any triples, so they might be closed without any triple.
      Specified by:
        `openContext` in interface `TripleHandler`
      Parameters:
        `context` - an instantiated `ExtractionContext`
      Throws:
        `TripleHandlerException` - if there is an errr opening the `ExtractionContext`

    - #### 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,
                                    ExtractionContext context)
                             throws TripleHandlerException

      Description copied from interface: `TripleHandler`
      Invoked with a currently open context, notifies the detection of a triple.
      Specified by:
        `receiveTriple` in interface `TripleHandler`
      Parameters:
        `s` - triple subject, cannot be `null`.
        `p` - triple predicate, cannot be `null`.
        `o` - triple object, cannot be `null`.
        `g` - triple graph, can be `null`.
        `context` - extraction context.
      Throws:
        `TripleHandlerException` - if there is an error receiving the triple.

    - #### receiveNamespace

          public void receiveNamespace​(String prefix,
                                       String uri,
                                       ExtractionContext context)
                                throws TripleHandlerException

      Description copied from interface: `TripleHandler`
      Invoked with a currently open context, notifies the detection of a namespace.
      Specified by:
        `receiveNamespace` in interface `TripleHandler`
      Parameters:
        `prefix` - namespace prefix.
        `uri` - namespace IRI.
        `context` - namespace context.
      Throws:
        `TripleHandlerException` - if there is an error receiving the namespace.

    - #### endDocument

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

      Description copied from interface: `TripleHandler`
      Informs the handler that the end of the document has been reached.
      Specified by:
        `endDocument` in interface `TripleHandler`
      Parameters:
        `documentIRI` - document IRI.
      Throws:
        `TripleHandlerException` - if there is an error ending the document.

    - #### setContentLength

          public void setContentLength​(long contentLength)

      Description copied from interface: `TripleHandler`
      Sets the length of the content to be processed.
      Specified by:
        `setContentLength` in interface `TripleHandler`
      Parameters:
        `contentLength` - length of the content being processed.