Interface Encodable
-
- All Known Implementing Classes:
EncodableList,EncodableMap,EncodableSet
public interface EncodableThis interface provides an alternative to the
DatatypeCodecinterface where the codec behaviour can be inlined directly into the datatype code. This interface can be used as a substitute forFastSerializablewhen the additional utility functions provided to codecs are necessary.Classes implementing
Encodablemust provide a public constructor that takes, in this order:-
a
DataInputargument; -
a
ClassLoaderargument; and -
a
DecoderUtilsargument.
Object state is read from the
DataInputstream. TheClassLoaderargument can be used to resolve any application-specific classes stored in the stream, and theDecoderUtilscan be used to restore certain SLEE-specific types. The constructor may throwIOException.In order for Rhino to utilise the function of the
Encodableinterface, a CMP field must be declared with a type of at leastEncodable- a CMP field declared with a type ofObjectwill fall back to Rhino’s default serialisation behaviour. Serialisation efficiency will be gained by storing into a CMP field an object of exactly the declared CMP field type. Rhino will correctly handle the case if at runtime a subclass of the declared CMP field type is stored into the CMP field, however in this case reflection must be used during deserialisation to instantiate an object of the stored class, as it cannot be known at deploy time.As for
FastSerializable, there is no handling of shared references to objects. If anEncodableobject is encountered twice during serialisation, then two copies of the object will exist upon deserialisation.- Since:
- Rhino 2.4.0
- See Also:
DatatypeCodec
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidencode(DataOutput out, EncoderUtils utils)Encode the state of this object to the given data output stream.
-
-
-
Method Detail
-
encode
void encode(DataOutput out, EncoderUtils utils) throws IOException
Encode the state of this object to the given data output stream.
- Parameters:
out- the data output stream to encode the value to.utils- additional utility encoding functions that may be useful to the encoder.- Throws:
IOException- if an I/O error occurs.- Since:
- Rhino 2.4.0
-
-