|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.util.encoding.IntEncoder org.apache.lucene.util.encoding.IntEncoderFilter org.apache.lucene.util.encoding.SortingIntEncoder
public class SortingIntEncoder
An IntEncoderFilter
which sorts the values to encode in ascending
order before encoding them. Encoding therefore happens upon calling
close()
. Since this encoder is usually chained with another encoder
that relies on sorted values, it does not offer a default constructor.
Field Summary |
---|
Fields inherited from class org.apache.lucene.util.encoding.IntEncoderFilter |
---|
encoder |
Fields inherited from class org.apache.lucene.util.encoding.IntEncoder |
---|
out |
Constructor Summary | |
---|---|
SortingIntEncoder(IntEncoder encoder)
Initializes with the given encoder. |
Method Summary | |
---|---|
void |
close()
Instructs the encoder to finish the encoding process. |
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()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SortingIntEncoder(IntEncoder encoder)
Method Detail |
---|
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 IntEncoderFilter
IOException
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
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 IntEncoderFilter
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |