step.encoding
Class OffsetIntStrategy

java.lang.Object
  |
  +--step.encoding.Encoder
        |
        +--step.encoding.Strategy
              |
              +--step.encoding.OffsetIntStrategy

public class OffsetIntStrategy
extends Strategy

Instead of transmitting the absolute (integer) value, transmit the offset from a fixed base value.

NOTE: The same (base) encoder is used for the offset value. Thus, if the base values have the "unsigned" property, so must the offset values.

Algorithm:

  -> current - base
 
Credit: Chilimbi, Jones, Zorn (HATF/Meta-TF)

See Also:
StepInt, WindowIntStrategy

Field Summary
static String STRATEGY_NAME
           
 
Fields inherited from class step.encoding.Strategy
_baseEncoder
 
Constructor Summary
OffsetIntStrategy(Encoder baseEncoder)
          Create a new "offset" strategy.
OffsetIntStrategy(Encoder baseEncoder, StepInt base)
          Create a new "offset" strategy.
 
Method Summary
 StepObject decode(DecodeContext context)
          Decode an offset value.
 void dump(int level)
           
 void encode(StepObject o, EncodeContext context)
          Encode an offset value.
 
Methods inherited from class step.encoding.Strategy
baseDecode, baseEncode, eventMessage
 
Methods inherited from class step.encoding.Encoder
getFactory, getName, indent, makeFieldName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STRATEGY_NAME

public static final String STRATEGY_NAME
See Also:
Constant Field Values
Constructor Detail

OffsetIntStrategy

public OffsetIntStrategy(Encoder baseEncoder)
Create a new "offset" strategy. The first value is used as the base value.

Parameters:
baseEncoder - the encoder to use for the inital value

OffsetIntStrategy

public OffsetIntStrategy(Encoder baseEncoder,
                         StepInt base)
Create a new "offset" strategy.

Parameters:
baseEncoder - the base encoder, only used for identification
base - the base value to subtract from input values.
Method Detail

encode

public void encode(StepObject o,
                   EncodeContext context)
            throws EncoderException,
                   IOException
Encode an offset value.

Specified by:
encode in class Encoder
Throws:
EncoderException - if the value is not a StepInt.
IOException - if the encode operation encountered an I/O failure.

decode

public StepObject decode(DecodeContext context)
                  throws EncoderException,
                         IOException
Decode an offset value.

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

dump

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