step.encoding
Class WindowIntStrategy

java.lang.Object
  |
  +--step.encoding.Encoder
        |
        +--step.encoding.Strategy
              |
              +--step.encoding.RegularValueStrategy
                    |
                    +--step.encoding.WindowIntStrategy
Direct Known Subclasses:
PWindowIntStrategy

public class WindowIntStrategy
extends RegularValueStrategy

Assume (integer) values are in the neighborhood of a base value, and transmit the offset from the base. Irregular values shift the base of computation.

NOTE: Although values may be more than 4 bytes (i.e. long), their difference must be in the int range. Otherwise, the behavior of this encoder is undefined.

Algorithm:

 delta := current - base
 if |delta| <= threshold
     then -> delta
     else -> meta:IrregularValueEvent, base:=current
 

See Also:
StepInt, OffsetIntStrategy

Field Summary
static String STRATEGY_NAME
           
 
Fields inherited from class step.encoding.RegularValueStrategy
_nextIsRegular
 
Fields inherited from class step.encoding.Strategy
_baseEncoder
 
Constructor Summary
WindowIntStrategy(Encoder baseEncoder, int threshold)
          Create a new "window" strategy.
 
Method Summary
 StepObject decode(DecodeContext context)
          Decode a window value.
 void dump(int level)
           
 void encode(StepObject o, EncodeContext context)
          Encode a window value.
 
Methods inherited from class step.encoding.RegularValueStrategy
setNextIsRegular
 
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

WindowIntStrategy

public WindowIntStrategy(Encoder baseEncoder,
                         int threshold)
Create a new "window" strategy.

Parameters:
baseEncoder - the encoder to use for deviant values.
threshold - the maximum (absolute) difference from the current base to allow.
Throws:
IllegalArgumentException - if the threshold is not >= 0.
Method Detail

encode

public void encode(StepObject o,
                   EncodeContext context)
            throws EncoderException,
                   IOException
Encode a window 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 a window 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