|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.instantreality.InstantIO.Decoder
public abstract class Decoder
Abstract superclass of all classes that decode data values.
The NetworkNode
class uses
decoders to decode values received from other components
on the network. Before any data type can be transferred via
the network, a Decoder has to be written that transforms a
system and hardware independent byte stream to data values.
For some frequently used data types, decoders already exist
in this package, but when you need to transfer your own
data types, you have to implement a Decoder.
For example, let's say you want to transfer Integer
values via the network (a Decoder for
Integer
of course already exists in this package,
but for the sake of demonstrating the procedure whe
nevertheless demonstrate how to create your own). First, you
have to create a class that inherits from the Decoder class
and implements the abstract decode
method:
Then, you have to create a corresponding
public class MyIntDecoder extends Decoder
{
public final Object decode(DataInputStream dis)
throws IOException
{
return new Integer(dis.readInt());
}
}
Encoder
class (see the documentation of this class for
more information about how to do that). Finally, you have
to create an instance of the Codec
class so
that the NetworkNode can actually access your Decoder
(see documentation of the Codec class).
NetworkNode
,
Encoder
,
Codec
Constructor Summary | |
---|---|
protected |
Decoder()
Creates a new Decoder object. |
Method Summary | |
---|---|
abstract java.lang.Object |
decode(java.io.DataInputStream dis)
Decodes objects. |
void |
initialize(java.lang.String label,
java.lang.Class type,
java.lang.String description)
Initializes the Decoder object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected Decoder()
Method Detail |
---|
public void initialize(java.lang.String label, java.lang.Class type, java.lang.String description)
label
- The label of the OutSlottype
- The type of the OutSlotdescription
- The description of the OutSlotpublic abstract java.lang.Object decode(java.io.DataInputStream dis) throws java.io.IOException
dis
- The input stream you read the system and hardware independent
byte stream from.
java.io.IOException
- when the conversion fails (should
never happen)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |