step.encoding
Class DeltaIntStrategy
java.lang.Object
|
+--step.encoding.Encoder
|
+--step.encoding.Strategy
|
+--step.encoding.RegularValueStrategy
|
+--step.encoding.DeltaIntStrategy
- Direct Known Subclasses:
- PDeltaIntStrategy
- public class DeltaIntStrategy
- extends RegularValueStrategy
Assume that the next (integer) value is relatively close to the last, and
only transmit on the difference from the last value.
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 - last;
if |delta| <= threshold
then -> delta
else -> meta:IrregularValueEvent
, current
Credit: A. Samples (Mache)
- See Also:
StepInt
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
DeltaIntStrategy
public DeltaIntStrategy(Encoder baseEncoder,
int threshold)
- Create a new "delta" strategy.
- Parameters:
baseEncoder
- the encoder to defer to for irregular valuesthreshold
- the maximum (absolute) delta value to encode
- Throws:
IllegalArgumentException
- if the threshold is < 0.
encode
public void encode(StepObject o,
EncodeContext context)
throws EncoderException,
IOException
- Encode an integer 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
- Description copied from class:
Encoder
- Decode a 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