org.planx.xmlstore.routing.messaging
Interface Streamable

All Known Subinterfaces:
Message
All Known Implementing Classes:
AcknowledgeMessage, ConnectMessage, DataLookupMessage, DataMessage, HashMessage, HashRequestMessage, Identifier, LookupMessage, Node, NodeLookupMessage, NodeReplyMessage, OriginMessage, RemoveMessage, StoreMessage, StoreRequestMessage, TimestampedValue

public interface Streamable

A Streamable object is able to write its state to an output stream and a class implementing Streamable must be able to recreate an instance of the class from an input stream. No information about class name is written to the output stream so it must be known what class type is expected when reading objects back in from an input stream. This gives a space advantage over Serializable but essentially kills polymorphy.

Since the exact class must be known anyway prior to reading, it is encouraged that classes implementing Streamable also provide a constructor of the form:

Streamable(DataInput in) throws IOException;

Author:
Thomas Ambus

Method Summary
 void fromStream(DataInput in)
          Reads the internal state of the Streamable object from the input stream.
 void toStream(DataOutput out)
          Writes the internal state of the Streamable object to the output stream in a format that can later be read by the same Streamble class using the fromStream(java.io.DataInput) method.
 

Method Detail

toStream

void toStream(DataOutput out)
              throws IOException
Writes the internal state of the Streamable object to the output stream in a format that can later be read by the same Streamble class using the fromStream(java.io.DataInput) method.

Throws:
IOException

fromStream

void fromStream(DataInput in)
                throws IOException
Reads the internal state of the Streamable object from the input stream. Immutable objects should throw an UnsupportedOperationException, and instead implement a constructor as described above.

Throws:
IOException


Copyright © 2010. All Rights Reserved.