org.geotools.graph.io.standard
Class SerializedReaderWriter
Object
AbstractReaderWriter
SerializedReaderWriter
- All Implemented Interfaces:
- GraphReaderWriter, FileReaderWriter
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
- Module:
modules/extension/graph (gt-graph.jar)
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 Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SerializedReaderWriter
public SerializedReaderWriter()
read
public Graph read()
throws Exception
- Deserializes the graph and reconstructs the original structure.
- Specified by:
read
in interface GraphReaderWriter
- Returns:
- The represented graph.
- Throws:
Exception
- See Also:
GraphReaderWriter.read()
write
public void write(Graph graph)
throws 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:
Exception
- See Also:
GraphReaderWriter#write()
Copyright © 1996-2009 Geotools. All Rights Reserved.