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
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
STRATEGY_NAME
public static final String STRATEGY_NAME
- See Also:
- Constant Field Values
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.
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