org.planx.io
Interface Streamer<E>

All Known Subinterfaces:
SizeStreamer<E>
All Known Implementing Classes:
Locator.CompactStreamer, PolymorphicStreamer

public interface Streamer<E>

A Streamer is capable of writing and reading objects of a specific class to and from byte representation. The Streamer must ensure that the format written by the toStream method is compatible with the fromStream method. Moreover, all data written by the toStream method must be read by the fromStream method, so that the position of the stream is ready for the next Streamer.

Compared to Serializable the advantage of using Streamers is that the identity of the class is not written to the stream, thus making the output more compact. Furthermore, multiple Streamers can be defined for the same class so that the output format is configurable and not fixed at one representation.

Note, that if a Streamer requires some kind of polymorphy, it can simply write the identity of the class to the output itself.

Author:
Thomas Ambus

Method Summary
 E fromStream(DataInput in)
          Reads an object of class E from the data source.
 void toStream(DataOutput out, E obj)
          Writes the internal state of the object to the data source in a format that can later be read by the same Streamer using the fromStream method.
 

Method Detail

toStream

void toStream(DataOutput out,
              E obj)
              throws IOException
Writes the internal state of the object to the data source in a format that can later be read by the same Streamer using the fromStream method.

Throws:
IOException

fromStream

E fromStream(DataInput in)
             throws IOException
Reads an object of class E from the data source.

Throws:
IOException


Copyright © 2004-2005 Plan-X. All Rights Reserved.