|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.kuka.comm.codec.Encoder<I,O>
I - the input type of this encoderO - the output type of this encoderpublic abstract class Encoder<I,O>
A basic encoder. This class encapsulates different encoding implementations into a generic
encode(Object, Object) method call.
Encoders must be implemented in a thread-safe manner. They should either be stateless or their state should not be
changed while they are being used by a Connection or a Server.
Moreover a implementation to concatenate two encoder has been realized by this class. As far as you just want to
define the way of encoding, this class is the right one. Otherwise you have to derive the Encoder interface
directly.
A encodeImpl(Object, Object) method needs to be derived by more specific implementations.
| Nested Class Summary | |
|---|---|
protected static class |
Encoder.EncoderContext
This class can be used to do some more encoding after a concatenated encoder finished. |
| Constructor Summary | |
|---|---|
Encoder()
|
|
| Method Summary | |
|---|---|
Encoder<I,O> |
concat(Encoder<I,O> next)
This method concatenates two encoders, i.e. they will be executed in a row. |
void |
encode(I in,
O out)
Encodes the given input into to the given output object. |
protected void |
encodeImpl(I in,
O out)
Override this method to implement encoding process. |
protected void |
encodeImpl(I in,
O out,
Encoder.EncoderContext context)
Override this method to implement encoding process. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Encoder()
| Method Detail |
|---|
public final void encode(I in,
O out)
throws EncoderException
This method is usually called in the send method of a connection (see Connection.send(Object)) to encode
the method that should be sent. But it can also be used by other encoders.
in - the input for this encoder, usually the message to be encodedout - the output for this encoder, usually the encoded message
EncoderException - if an error occurred during encodingpublic final Encoder<I,O> concat(Encoder<I,O> next)
next - the encoder to be executed after this one
protected void encodeImpl(I in,
O out)
throws EncoderException
Note: You should override either this method or encodeImpl(Object, Object, EncoderContext).
Overriding both will have no effect, i.e. only encodeImpl(Object, Object, EncoderContext) will be
called.
in - the input for this encoderout - the output for this encoder
EncoderException - if an error occurred during encodingencodeImpl(Object, Object, EncoderContext)
protected void encodeImpl(I in,
O out,
Encoder.EncoderContext context)
throws EncoderException
The context is currently only taken into account if this encoder is concatenated to another one
concat(Encoder).
Note: You should override either this method or encodeImpl(Object, Object). Overriding both will
have no effect, i.e. only encodeImpl(Object, Object, EncoderContext) will be called.
in - the input for this encoderout - the output for this encodercontext - can be used to do some more encoding after a concatenated encoder finished
EncoderException - if an error occurred during encodingencodeImpl(Object, Object)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||