y.io
Class YGFIOHandler

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

public class YGFIOHandler
extends IOHandler

Reading and Writing graphs in Y Graph Format (YGF).


Constructor Summary
YGFIOHandler()
          Instantiates a new YGFIOHandler.
 
Method Summary
static void addEncoding(String encodedName, String decodedName)
          Adds a new class name encoding to YGFIOHandler.
protected  Graph2D createInnerGraph(Node anchorNode)
          Creates a new graph instance that is used as inner graph for a Graph2DNodeRealizer in case the read in graph is not part of a graph hierarchy.
static String decode(String encodedName)
          Decodes the external class name string generated by YGFIOHandler.encode(String).
static String encode(String decodedName)
          Returns the external form of a given class name string.
 String getFileFormatString()
          Returns the YGF file format string.
 String getFileNameExtension()
          Returns the YGF file name extension, i.e.
 void read(Graph2D graph, InputStream in)
          Adds the contents reads from a stream to the given graph.
protected  void read(Graph2D graph, ObjectInputStream in)
          Fills the contents of the given graph from an ObjectInputStream.
protected  void readEdgeInfo(Graph2D graph, Edge e, ObjectInputStream in)
          Reads edge information from the given input stream.
protected  void readEdgeRealizer(Graph2D graph, Edge e, ObjectInputStream in)
          Reads edge realizer information from the input stream.
protected  void readFolderNodeInfo(Graph2D graph, Node v, ObjectInputStream in)
          Reads in folder node information if the given graph was part of a graph hierarchy.
protected  void readGroupNodeInfo(Graph2D graph, Node v, ObjectInputStream in)
          Reads in group node information if the given graph was part of a graph hierarchy and contained grouped nodes.
protected  void readInterEdgeInfo(Graph2D graph, Edge e, ObjectInputStream in)
          Reads graph hierarchic inter edge information from the given input stream.
protected  void readNodeInfo(Graph2D graph, Node v, ObjectInputStream in)
          Reads node information from the input stream.
protected  void readNodeRealizer(Graph2D graph, Node v, ObjectInputStream in)
          Reads node realizer information from the input stream.
protected  void write(Graph2D graph, ObjectOutputStream out)
          Writes the contents of the given graph to an ObjectOutputStream.
 void write(Graph2D graph, OutputStream out)
          Writes the contents of the given graph in YGF format to a stream.
protected  void writeEdgeInfo(Graph2D graph, Edge e, ObjectOutputStream out)
          Writes edge information to the output stream.
protected  void writeEdgeRealizer(Graph2D graph, Edge e, ObjectOutputStream out)
          Writes edge realizer information to the given output stream.
protected  void writeFolderNodeInfo(Graph2D graph, Node v, ObjectOutputStream out)
          Writes out folder node information if the given graph is part of a graph hierarchy.
protected  void writeGroupNodeInfo(Graph2D graph, Node v, ObjectOutputStream out)
          Writes out group node information if the given graph is part of a graph hierarchy.
protected  void writeInterEdgeInfo(Graph2D graph, Edge e, ObjectOutputStream out)
          Writes graph hierarchic inter edge information to the given output stream.
protected  void writeNodeInfo(Graph2D graph, Node v, ObjectOutputStream out)
          Writes node information to the output stream.
protected  void writeNodeRealizer(Graph2D graph, Node v, ObjectOutputStream out)
          Writes node realizer information to the output stream.
 
Methods inherited from class y.io.IOHandler
canRead, canWrite, canWriteSubset, createObjectInputStream, createObjectOutputStream, hide, read, 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

YGFIOHandler

public YGFIOHandler()
Instantiates a new YGFIOHandler.

Method Detail

addEncoding

public static void addEncoding(String encodedName,
                               String decodedName)
Adds a new class name encoding to YGFIOHandler. The methods YGFIOHandler.encode(String) and YGFIOHandler.decode(String) can be used to translate between encoded and decoded names.


encode

public static String encode(String decodedName)
Returns the external form of a given class name string. If the given name can't be encoded, the decoded name itself will be returned.


decode

public static String decode(String encodedName)
Decodes the external class name string generated by YGFIOHandler.encode(String). If the given name can't be decoded, the encoded name itself will be returned.


getFileFormatString

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

Specified by:
getFileFormatString in class IOHandler

getFileNameExtension

public String getFileNameExtension()
Returns the YGF file name extension, i.e. "ygf"

Specified by:
getFileNameExtension in class IOHandler

write

public void write(Graph2D graph,
                  OutputStream out)
           throws IOException
Writes the contents of the given graph in YGF format to a stream.

Specified by:
write in class IOHandler
IOException

write

protected void write(Graph2D graph,
                     ObjectOutputStream out)
              throws IOException
Writes the contents of the given graph to an ObjectOutputStream.

IOException

writeEdgeInfo

protected void writeEdgeInfo(Graph2D graph,
                             Edge e,
                             ObjectOutputStream out)
                      throws IOException
Writes edge information to the output stream. Edge information includes realizer information and graph hierarchic inter edge information. Subclasses may want to refine this method.

IOException
Parameters:
e - The edge for which information is written out

writeEdgeRealizer

protected void writeEdgeRealizer(Graph2D graph,
                                 Edge e,
                                 ObjectOutputStream out)
                          throws IOException
Writes edge realizer information to the given output stream.

IOException

writeInterEdgeInfo

protected void writeInterEdgeInfo(Graph2D graph,
                                  Edge e,
                                  ObjectOutputStream out)
                           throws IOException
Writes graph hierarchic inter edge information to the given output stream.

IOException

writeNodeInfo

protected void writeNodeInfo(Graph2D graph,
                             Node v,
                             ObjectOutputStream out)
                      throws IOException
Writes node information to the output stream. Node information includes realizer information and graph hierarchic inner graph information Subclasses may want to overwrite this method.

IOException
Parameters:
v - The node for which information is written out

writeNodeRealizer

protected void writeNodeRealizer(Graph2D graph,
                                 Node v,
                                 ObjectOutputStream out)
                          throws IOException
Writes node realizer information to the output stream.

IOException
Parameters:
v - The node for which information is written out

writeFolderNodeInfo

protected void writeFolderNodeInfo(Graph2D graph,
                                   Node v,
                                   ObjectOutputStream out)
                            throws IOException
Writes out folder node information if the given graph is part of a graph hierarchy.

IOException

writeGroupNodeInfo

protected void writeGroupNodeInfo(Graph2D graph,
                                  Node v,
                                  ObjectOutputStream out)
                           throws IOException
Writes out group node information if the given graph is part of a graph hierarchy.

IOException

read

public void read(Graph2D graph,
                 InputStream in)
          throws IOException
Description copied from class: IOHandler
Adds the contents reads from a stream to the given graph. The given graph will not be cleared before the content of the file will be added to it.

Specified by:
read in class IOHandler
IOException

read

protected void read(Graph2D graph,
                    ObjectInputStream in)
             throws IOException
Fills the contents of the given graph from an ObjectInputStream.

IOException

readNodeInfo

protected void readNodeInfo(Graph2D graph,
                            Node v,
                            ObjectInputStream in)
                     throws IOException
Reads node information from the input stream. Subclasses may want to overwrite this method.

IOException
Parameters:
v - The node for which information is read in
graph - The graph that is the owner of the given node.

readNodeRealizer

protected void readNodeRealizer(Graph2D graph,
                                Node v,
                                ObjectInputStream in)
                         throws IOException
Reads node realizer information from the input stream. Subclasses may want to overwrite this method.

IOException
Parameters:
v - The node for which information is read in
graph - The graph that is the owner of the given node.

createInnerGraph

protected Graph2D createInnerGraph(Node anchorNode)
Creates a new graph instance that is used as inner graph for a Graph2DNodeRealizer in case the read in graph is not part of a graph hierarchy.

Parameters:
anchorNode - the anchor node for which to create an inner graph.
Returns:
returns a Graph2D object. Subclasses may want to overwrite this method to return a specialized version of Graph2D.

readFolderNodeInfo

protected void readFolderNodeInfo(Graph2D graph,
                                  Node v,
                                  ObjectInputStream in)
                           throws IOException
Reads in folder node information if the given graph was part of a graph hierarchy.

IOException

readGroupNodeInfo

protected void readGroupNodeInfo(Graph2D graph,
                                 Node v,
                                 ObjectInputStream in)
                          throws IOException
Reads in group node information if the given graph was part of a graph hierarchy and contained grouped nodes.

IOException

readEdgeInfo

protected void readEdgeInfo(Graph2D graph,
                            Edge e,
                            ObjectInputStream in)
                     throws IOException
Reads edge information from the given input stream. Edge information includes realizer information and graph hierarchic inter edge information. Subclasses may want to refine this method.

IOException
Parameters:
e - The edge for which information is read in.

readEdgeRealizer

protected void readEdgeRealizer(Graph2D graph,
                                Edge e,
                                ObjectInputStream in)
                         throws IOException
Reads edge realizer information from the input stream.

IOException
Parameters:
e - The edge for which information is read in
graph - The graph that is the owner of the given edge

readInterEdgeInfo

protected void readInterEdgeInfo(Graph2D graph,
                                 Edge e,
                                 ObjectInputStream in)
                          throws IOException
Reads graph hierarchic inter edge information from the given input stream.

IOException

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

2003