Package org.apache.any23.writer
Class CompositeTripleHandler
- java.lang.Object
-
- org.apache.any23.writer.CompositeTripleHandler
-
- All Implemented Interfaces:
AutoCloseable,TripleHandler
public class CompositeTripleHandler extends Object implements TripleHandler
ATripleHandlermulti decorator, that wraps zero or more other triple handlers and dispatches all events to each of them.- Author:
- Richard Cyganiak (richard@cyganiak.de)
-
-
Constructor Summary
Constructors Constructor Description CompositeTripleHandler()Constructor with empty decorated list.CompositeTripleHandler(Collection<TripleHandler> children)Constructor with initial list of decorated handlers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(TripleHandler child)Adds a decorated handler.voidclose()Will be called last and exactly once.voidcloseContext(ExtractionContext context)Informs the handler that no more triples will come from a previously opened context.voidendDocument(org.eclipse.rdf4j.model.IRI documentIRI)Informs the handler that the end of the document has been reached.Collection<TripleHandler>getChilds()voidopenContext(ExtractionContext context)Informs the handler that a new context has been established.voidreceiveNamespace(String prefix, String uri, ExtractionContext context)Invoked with a currently open context, notifies the detection of a namespace.voidreceiveTriple(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.voidsetContentLength(long contentLength)Sets the length of the content to be processed.voidstartDocument(org.eclipse.rdf4j.model.IRI documentIRI)
-
-
-
Constructor Detail
-
CompositeTripleHandler
public CompositeTripleHandler()
Constructor with empty decorated list.
-
CompositeTripleHandler
public CompositeTripleHandler(Collection<TripleHandler> children)
Constructor with initial list of decorated handlers.- Parameters:
children- list of decorated handlers.
-
-
Method Detail
-
addChild
public void addChild(TripleHandler child)
Adds a decorated handler.- Parameters:
child- the decorated handler.
-
getChilds
public Collection<TripleHandler> getChilds()
-
startDocument
public void startDocument(org.eclipse.rdf4j.model.IRI documentIRI) throws TripleHandlerException- Specified by:
startDocumentin interfaceTripleHandler- Throws:
TripleHandlerException
-
openContext
public void openContext(ExtractionContext context) throws TripleHandlerException
Description copied from interface:TripleHandlerInforms 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:
openContextin interfaceTripleHandler- Parameters:
context- an instantiatedExtractionContext- Throws:
TripleHandlerException- if there is an errr opening theExtractionContext
-
closeContext
public void closeContext(ExtractionContext context) throws TripleHandlerException
Description copied from interface:TripleHandlerInforms 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:
closeContextin interfaceTripleHandler- Parameters:
context- the context to be closed.- Throws:
TripleHandlerException- if there is an error closing theExtractionContext.
-
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 TripleHandlerExceptionDescription copied from interface:TripleHandlerInvoked with a currently open context, notifies the detection of a triple.- Specified by:
receiveTriplein interfaceTripleHandler- Parameters:
s- triple subject, cannot benull.p- triple predicate, cannot benull.o- triple object, cannot benull.g- triple graph, can benull.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:TripleHandlerInvoked with a currently open context, notifies the detection of a namespace.- Specified by:
receiveNamespacein interfaceTripleHandler- Parameters:
prefix- namespace prefix.uri- namespace IRI.context- namespace context.- Throws:
TripleHandlerException- if there is an error receiving the namespace.
-
close
public void close() throws TripleHandlerExceptionDescription copied from interface:TripleHandlerWill be called last and exactly once.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceTripleHandler- Throws:
TripleHandlerException- if there is an error closing theTripleHandlerimplementation.
-
endDocument
public void endDocument(org.eclipse.rdf4j.model.IRI documentIRI) throws TripleHandlerExceptionDescription copied from interface:TripleHandlerInforms the handler that the end of the document has been reached.- Specified by:
endDocumentin interfaceTripleHandler- Parameters:
documentIRI- document IRI.- Throws:
TripleHandlerException- if there is an error ending the document.
-
setContentLength
public void setContentLength(long contentLength)
Description copied from interface:TripleHandlerSets the length of the content to be processed.- Specified by:
setContentLengthin interfaceTripleHandler- Parameters:
contentLength- length of the content being processed.
-
-