public abstract class IntEncoderFilter extends IntEncoder
IntEncoder
which is served as a filter
on the values to encode. An encoder filter wraps another IntEncoder
which does the actual encoding. This allows for chaining filters and
encoders, such as:
new UniqueValuesIntEncoder(new DGapIntEncoder(new VInt8IntEnoder()));
UniqueValuesIntEncoder
followed by DGapIntEncoder
The default implementation implements close()
by closing the wrapped
encoder and reInit(OutputStream)
by re-initializing the wrapped
encoder.
Modifier and Type | Field and Description |
---|---|
protected IntEncoder |
encoder |
out
Modifier | Constructor and Description |
---|---|
protected |
IntEncoderFilter(IntEncoder encoder) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Instructs the encoder to finish the encoding process.
|
void |
reInit(OutputStream out)
Reinitializes the encoder with the give
OutputStream . |
createMatchingDecoder, encode
protected final IntEncoder encoder
protected IntEncoderFilter(IntEncoder encoder)
public void close() throws IOException
IntEncoder
reInit
. An implementation may do here additional cleanup required to
complete the encoding, such as flushing internal buffers, etc.encode
should be made before first calling reInit
.
NOTE: overriding classes should make sure they either call
super.close()
or close the output stream themselves.
close
in class IntEncoder
IOException
public void reInit(OutputStream out)
IntEncoder
OutputStream
. 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 IntEncoder