ostore.util
Interface QuickSerializable
- All Known Subinterfaces:
- Digestible, Model, Model.Delta, Model.Prediction, QSCipher, QSPrivateKey, QSPublicKey, QSSignature, SecureHash, SecureVerify, SegmentedModel, SegmentedModel.Segment, TapestryQuery, TapestryQueryState, TapestryTag, VerifiableBlock
- All Known Implementing Classes:
- Array, BloomQuery, DHMessage, EncryptedQS, MACedQS, Matrix, NetworkMessage, QSBool, QSDate, QSInt, QSLong, QSMACType, QSVector, SegmentPager.Request, SegmentPager.ReverseRequest, Timestamp, ostore.tapestry.TMessageEvent, UpdateId, QSWindow, TapestryPrefixRouteMsg, PublishInfo, PatchworkModel.Observation
- public interface QuickSerializable
QuickSerializable is an interface that should be implemented by any
OceanStore object intended to be sent "over the wire", stored to disk,
or otherwise leave the happy confines of the JVM. It interacts with the
TypeTable
and Types
classes to encode and decode Java
objects to/from byte arrays.
Note that in addition to the interface defined here, all subtypes of
QuickSerializable
should define a constructor of one of the
following two forms:
Foo (byte [] data, int [] offset)
or
Foo (byte [] data, int [] offset) throws QSException
for use in decoding. The meanings of data
and
offset
for this constructor are the same as in
to_bytes(byte[], int[])
, below. The second form should be used if there
is the possiblity that the decoding process can detect a bad encoding,
in which case a QSException
should be thrown.
- Version:
- "$Id: QuickSerializable.java,v 1.6 2001/10/18 00:20:03 eaton Exp $"
- Author:
- Sean C. Rhea
- See Also:
TypeTable
,
Types
,
QSException
Method Summary |
void |
to_bytes(byte[] data,
int[] offset)
Store the object in its "on the wire" form in the byte array
data , starting at index offset [0] , and
increment offset [0] by the number of bytes written;
if data == null , increment offset [0] by
the number of bytes that would have been written otherwise. |
int |
type_code()
Returns the unique integer associated with this class in the
TypeTable . |
to_bytes
public void to_bytes(byte[] data,
int[] offset)
- Store the object in its "on the wire" form in the byte array
data
, starting at index offset [0]
, and
increment offset [0]
by the number of bytes written;
if data == null
, increment offset [0]
by
the number of bytes that would have been written otherwise.
- Parameters:
data
- The byte array to store into, or null
.offset
- A single element array whose first
element is the index in data to begin writing at on
function entry, and which on function exit has been
incremented by the number of bytes written.
type_code
public int type_code()
- Returns the unique integer associated with this class in the
TypeTable
.
- Returns:
- an integer unique to this class