org.mulgara.mrg.writer
Class N3Writer

java.lang.Object
  extended by org.mulgara.mrg.writer.AbstractGraphWriter
      extended by org.mulgara.mrg.writer.N3Writer
All Implemented Interfaces:
GraphWriter

public class N3Writer
extends AbstractGraphWriter
implements GraphWriter

Creates a writer specifically for N3 output.


Field Summary
 
Fields inherited from class org.mulgara.mrg.writer.AbstractGraphWriter
base, graph, prefixGen, rns
 
Constructor Summary
N3Writer(Graph graph, URI base)
          Creates a graph writer.
N3Writer(Graph graph, URI base, Map<String,URI> ns)
          Creates a graph writer.
 
Method Summary
protected  String format(Node n)
          Formats a node for printing.
protected  String formatLiteral(Literal l)
          Formats a literal for printing.
protected  String formatUri(PredicateNode p)
          Overloads formatUri(Uri) to avoid the need to cast.
protected  String formatUri(Uri u)
          Format a URI reference.
protected  void writeProperties(PrintStream o, List<PropertyValue> pvs)
          Prints all property values together, using ; and , separators.
 void writeTo(OutputStream out)
          Writes the graph to a stream.
 
Methods inherited from class org.mulgara.mrg.writer.AbstractGraphWriter
getNamespaces, resetNamespaces, scanNamespaces, setNamespaces, setNamespacesByString, testNamespace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mulgara.mrg.writer.GraphWriter
getNamespaces, resetNamespaces, scanNamespaces, setNamespaces, setNamespacesByString
 

Constructor Detail

N3Writer

public N3Writer(Graph graph,
                URI base)
Creates a graph writer.

Parameters:
graph - The graph to be written by this writer.

N3Writer

public N3Writer(Graph graph,
                URI base,
                Map<String,URI> ns)
Creates a graph writer.

Parameters:
graph - The graph to be written by this writer.
ns - The namespaces to use while emitting this graph.
Method Detail

writeTo

public void writeTo(OutputStream out)
Description copied from interface: GraphWriter
Writes the graph to a stream.

Specified by:
writeTo in interface GraphWriter
Parameters:
out - The stream to write the graph to.
See Also:
GraphWriter.writeTo(java.io.OutputStream)

writeProperties

protected void writeProperties(PrintStream o,
                               List<PropertyValue> pvs)
Prints all property values together, using ; and , separators.

Parameters:
o - The output to print to.
pvs - The property/values to be written.

formatUri

protected String formatUri(Uri u)
Format a URI reference. If it starts with a known prefix, then use that, otherwise it will be written in full form, surrounded by angle brackets.

Parameters:
u - The URI reference to present.
Returns:
Either a prefixed QName, or a full URI with bracketing.

formatUri

protected String formatUri(PredicateNode p)
Overloads formatUri(Uri) to avoid the need to cast.

Parameters:
p - The predicate node to print.
Returns:
The formatted Uri reference.

format

protected String format(Node n)
Formats a node for printing.

Parameters:
n - The node to format.
Returns:
A formatted string for the node.

formatLiteral

protected String formatLiteral(Literal l)
Formats a literal for printing.

Parameters:
l - The literal to be formatted.
Returns:
A formatted version of the literal.


Copyright © 2011. All Rights Reserved.