quoggles.auxiliary.gmlxml
Class GMLXMLWriter

java.lang.Object
  |
  +--quoggles.auxiliary.gmlxml.GMLXMLWriter
All Implemented Interfaces:
org.graffiti.plugin.io.OutputSerializer, org.graffiti.plugin.io.Serializer

public class GMLXMLWriter
extends java.lang.Object
implements org.graffiti.plugin.io.OutputSerializer

Provides a GML writer. This writer does not yet support all GML features yet.

Unknown attributes are written in XML style. See http://infosun.fmi.uni-passau.de/Graphlet/GML/ for more details


Field Summary
private  java.util.Map attMapping
          A map of attributes, which should be written to the stream.
private  java.util.Map colMapping
          A map of collection attributes, which should be written to the stream.
private  java.util.Collection dontWriteAttrs
          A collection of attribute paths that should not be written explicitly.
private  java.lang.String eol
          DOCUMENT ME!
private static java.lang.String TAB
          Prepresents a tabulator.
 
Constructor Summary
GMLXMLWriter()
          Constructs a new GML writer.
 
Method Summary
private  java.lang.String colToHex(org.graffiti.attributes.Attribute colorAtt)
          Converts the given color attribute into a hex string.
private  java.lang.String createTabs(int level)
          Creates and returns TAB + TAB + ... + TAB (level).
 java.lang.String[] getExtensions()
           
private  java.lang.StringBuffer getWrittenAttributeHierarchy(org.graffiti.attributes.Attribute a, int level)
          This method does not actually write the hierarchy to the stream, but stores it into a StringBuffer.
private  void warning(java.lang.String msg)
          Prints the given warning to system.out.
 void write(java.io.OutputStream o, org.graffiti.graph.Graph g)
           
private  void writeAttributable(java.io.PrintStream p, org.graffiti.attributes.Attributable a, int level)
          Writes the attribute hierarchy of the specified attributable.
private  void writeEdges(java.io.PrintStream p, org.graffiti.graph.Graph g, java.util.ArrayList nodeIds)
          Writes the edge of the given graph to the given print stream.
private  void writeGraph(java.io.PrintStream p, org.graffiti.graph.Graph g)
          Method writeGraph.
private  java.util.ArrayList writeNodes(java.io.PrintStream p, org.graffiti.graph.Graph g)
          Writes the nodes of the given graph to the given print stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAB

private static final java.lang.String TAB
Prepresents a tabulator.

See Also:
Constant Field Values

eol

private final java.lang.String eol
DOCUMENT ME!


dontWriteAttrs

private java.util.Collection dontWriteAttrs
A collection of attribute paths that should not be written explicitly. Sensible e.g. for attributes that have already been given special treatment.


attMapping

private java.util.Map attMapping
A map of attributes, which should be written to the stream. This is something like a filter and a mapping from graffiti collection attributes to GML attributes.


colMapping

private java.util.Map colMapping
A map of collection attributes, which should be written to the stream. This is something like a filter and a mapping from graffiti collection attributes to GML (hierarchial) attributes.

Constructor Detail

GMLXMLWriter

public GMLXMLWriter()
Constructs a new GML writer.

Method Detail

getExtensions

public java.lang.String[] getExtensions()
Specified by:
getExtensions in interface org.graffiti.plugin.io.Serializer
See Also:
Serializer.getExtensions()

write

public void write(java.io.OutputStream o,
                  org.graffiti.graph.Graph g)
           throws java.io.IOException
Specified by:
write in interface org.graffiti.plugin.io.OutputSerializer
java.io.IOException
See Also:
OutputSerializer.write(OutputStream, Graph)

getWrittenAttributeHierarchy

private java.lang.StringBuffer getWrittenAttributeHierarchy(org.graffiti.attributes.Attribute a,
                                                            int level)
This method does not actually write the hierarchy to the stream, but stores it into a StringBuffer. That is the means to remove empty and unnecessary sub structures. An example is the coordinate attribute: All sub attributes (x, y) of coordinate have already been written somewhere else. Therefore, the coordinate attribute itself will be empty and can be ommitted. This can be seen only after having checked all sub- attributess, though.

Parameters:
a - the collection attribute to get the attribute from.
level - the indentation level.
Returns:
the sub herarchy starting at Attribute a

colToHex

private java.lang.String colToHex(org.graffiti.attributes.Attribute colorAtt)
Converts the given color attribute into a hex string. Returns #000000, if the given color attribute could not be converted.

Parameters:
colorAtt - DOCUMENT ME!
Returns:
a hex string representing the value of the given color attribute. e.g.: "#FFFFFF" or "#00AAEE".

createTabs

private java.lang.String createTabs(int level)
Creates and returns TAB + TAB + ... + TAB (level).

Parameters:
level - the indentation level.
Returns:
a string, of level TAB.

warning

private void warning(java.lang.String msg)
Prints the given warning to system.out.

Parameters:
msg - the warning msg.

writeAttributable

private void writeAttributable(java.io.PrintStream p,
                               org.graffiti.attributes.Attributable a,
                               int level)
Writes the attribute hierarchy of the specified attributable.

Parameters:
p - the print stream to write to.
a - the attributable to read the attributes from.
level - the indentation level.

writeEdges

private void writeEdges(java.io.PrintStream p,
                        org.graffiti.graph.Graph g,
                        java.util.ArrayList nodeIds)
Writes the edge of the given graph to the given print stream.

Parameters:
p - the stream to write to.
g - the graph to get the data from.
nodeIds - the ordered list of node ids.

writeGraph

private void writeGraph(java.io.PrintStream p,
                        org.graffiti.graph.Graph g)
Method writeGraph.

Parameters:
p -
g -

writeNodes

private java.util.ArrayList writeNodes(java.io.PrintStream p,
                                       org.graffiti.graph.Graph g)
Writes the nodes of the given graph to the given print stream.

Parameters:
p - the stream to write to.
g - the graph to get the data from.
Returns:
the ordered array list of nodes.