Class CreepIntEncoder


public class CreepIntEncoder
extends Encoder

Encoder for STEP int types that uses a variable size encoding.

Values are encoded one byte at a time, using 7 bits for data and marking the high bit if more bytes should be read. The encoding is thus pseudo-LITTLE endian (least significant -> most significant), using 7 bit bytes.

The maximum number of bytes used by this encoding is 10, in signed mode: 9 (=63/7) for the 63 low bits plus one more to sign extend.

See Also:
StepInt, IntEncoder

Constructor Summary
CreepIntEncoder(String name, boolean unsigned, EncoderFactory factory)
          Create a new encoder for STEP int types.
Method Summary
 StepObject decode(DecodeContext context)
          Decode a STEP int value.
 void dump(int level)
 void encode(StepObject o, EncodeContext context)
          Encode the given STEP int value.
Methods inherited from class step.encoding.Encoder
eventMessage, getFactory, getName, indent, makeFieldName
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public CreepIntEncoder(String name,
                       boolean unsigned,
                       EncoderFactory factory)
Create a new encoder for STEP int types.

name - the name for this encoder.
unsigned - true if encoded/decoded values are always >= 0
factory - the EncoderFactory used to create this encoder
Method Detail


public void encode(StepObject o,
                   EncodeContext context)
            throws EncoderException,
Encode the given STEP int value.

Specified by:
encode in class Encoder
EncoderException - if
  • the value was not a StepInt.
  • a negative value was passed while the "unsigned" option was set.
IOException - if the encode operation encountered an I/O failure.


public StepObject decode(DecodeContext context)
                  throws EncoderException,
Decode a STEP int value.

Specified by:
decode in class Encoder
IOException - if the decode operation encountered an I/O failure.
EncoderException - if the decode operation encountered an error.


public void dump(int level)
Specified by:
dump in class Encoder