com.kuka.comm.codec.bytebuffer
Class EnclosingTokenEncoder<I>

java.lang.Object
  extended by com.kuka.comm.codec.Encoder<I,ByteBuffer>
      extended by com.kuka.comm.codec.bytebuffer.EnclosingTokenEncoder<I>
Type Parameters:
I - the input type of this encoder

public final class EnclosingTokenEncoder<I>
extends Encoder<I,ByteBuffer>

This encoder delimits a payload strictly with a constant prefix and postfix. Hence, it must be given that prefix and postfix are not part of the payload code.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.kuka.comm.codec.Encoder
Encoder.EncoderContext
 
Constructor Summary
EnclosingTokenEncoder(byte[] prefix, byte[] postfix)
          Creates a new enclosing token encoder.
EnclosingTokenEncoder(String prefix, String postfix)
          Creates a new enclosing token encoder.
 
Method Summary
protected  void encodeImpl(I in, ByteBuffer out, Encoder.EncoderContext context)
          Override this method to implement encoding process.
 
Methods inherited from class com.kuka.comm.codec.Encoder
concat, encode, encodeImpl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnclosingTokenEncoder

public EnclosingTokenEncoder(String prefix,
                             String postfix)
Creates a new enclosing token encoder.

First the prefix is put into the output buffer, after that the next concatenated encoder writes to the payload buffer. The postfix is added to the end of the payload.

Parameters:
prefix - The prefix. It may not be null or empty. The prefix must be different from the postfix and it may not contain the postfix as a substring.
postfix - The postfix. It may not be null or empty. The postfix must be different from the prefix and it may not contain the prefix as a substring.

EnclosingTokenEncoder

public EnclosingTokenEncoder(byte[] prefix,
                             byte[] postfix)
Creates a new enclosing token encoder.

First the prefix is put into the output buffer, after that the next concatenated encoder writes to the payload buffer. The postfix is added to the end of the payload.

Parameters:
prefix - The prefix. It may not be null or empty. The prefix must be different from the postfix and it may not contain the postfix as a substring.
postfix - The postfix. It may not be null or empty. The postfix must be different from the prefix and it may not contain the prefix as a substring.
Method Detail

encodeImpl

protected void encodeImpl(I in,
                          ByteBuffer out,
                          Encoder.EncoderContext context)
Description copied from class: Encoder
Override this method to implement encoding process.

The context is currently only taken into account if this encoder is concatenated to another one Encoder.concat(Encoder).

Note: You should override either this method or Encoder.encodeImpl(Object, Object). Overriding both will have no effect, i.e. only Encoder.encodeImpl(Object, Object, EncoderContext) will be called.

Overrides:
encodeImpl in class Encoder<I,ByteBuffer>
Parameters:
in - the input for this encoder
out - the output for this encoder
context - can be used to do some more encoding after a concatenated encoder finished
See Also:
Encoder.encodeImpl(Object, Object)


Copyright © 2019. All rights reserved.