org.eaglei.repository.format
Class RDFContextNTriplesWriter

java.lang.Object
  extended by org.openrdf.rio.helpers.RDFHandlerBase
      extended by org.eaglei.repository.format.RDFContextNTriplesWriter
All Implemented Interfaces:
org.openrdf.rio.RDFHandler, org.openrdf.rio.RDFWriter

public class RDFContextNTriplesWriter
extends org.openrdf.rio.helpers.RDFHandlerBase
implements org.openrdf.rio.RDFWriter

Writer for "Context NTriples" RDF serialization format About the Format: This is NOT a standard or "offcial" format. We made this up for the eagle-i project, to have a simple line-based QUAD (not TRIPLE) format that makes it easy to compare the contents of two groups of quads, or dumps of a Sesame context-aware triplestore (really quad-store). Note that there IS a similar quasi-official semi-standard, "N-Quads" format documented ehre: http://sw.deri.org/2008/07/n-quads/ It is NOT useful for our needs since they put the context last and leave it as an optional addition, so statements might be rendered as triples; this makes simple text comparison difficult and columnar manipulation (e.g. with "awk" is impossible, since the 3rd element of a statement might be a literal with embedded colum-sep characters.. It's much more sensible efficeint to put the context in the first column! The only purpose of tihs format is to render "quads" - i.e. the statement *and* its context(s) - in a format that is guaranteed to to be the same for any equivalent graph, modulo the order of the lines. This allows sorted output to be compared for equality with a simple text comparision. It CANNOT be parsed into reasonable RDF again because the identifiers in blank nodes are lost. So there is no parser. Format is similar to NTriples; see: http://www.w3.org/TR/rdf-testcases/#ntriples ..only each line STARTS with a forth value, the context (or named graph); null context represented by "<>". Destructive changes when filtering output: 1. Optionally normalize all blank nodes so they compare as equal, all named _:bnode 2. Transform newline characters (both \r and \n) into escaped versions so they do not induce "false" line breaks. Remember, it is *ONLY* useful to debug and compare this output!

Version:
$Id: $
Author:
Larry Stone Started May 10, 2010

Field Summary
static org.openrdf.rio.RDFFormat CONTEXT_NTRIPLES
          Constant CONTEXT_NTRIPLES
static java.lang.String CONTEXT_NTRIPLES_MIME
          Constant CONTEXT_NTRIPLES_MIME="text/x-rdf-context-ntriples"
static boolean normalizeBNodes
           
 
Constructor Summary
RDFContextNTriplesWriter(java.io.Writer out)
          Constructor for RDFContextNTriplesWriter.
 
Method Summary
 void endRDF()
          endRDF
 org.openrdf.rio.RDFFormat getRDFFormat()
          getRDFFormat
 void handleStatement(org.openrdf.model.Statement s)
          
 
Methods inherited from class org.openrdf.rio.helpers.RDFHandlerBase
handleComment, handleNamespace, startRDF
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openrdf.rio.RDFHandler
handleComment, handleNamespace, startRDF
 

Field Detail

CONTEXT_NTRIPLES_MIME

public static final java.lang.String CONTEXT_NTRIPLES_MIME
Constant CONTEXT_NTRIPLES_MIME="text/x-rdf-context-ntriples"

See Also:
Constant Field Values

normalizeBNodes

public static final boolean normalizeBNodes
See Also:
Constant Field Values

CONTEXT_NTRIPLES

public static final org.openrdf.rio.RDFFormat CONTEXT_NTRIPLES
Constant CONTEXT_NTRIPLES

Constructor Detail

RDFContextNTriplesWriter

public RDFContextNTriplesWriter(java.io.Writer out)

Constructor for RDFContextNTriplesWriter.

Parameters:
out - a Writer object.
Method Detail

getRDFFormat

public org.openrdf.rio.RDFFormat getRDFFormat()

getRDFFormat

Specified by:
getRDFFormat in interface org.openrdf.rio.RDFWriter
Returns:
a RDFFormat object.

handleStatement

public void handleStatement(org.openrdf.model.Statement s)
                     throws org.openrdf.rio.RDFHandlerException

Specified by:
handleStatement in interface org.openrdf.rio.RDFHandler
Overrides:
handleStatement in class org.openrdf.rio.helpers.RDFHandlerBase
Throws:
org.openrdf.rio.RDFHandlerException

endRDF

public void endRDF()
            throws org.openrdf.rio.RDFHandlerException

endRDF

Specified by:
endRDF in interface org.openrdf.rio.RDFHandler
Overrides:
endRDF in class org.openrdf.rio.helpers.RDFHandlerBase
Throws:
org.openrdf.rio.RDFHandlerException - if any.


Copyright © 2009-2011 Eagle-I. All Rights Reserved.