org.geotools.graph.io.standard
Class SerializedReaderWriter

java.lang.Object
  extended byorg.geotools.graph.io.standard.AbstractReaderWriter
      extended byorg.geotools.graph.io.standard.SerializedReaderWriter
All Implemented Interfaces:
FileReaderWriter, GraphReaderWriter

public class SerializedReaderWriter
extends AbstractReaderWriter
implements FileReaderWriter

An implementation of GraphReaderWriter that uses java serialization to read and write graph objects. During the graph serialization process edges are written to the object output stream. Along with the edges, the two nodes incident to the edge are also written. However, edge adjacency lists of nodes are not written to the output stream in order to prevent deep recursive calls that often result in a stack overflow. Therefore it is important that any implementation of the Node interface declare its edge adjacecny list (if any) as transient in order to support graph serializability.
Because edge adjacency lists are not serialized, they must be reconstructed upon deserialization in order to preserve the original graph structure.

Author:
Justin Deoliveira, Refractions Research Inc, jdeolive@refractions.net

Field Summary
 
Fields inherited from class org.geotools.graph.io.standard.AbstractReaderWriter
BUILDER, EDGES, GENERATOR, NODES
 
Fields inherited from interface org.geotools.graph.io.standard.FileReaderWriter
FILENAME
 
Constructor Summary
SerializedReaderWriter()
           
 
Method Summary
 Graph read()
          Deserializes the graph and reconstructs the original structure.
 void write(Graph graph)
          Serializes the graph by writing each edge in the graph to an object output stream.
 
Methods inherited from class org.geotools.graph.io.standard.AbstractReaderWriter
getProperty, setProperty, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.geotools.graph.io.GraphReaderWriter
getProperty, setProperty
 

Constructor Detail

SerializedReaderWriter

public SerializedReaderWriter()
Method Detail

read

public Graph read()
           throws java.lang.Exception
Deserializes the graph and reconstructs the original structure.

Specified by:
read in interface GraphReaderWriter
Returns:
The represented graph.
Throws:
java.lang.Exception
See Also:
GraphReaderWriter.read()

write

public void write(Graph graph)
           throws java.lang.Exception
Serializes the graph by writing each edge in the graph to an object output stream. If there any nodes of degree 0 in the graph, then they are appended to the end of the object output stream.

Specified by:
write in interface GraphReaderWriter
Parameters:
graph - The graph to be
Throws:
java.lang.Exception
See Also:
GraphReaderWriter#write()


Copyright © GeoTools. All Rights Reserved.