public class VInt8IntEncoder extends IntEncoder
IntEncoder
which implements variable length encoding. A number is
encoded as follows:
SimpleIntEncoder
or write your own version of variable length
encoding, which can better handle negative values.out
Constructor and Description |
---|
VInt8IntEncoder() |
Modifier and Type | Method and Description |
---|---|
IntDecoder |
createMatchingDecoder()
Returns an
IntDecoder which matches this encoder. |
void |
encode(int value)
Encodes an integer to the output stream given in
reInit |
String |
toString() |
close, reInit
public void encode(int value) throws IOException
IntEncoder
reInit
encode
in class IntEncoder
IOException
public IntDecoder createMatchingDecoder()
IntEncoder
IntDecoder
which matches this encoder. Every encoder
must return an IntDecoder
and null
is not a valid
value. If an encoder is just a filter, it should at least return its
wrapped encoder's matching decoder.
NOTE: this method should create a new instance of the matching decoder and leave the instance sharing to the caller. Returning the same instance over and over is risky because encoders and decoders are not thread safe.
createMatchingDecoder
in class IntEncoder