org.mulgara.mrg.writer
Class XMLWriter

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

public class XMLWriter
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
XMLWriter(Graph graph, URI base)
          Creates a graph writer.
XMLWriter(Graph graph, URI base, Map<String,URI> ns)
          Creates a graph writer.
 
Method Summary
protected  void emitPropVal(PrintStream o, int i, Uri property, ObjectNode value)
          Prints a single property/value pair where the value is a Uri or a Bnode.
protected  void emitPropVal(PrintStream o, Uri property, Literal value)
          Prints a single property/value pair where the value is a literal.
protected  String formatForAbout(Uri u)
          Format a URI reference for use in an about=.
protected  String formatForTag(Uri u)
          Format a URI reference for use in an XML tag.
 void scanNamespaces()
          Scans the graph for valid namespaces.
protected  boolean testNamespace(String ns)
          Tests a potential namespace to see if it is considered to be OK.
 void writeTo(OutputStream out)
          Writes the graph to a stream.
 
Methods inherited from class org.mulgara.mrg.writer.AbstractGraphWriter
getNamespaces, resetNamespaces, setNamespaces, setNamespacesByString
 
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, setNamespaces, setNamespacesByString
 

Constructor Detail

XMLWriter

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

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

XMLWriter

public XMLWriter(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

scanNamespaces

public void scanNamespaces()
Scans the graph for valid namespaces. Adds in the RDF namespace by default, even if this is not explicitly used in the graph.

Specified by:
scanNamespaces in interface GraphWriter
Overrides:
scanNamespaces in class AbstractGraphWriter
See Also:
AbstractGraphWriter.scanNamespaces()

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)

emitPropVal

protected void emitPropVal(PrintStream o,
                           int i,
                           Uri property,
                           ObjectNode value)
Prints a single property/value pair where the value is a Uri or a Bnode.

Parameters:
o - The print stream to use as output.
i - The indent amount.
property - The property.
value - The literal value for the property.

emitPropVal

protected void emitPropVal(PrintStream o,
                           Uri property,
                           Literal value)
Prints a single property/value pair where the value is a literal.

Parameters:
o - The print stream to use as output.
property - The property.
value - The literal value for the property.

formatForAbout

protected String formatForAbout(Uri u)
Format a URI reference for use in an about=.

Parameters:
u - The URI reference to present.
Returns:
A string suitable for about=""

formatForTag

protected String formatForTag(Uri u)
Format a URI reference for use in an XML tag.

Parameters:
u - The URI reference to present.
Returns:
A QName.

testNamespace

protected boolean testNamespace(String ns)
Tests a potential namespace to see if it is considered to be OK.

Overrides:
testNamespace in class AbstractGraphWriter
Parameters:
ns - The namespace to test.
Returns:
true iff the namespace can be used in this type of document.


Copyright © 2011. All Rights Reserved.