public final class UniqueValuesIntEncoder extends IntEncoderFilter
IntEncoderFilter which ensures only unique values are encoded. The
implementation assumes the values given to encode(int) are sorted.
If this is not the case, you can chain this encoder with
SortingIntEncoder.encoderout| Constructor and Description |
|---|
UniqueValuesIntEncoder(IntEncoder encoder)
Constructs a new instance with the given encoder.
|
| 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 |
void |
reInit(OutputStream out)
Reinitializes the encoder with the give
OutputStream. |
String |
toString() |
closepublic UniqueValuesIntEncoder(IntEncoder encoder)
public void encode(int value)
throws IOException
IntEncoderreInitencode in class IntEncoderIOExceptionpublic IntDecoder createMatchingDecoder()
IntEncoderIntDecoder 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 IntEncoderpublic void reInit(OutputStream out)
IntEncoderOutputStream. For
re-usability it can be changed without the need to reconstruct a new
object.
NOTE: after calling IntEncoder.close(), one must call
this method even if the output stream itself hasn't changed. An example
case is that the output stream wraps a byte[], and the output stream itself
is reset, but its instance hasn't changed. Some implementations of
IntEncoder may write some metadata about themselves to the output
stream, and therefore it is imperative that one calls this method before
encoding any data.
reInit in class IntEncoderFilter