org.planx.xmlstore.io
Interface Streamer<E>

All Known Implementing Classes:
InlineNodeStreamer, PolymorphicStreamer

public interface Streamer<E>

A Streamer is capable of writing and reading objects of a specific class to and from streams. 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 if needed.

Author:
Thomas Ambus

Method Summary
 E fromStream(DataInput in)
          Reads the internal state of the object from the input stream.
 void toStream(DataOutput out, E obj)
          Writes the internal state of the object to the output stream 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 output stream 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 the internal state of the object from the input stream.

Throws:
IOException


Copyright © 2010. All Rights Reserved.