Package org.apache.any23.writer
Class TripleWriterHandler
- java.lang.Object
-
- org.apache.any23.writer.TripleWriterHandler
-
- All Implemented Interfaces:
AutoCloseable
,TripleHandler
,TripleWriter
- Direct Known Subclasses:
JSONWriter
,RDFWriterTripleHandler
,URIListWriter
public abstract class TripleWriterHandler extends Object implements TripleHandler, TripleWriter
This class connects aTripleHandler
to aTripleWriter
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(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(ExtractionContext context)
Writers may override this method to handle an "openContext" extraction event.void
receiveNamespace(String prefix, String uri, 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, 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
-
-
-
-
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, ExtractionContext context) throws 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 interfaceTripleHandler
- Parameters:
s
- the subject receivedp
- the predicate receivedo
- the object receivedg
- the graph name received, or nullcontext
- the extraction context- Throws:
TripleHandlerException
- if there was an error responding to a received triple
-
receiveNamespace
public void receiveNamespace(String prefix, String uri, ExtractionContext context) throws TripleHandlerException
Writers may override this method to handle a "receiveNamespace" extraction event. The default implementation calls:this.writeNamespace(prefix, uri)
- Specified by:
receiveNamespace
in interfaceTripleHandler
- Parameters:
prefix
- namespace prefix.uri
- namespace IRI.context
- the extraction context- Throws:
TripleHandlerException
- if there was an error responding to the received namepsace.
-
startDocument
public void startDocument(org.eclipse.rdf4j.model.IRI documentIRI) throws TripleHandlerException
Writers may override this method to handle a "startDocument" extraction event. The default implementation does nothing.- Specified by:
startDocument
in interfaceTripleHandler
- Parameters:
documentIRI
- the name of the document that was started- Throws:
TripleHandlerException
- if an error occurred while responding to a "startDocument" extraction event.
-
openContext
public void openContext(ExtractionContext context) throws TripleHandlerException
Writers may override this method to handle an "openContext" extraction event. The default implementation does nothing.- Specified by:
openContext
in interfaceTripleHandler
- Parameters:
context
- the context that was opened- Throws:
TripleHandlerException
- if an error occurred while responding to a "startDocument" extraction event.
-
closeContext
public void closeContext(ExtractionContext context) throws TripleHandlerException
Writers may override this method to handle a "closeContext" extraction event. The default implementation does nothing.- Specified by:
closeContext
in interfaceTripleHandler
- Parameters:
context
- the context to be closed.- Throws:
TripleHandlerException
- if an error occurred while responding to a "closeContext" extraction event.
-
endDocument
public void endDocument(org.eclipse.rdf4j.model.IRI documentIRI) throws TripleHandlerException
Writers may override this method to handle an "endDocument" extraction event. The default implementation does nothing.- Specified by:
endDocument
in interfaceTripleHandler
- Parameters:
documentIRI
- the document IRI.- Throws:
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 interfaceTripleHandler
- Parameters:
contentLength
- length of the content being processed.
-
-