y.io
Class IOHandler

java.lang.Object
  |
  +--y.io.IOHandler
Direct Known Subclasses:
GMLIOHandler, ImageMapOutputHandler, ImageOutputHandler, TGFIOHandler, TiledImageOutputHandler, YGFIOHandler

public abstract class IOHandler
extends Object

Abstract IO handler class. An IO handler is responsible for reading and/or writing graphs in a specific format from/to a stream


Constructor Summary
IOHandler()
           
 
Method Summary
 boolean canRead()
          Whether this file handler supports reading from a file.
 boolean canWrite()
          Whether this file handler supports writing to a file.
 boolean canWriteSubset()
          Whether this file handler supports writing graph subsets to a file.
static ObjectInputStream createObjectInputStream(String name)
          Creates and returns an object input stream that is connected to a file.
static ObjectOutputStream createObjectOutputStream(String name)
          Creates and returns an object output stream that is connected to a file.
abstract  String getFileFormatString()
          Returns a descriptive string of the supported file format
abstract  String getFileNameExtension()
          Returns the file name extension that will be added (if not present) when saving a file.
protected  void hide(GraphHider hider, DataProvider dp)
          Uses the GraphHider to hide parts of the graph in order to write a subset.
abstract  void read(Graph2D graph, InputStream in)
          Adds the contents reads from a stream to the given graph.
 void read(Graph2D graph, String name)
          Fills the contents of the given graph from a file.
 void read(Graph2D graph, URL url)
          Fills the contents of the given graph from a URL.
protected  boolean shouldSerialize(Edge edge, DataProvider dp)
          Determines whether the given edge should be serialized.
protected  boolean shouldSerialize(Node node, DataProvider dp)
          Determines whether the given node should be serialized.
abstract  void write(Graph2D graph, OutputStream out)
          Writes the contents of the given graph to a stream
 void write(Graph2D graph, String name)
          Writes the contents of the given graph to a file.
 void writeSubset(Graph2D graph, DataProvider dp, OutputStream out)
          Writes a subset of the contents of the given graph to a stream
 void writeSubset(Graph2D graph, DataProvider dp, String name)
          Writes a subset of the contents of the given graph to a stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IOHandler

public IOHandler()
Method Detail

write

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

IOException

writeSubset

public void writeSubset(Graph2D graph,
                        DataProvider dp,
                        OutputStream out)
                 throws IOException
Writes a subset of the contents of the given graph to a stream

IOException
Parameters:
graph - hte graph to be written out
dp - the dataprovider, which contains boolean information for each element, which indicates, whether this item should be serialized or not

read

public abstract void read(Graph2D graph,
                          InputStream in)
                   throws IOException
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.

IOException

getFileFormatString

public abstract String getFileFormatString()
Returns a descriptive string of the supported file format


getFileNameExtension

public abstract String getFileNameExtension()
Returns the file name extension that will be added (if not present) when saving a file.


write

public void write(Graph2D graph,
                  String name)
           throws IOException
Writes the contents of the given graph to a file.

IOException
Parameters:
name - The name of the output file

writeSubset

public void writeSubset(Graph2D graph,
                        DataProvider dp,
                        String name)
                 throws IOException
Writes a subset of the contents of the given graph to a stream

IOException

read

public void read(Graph2D graph,
                 String name)
          throws IOException
Fills the contents of the given graph from a file.

IOException
Parameters:
name - The name of the file to be read.

read

public void read(Graph2D graph,
                 URL url)
          throws IOException
Fills the contents of the given graph from a URL.

IOException
Parameters:
url - The url of the resource to be read.

createObjectInputStream

public static ObjectInputStream createObjectInputStream(String name)
                                                 throws IOException
Creates and returns an object input stream that is connected to a file.

IOException
Parameters:
name - The name of the input file.

createObjectOutputStream

public static ObjectOutputStream createObjectOutputStream(String name)
                                                   throws IOException
Creates and returns an object output stream that is connected to a file.

IOException
Parameters:
name - The name of the output file.

canRead

public boolean canRead()
Whether this file handler supports reading from a file.


canWrite

public boolean canWrite()
Whether this file handler supports writing to a file.


canWriteSubset

public boolean canWriteSubset()
Whether this file handler supports writing graph subsets to a file.


hide

protected void hide(GraphHider hider,
                    DataProvider dp)
Uses the GraphHider to hide parts of the graph in order to write a subset.

Parameters:
hider - the hider
dp - the dataprovider which tells which graphelements to serialize and which not

shouldSerialize

protected boolean shouldSerialize(Node node,
                                  DataProvider dp)
Determines whether the given node should be serialized. The information is obtained by examining the dataprovider

Parameters:
node - the node
dp - the dataprovider which tells which graphelements to serialize and which not
Returns:
true iff this elements should be serialized

shouldSerialize

protected boolean shouldSerialize(Edge edge,
                                  DataProvider dp)
Determines whether the given edge should be serialized. The information is obtained by examining the dataprovider

Parameters:
edge - the edge
dp - the dataprovider which tells which graphelements to serialize and which not
Returns:
true iff this elements should be serialized

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

2003