org.gersteinlab.tyna.core.io
Class SIFIO

java.lang.Object
  extended byorg.gersteinlab.tyna.core.io.SIFIO
All Implemented Interfaces:
GraphReader, GraphWriter

public class SIFIO
extends java.lang.Object
implements GraphReader, GraphWriter

	This class represents the IO unit for the SIF format for directed
	graphs. Each line is of the following form:

	
	...

	Node IDs and relationship types are case-insensitive, and are stored in
	upper case.

	This format does not allow nodes that have no incident edges. Node names
	are case-insensitive. White spaces at the beginning and end of a node
	name are trimmed.
	

Version:
1.0 (November 2, 2005) Change History: 1.0 - Initial version
Author:
Kevin Yuk-Lap Yip

Constructor Summary
SIFIO()
           
 
Method Summary
 Graph readGraph(java.io.InputStream in, boolean isDirected, boolean isMultigraph)
          Read the graph from an input stream.
 Graph readGraph(java.io.Reader in, boolean isDirected, boolean isMultigraph)
          Read the graph from a reader.
 void writeGraph(Graph graph, java.io.OutputStream out)
          Write the graph to an output stream.
 void writeGraph(Graph graph, java.io.Writer out)
          Write the graph to a writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SIFIO

public SIFIO()
Method Detail

readGraph

public Graph readGraph(java.io.InputStream in,
                       boolean isDirected,
                       boolean isMultigraph)
                throws GraphTypeException,
                       java.io.IOException,
                       InputFormatException
Description copied from interface: GraphReader
Read the graph from an input stream. The class of the returned object depends on the input values of isDirected and isMulti. If isDirected is true, the returned object is an instance of DirectedGraph. Otherwise, it is an instance of UndirectedGraph. If isMulti is true, the returned object is an instance of MultiGraph. Otherwise, it is an instance of SimpleGraph. The method does not close the input stream.

Specified by:
readGraph in interface GraphReader
Parameters:
in - The input stream
isDirected - Whether the graph is to be directed
isMultigraph - Whether the graph is to be a multigraph
Returns:
The graph being read
Throws:
java.io.IOException - When there is an IO error
GraphTypeException - When the graph type does not match requirements
InputFormatException - When the input format is invalid

readGraph

public Graph readGraph(java.io.Reader in,
                       boolean isDirected,
                       boolean isMultigraph)
                throws GraphTypeException,
                       java.io.IOException,
                       InputFormatException
Description copied from interface: GraphReader
Read the graph from a reader. The class of the returned object depends on the input values of isDirected and isMulti. If isDirected is true, the returned object is an instance of DirectedGraph. Otherwise, it is an instance of UndirectedGraph. If isMulti is true, the returned object is an instance of MultiGraph. Otherwise, it is an instance of SimpleGraph. The method does not close the reader.

Specified by:
readGraph in interface GraphReader
Parameters:
in - The reader
isDirected - Whether the graph is to be directed
isMultigraph - Whether the graph is to be a multigraph
Returns:
The graph being read
Throws:
InputFormatException - When the input format is invalid
GraphTypeException - When the graph type does not match requirements
java.io.IOException - When there is an IO error

writeGraph

public void writeGraph(Graph graph,
                       java.io.OutputStream out)
                throws GraphTypeException,
                       java.io.IOException
Description copied from interface: GraphWriter
Write the graph to an output stream. The method does not close the stream.

Specified by:
writeGraph in interface GraphWriter
Parameters:
graph - The graph
out - The output stream
Throws:
java.io.IOException - When there is an IO error
GraphTypeException - When the graph type does not match requirements

writeGraph

public void writeGraph(Graph graph,
                       java.io.Writer out)
                throws GraphTypeException,
                       java.io.IOException
Description copied from interface: GraphWriter
Write the graph to a writer. The method does not close the writer.

Specified by:
writeGraph in interface GraphWriter
Parameters:
graph - The graph
out - The writer
Throws:
java.io.IOException - When there is an IO error
GraphTypeException - When the graph type does not match requirements