org.apache.any23.writer
Class RDFWriterTripleHandler

java.lang.Object
  extended by org.apache.any23.writer.RDFWriterTripleHandler
All Implemented Interfaces:
FormatWriter, TripleHandler
Direct Known Subclasses:
NQuadsWriter, NTriplesWriter, RDFXMLWriter, TriXWriter, TurtleWriter

public abstract class RDFWriterTripleHandler
extends Object
implements FormatWriter, TripleHandler

A TripleHandler that writes triples to a Sesame RDFWriter, eg for serialization using one of Sesame's writers.

Author:
Richard Cyganiak (richard@cyganiak.de), Michele Mostarda (mostarda@fbk.eu)

Method Summary
 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.openrdf.model.URI documentURI)
          Informs the handler that the end of the document has been reached.
 boolean isAnnotated()
          If true then the produced RDF is annotated with the extractors used to generate the specific statements.
 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.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o, org.openrdf.model.URI g, ExtractionContext context)
          Invoked with a currently open context, notifies the detection of a triple.
 void setAnnotated(boolean f)
          Sets the annotation flag.
 void setContentLength(long contentLength)
          Sets the length of the content to be processed.
 void startDocument(org.openrdf.model.URI documentURI)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isAnnotated

public boolean isAnnotated()
If true then the produced RDF is annotated with the extractors used to generate the specific statements.

Specified by:
isAnnotated in interface FormatWriter
Returns:
the annotation flag value.

setAnnotated

public void setAnnotated(boolean f)
Sets the annotation flag.

Specified by:
setAnnotated in interface FormatWriter
Parameters:
f - If true then the produced RDF is annotated with the extractors used to generate the specific statements.

startDocument

public void startDocument(org.openrdf.model.URI documentURI)
                   throws TripleHandlerException
Specified by:
startDocument in interface TripleHandler
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 interface TripleHandler
Throws:
TripleHandlerException

receiveTriple

public void receiveTriple(org.openrdf.model.Resource s,
                          org.openrdf.model.URI p,
                          org.openrdf.model.Value o,
                          org.openrdf.model.URI 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

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 URI.
context - namespace context.
Throws:
TripleHandlerException

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

close

public void close()
           throws TripleHandlerException
Description copied from interface: TripleHandler
Will be called last and exactly once.

Specified by:
close in interface TripleHandler
Throws:
TripleHandlerException

endDocument

public void endDocument(org.openrdf.model.URI documentURI)
                 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:
documentURI - document URI.
Throws:
TripleHandlerException

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


Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.