Search this API

y.io
Class IOHandler

java.lang.Object
  extended by y.io.IOHandler
Direct Known Subclasses:
GMLIOHandler, GraphMLIOHandler, ImageMapOutputHandler, ImageOutputHandler, TGFIOHandler, TiledImageOutputHandler, XmlXslIOHandler, YGFIOHandler

public abstract class IOHandler
extends java.lang.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 java.io.ObjectInputStream createObjectInputStream(java.lang.String name)
          Creates and returns an object input stream that is connected to a file.
static java.io.ObjectOutputStream createObjectOutputStream(java.lang.String name)
          Creates and returns an object output stream that is connected to a file.
abstract  java.lang.String getFileFormatString()
          Returns a descriptive string of the supported file format.
abstract  java.lang.String getFileNameExtension()
          Returns the file name extension of the supported file format.
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, java.io.InputStream in)
          Adds the contents that are read from the stream to the given graph.
 void read(Graph2D graph, java.lang.String name)
          Fills the contents of the given graph from a file.
 void read(Graph2D graph, java.net.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, java.io.OutputStream out)
          Writes the contents of the given graph to a stream
 void write(Graph2D graph, java.lang.String name)
          Writes the contents of the given graph to a file.
 void writeSubset(Graph2D graph, DataProvider dp, java.io.OutputStream out)
          Writes a subset of the contents of the given graph to a stream
 void writeSubset(Graph2D graph, DataProvider dp, java.lang.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,
                           java.io.OutputStream out)
                    throws java.io.IOException
Writes the contents of the given graph to a stream

Throws:
java.io.IOException

writeSubset

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

Parameters:
graph - the graph to be written out
dp - the data provider, which contains boolean information for each element, which indicates, whether this item should be serialized or not
Throws:
java.io.IOException

read

public abstract void read(Graph2D graph,
                          java.io.InputStream in)
                   throws java.io.IOException
Adds the contents that are read from the stream to the given graph. The given graph will not be cleared when the content of the file will be added to it.

Throws:
java.io.IOException

getFileFormatString

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


getFileNameExtension

public abstract java.lang.String getFileNameExtension()
Returns the file name extension of the supported file format. The extension does not include the separating dot (i.e, '.').


write

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

Parameters:
name - The name of the output file
Throws:
java.io.IOException

writeSubset

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

Throws:
java.io.IOException

read

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

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

read

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

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

createObjectInputStream

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

Parameters:
name - The name of the input file.
Throws:
java.io.IOException

createObjectOutputStream

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

Parameters:
name - The name of the output file.
Throws:
java.io.IOException

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 data provider which tells which graph elements 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 data provider

Parameters:
node - the node
dp - the data provider which tells which graph elements 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 data provider

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

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