Package org.apache.any23.filter
Class ExtractionContextBlocker
- java.lang.Object
-
- org.apache.any23.filter.ExtractionContextBlocker
-
- All Implemented Interfaces:
AutoCloseable
,TripleHandler
public class ExtractionContextBlocker extends Object implements TripleHandler
A wrapper around aTripleHandler
that can block and unblock calls to the handler, either for the entire document, or for individualExtractionContext
s. A document is initially blocked and must be explicitly unblocked. Contexts are initially unblocked and must be explicitly blocked. Unblocking a document unblocks all contexts as well. This class it thread-safe.- Author:
- Richard Cyganiak (richard@cyganiak.de)
-
-
Constructor Summary
Constructors Constructor Description ExtractionContextBlocker(TripleHandler wrapped)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
blockContext(ExtractionContext context)
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.boolean
isDocBlocked()
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)
void
unblockContext(ExtractionContext context)
void
unblockDocument()
-
-
-
Constructor Detail
-
ExtractionContextBlocker
public ExtractionContextBlocker(TripleHandler wrapped)
-
-
Method Detail
-
isDocBlocked
public boolean isDocBlocked()
-
blockContext
public void blockContext(ExtractionContext context)
-
unblockContext
public void unblockContext(ExtractionContext context)
-
startDocument
public void startDocument(org.eclipse.rdf4j.model.IRI documentIRI) throws TripleHandlerException
- Specified by:
startDocument
in interfaceTripleHandler
- Throws:
TripleHandlerException
-
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 interfaceTripleHandler
- Parameters:
context
- an instantiatedExtractionContext
- Throws:
TripleHandlerException
- if there is an errr opening theExtractionContext
-
closeContext
public void closeContext(ExtractionContext context)
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 interfaceTripleHandler
- Parameters:
context
- the context to be closed.
-
unblockDocument
public void unblockDocument()
-
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 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:TripleHandler
Invoked with a currently open context, notifies the detection of a namespace.- Specified by:
receiveNamespace
in 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 TripleHandlerException
Description copied from interface:TripleHandler
Will be called last and exactly once.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceTripleHandler
- Throws:
TripleHandlerException
- if there is an error closing theTripleHandler
implementation.
-
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 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:TripleHandler
Sets the length of the content to be processed.- Specified by:
setContentLength
in interfaceTripleHandler
- Parameters:
contentLength
- length of the content being processed.
-
-