y.io
Class GMLIOHandler

java.lang.Object
  |
  +--y.io.IOHandler
        |
        +--y.io.GMLIOHandler

public class GMLIOHandler
extends IOHandler

Read and writes a Graph2D in Graph Modeling Language (GML). This is mainly achieved by delegating the actual work to instances, that are created by EncoderFactory and ParserFactory.

For more information about GML refer to the official GML Page for the general format and our compatibility and extension notes.


Constructor Summary
GMLIOHandler()
          Instantiates a new GMLIOHandler.
 
Method Summary
static String convertColor(Color col)
          converts a java Color into standard string representation
static EncoderFactory getEncoderFactory()
          Getter for the ParserFactory (Singleton)
 String getFileFormatString()
          Returns the GML file format string.
 String getFileNameExtension()
          Returns the GML file name extension, i.e.
static ParserFactory getParserFactory()
          Getter for the ParserFactory (Singleton)
 void read(Graph2D graph, InputStream in)
          Adds the contents from the given stream to the given graph.
protected  void read(Graph2D graph, Reader reader)
          Fills the contents of the given graph from a reader.
 void read(Graph2D graph, String name)
          Generates a FileReader and passes control to GMLIOHandler.read(Graph2D, Reader)
static void setEncoderFactory(EncoderFactory _encoderFactory)
          Setter for the EncoderFactory (Singleton)
static void setParserFactory(ParserFactory _parserFactory)
          Setter for the ParserFactory (Singleton)
 void write(Graph2D graph, OutputStream out)
          Writes the contents of the given graph in GML format to a stream.
 
Methods inherited from class y.io.IOHandler
canRead, canWrite, canWriteSubset, createObjectInputStream, createObjectOutputStream, hide, read, shouldSerialize, shouldSerialize, write, writeSubset, writeSubset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GMLIOHandler

public GMLIOHandler()
Instantiates a new GMLIOHandler.

Method Detail

getFileFormatString

public String getFileFormatString()
Returns the GML file format string.

Specified by:
getFileFormatString in class IOHandler
Returns:
the string

getFileNameExtension

public String getFileNameExtension()
Returns the GML file name extension, i.e. "gml"

Specified by:
getFileNameExtension in class IOHandler
Returns:
"gml"

read

public void read(Graph2D graph,
                 InputStream in)
          throws IOException
Adds the contents from the given stream to the given graph.

Specified by:
read in class IOHandler
IOException
Parameters:
in - The input stream being read from

read

public void read(Graph2D graph,
                 String name)
          throws IOException
Generates a FileReader and passes control to GMLIOHandler.read(Graph2D, Reader)

Overrides:
read in class IOHandler
Throws:
IOException - in the case of an I/O error
Parameters:
graph - the graph
name - the filename

read

protected void read(Graph2D graph,
                    Reader reader)
             throws IOException
Fills the contents of the given graph from a reader.

Throws:
IOException - in case of an I/O Exception
Parameters:
graph - the graph to be filled
reader - The reader being read from

getParserFactory

public static ParserFactory getParserFactory()
Getter for the ParserFactory (Singleton)

Returns:
a previously installed factory or DefaultParserFactory

setParserFactory

public static void setParserFactory(ParserFactory _parserFactory)
Setter for the ParserFactory (Singleton)

Parameters:
_parserFactory - the factory to be installed

getEncoderFactory

public static EncoderFactory getEncoderFactory()
Getter for the ParserFactory (Singleton)

Returns:
the previously installed factory or HierarchicGraphEncoderFactory

setEncoderFactory

public static void setEncoderFactory(EncoderFactory _encoderFactory)
Setter for the EncoderFactory (Singleton)

Parameters:
_encoderFactory - the factory to be installed

write

public void write(Graph2D graph,
                  OutputStream out)
           throws IOException
Writes the contents of the given graph in GML format to a stream. This is achieved by using the currently installed EncoderFactory, obtaining a ObjectEncoder for GML and invoking the ObjectEncoder.encode(java.lang.Object, y.io.gml.GMLEncoder) method with the graph as the first argument.

Specified by:
write in class IOHandler
Throws:
IOException - in case of an I/O Exception
Parameters:
graph - the graph to be written
out - The OutputStream being written to.

convertColor

public static String convertColor(Color col)
converts a java Color into standard string representation

Parameters:
col - the color
Returns:
a String in the (GML) form #RRGGBB where each of the pairs is an hexcode value between 00 and FF

© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003