|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--step.encoding.Encoder | +--step.encoding.Strategy | +--step.encoding.RegularValueStrategy | +--step.encoding.IdentifierStrategy
Assume that values derive from a relatively small, fixed distribution. Instead of encoding the full value, use a small integer ID in its place.
NOTE: The ID values are encoded with a CreepIntEncoder
, thus the
strategy is optimized for distributions with < 128 distinct values.
Field Summary | |
static String |
STRATEGY_NAME
|
Fields inherited from class step.encoding.RegularValueStrategy |
_nextIsRegular |
Fields inherited from class step.encoding.Strategy |
_baseEncoder |
Constructor Summary | |
IdentifierStrategy(Encoder baseEncoder)
Create a new "identifier" strategy. |
Method Summary | |
protected void |
add(StepObject value)
Pre-map a value in the expected distribution. |
StepObject |
decode(DecodeContext context)
Decode an ID, map it to a value. |
void |
dump(int level)
|
void |
encode(StepObject o,
EncodeContext context)
Encode a value as an ID. |
protected Object |
idToValue(StepObject id)
Get the current value for this ID. |
protected Object |
valueToId(StepObject value)
Get the current ID for this 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 |
public static final String STRATEGY_NAME
Constructor Detail |
public IdentifierStrategy(Encoder baseEncoder)
baseEncoder
- the encoder to defer to when writing previously unmapped
values.Method Detail |
public void encode(StepObject o, EncodeContext context) throws EncoderException, IOException
encode
in class Encoder
IOException
- if the encode operation encountered an I/O failure.
EncoderException
- if the encode operation encountered an error.public StepObject decode(DecodeContext context) throws EncoderException, IOException
decode
in class Encoder
IOException
- if the decode operation encountered an I/O failure.
EncoderException
- if the decode operation encountered an error.protected Object valueToId(StepObject value)
StepInt
) or
null
if no ID is defined for the value.protected Object idToValue(StepObject id)
null
if no value is defined for the ID.protected void add(StepObject value)
WARNING: This method is provided for bootstrapping purposes. Don't use it unless you understand the consequences.
IllegalArgumentException
- if a mapping already exists for the value.public void dump(int level)
dump
in class Encoder
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |