Interface Encodable
-
- All Known Implementing Classes:
EncodableList
,EncodableMap
,EncodableSet
public interface Encodable
This interface provides an alternative to the
DatatypeCodec
interface where the codec behaviour can be inlined directly into the datatype code. This interface can be used as a substitute forFastSerializable
when the additional utility functions provided to codecs are necessary.Classes implementing
Encodable
must provide a public constructor that takes, in this order:-
a
DataInput
argument; -
a
ClassLoader
argument; and -
a
DecoderUtils
argument.
Object state is read from the
DataInput
stream. TheClassLoader
argument can be used to resolve any application-specific classes stored in the stream, and theDecoderUtils
can be used to restore certain SLEE-specific types. The constructor may throwIOException
.In order for Rhino to utilise the function of the
Encodable
interface, a CMP field must be declared with a type of at leastEncodable
- a CMP field declared with a type ofObject
will 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 anEncodable
object 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 void
encode(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
-
-