org.mulgara.mrg.writer
Class AbstractGraphWriter

java.lang.Object
  extended by org.mulgara.mrg.writer.AbstractGraphWriter
Direct Known Subclasses:
N3Writer, XMLWriter

public class AbstractGraphWriter
extends Object


Field Summary
protected  String base
          The base for the document.
protected  Graph graph
          The graph to be emitted.
protected  org.mulgara.mrg.writer.PrefixGenerator prefixGen
          A generator for creating namespace prefix names
protected  Map<String,String> rns
          The registered namespaces to use while emitting the graph, reverse mapped.
 
Constructor Summary
AbstractGraphWriter(Graph graph, URI base)
          Create a graph writer with an empty namespace map.
AbstractGraphWriter(Graph graph, URI base, Map<String,URI> ns)
          Create a graph writer with a specified namespace map.
 
Method Summary
 Map<String,URI> getNamespaces()
          Gets a mapping of prefixes to their namespaces.
 void resetNamespaces()
          Clears out the prefix/namespace set.
 void scanNamespaces()
          Scans the URIs in the graph to find all the namespaces.
 void setNamespaces(Map<String,URI> ns)
           
 void setNamespacesByString(Map<String,String> ns)
           
protected  boolean testNamespace(String ns)
          Tests a potential namespace to see if it is considered to be OK.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

graph

protected final Graph graph
The graph to be emitted.


base

protected final String base
The base for the document.


rns

protected Map<String,String> rns
The registered namespaces to use while emitting the graph, reverse mapped.


prefixGen

protected org.mulgara.mrg.writer.PrefixGenerator prefixGen
A generator for creating namespace prefix names

Constructor Detail

AbstractGraphWriter

public AbstractGraphWriter(Graph graph,
                           URI base)
Create a graph writer with an empty namespace map.

Parameters:
graph - The write to be written.

AbstractGraphWriter

public AbstractGraphWriter(Graph graph,
                           URI base,
                           Map<String,URI> ns)
Create a graph writer with a specified namespace map.

Parameters:
graph - The write to be written.
ns - The namespace map to use. This maps prefixes to namespaces.
Method Detail

setNamespaces

public void setNamespaces(Map<String,URI> ns)
See Also:
GraphWriter.setNamespaces(java.util.Map)

setNamespacesByString

public void setNamespacesByString(Map<String,String> ns)
                           throws URISyntaxException
Throws:
URISyntaxException
See Also:
GraphWriter.setNamespacesByString(java.util.Map)

resetNamespaces

public void resetNamespaces()
Clears out the prefix/namespace set.


scanNamespaces

public void scanNamespaces()
Scans the URIs in the graph to find all the namespaces. This populates the internal namespace mappings. Namespace prefixes will be automatically generated, except where namespaces are recognized. This takes linear time, and uses up memory to avoid duplicating work.


getNamespaces

public Map<String,URI> getNamespaces()
Gets a mapping of prefixes to their namespaces.

Returns:
a map with prefixes as keys and namespace URIs as values.

testNamespace

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

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


Copyright © 2011. All Rights Reserved.