public class IndexNumberDecoder extends Object

Decoder for IndexNumberEncoder. Not thread-safe.

Public Constructor Summary

Public Method Summary

int
decode(boolean descending, byte[] buffer, int offset)
Reads bytes encoding a number from the buffer at the offset, in the order specified by descending, and returns the new offset.
boolean
isResultDouble()
Returns whether the decoded number is representable as a double.
boolean
isResultLong()
Returns whether the decoded number is representable as a long.
void
reset()
Reset the decoder.
double
resultAsDouble()
Returns the decoded number as a double, or throws IllegalArgumentException if not possible.
long
resultAsLong()
Returns the decoded number as a long, or throws IllegalArgumentException if not possible.

Inherited Method Summary

Public Constructors

public IndexNumberDecoder ()

Public Methods

public int decode (boolean descending, byte[] buffer, int offset)

Reads bytes encoding a number from the buffer at the offset, in the order specified by descending, and returns the new offset.

The decoded number is accessible via isResultLong(), resultAsLong(), isResultDouble(), resultAsDouble().

Parameters
descending when true, expect an encoding that orders numbers in descending order
buffer bytes to read
offset index into buffer of first byte to read
Returns
  • number of bytes read from buffer

public boolean isResultDouble ()

Returns whether the decoded number is representable as a double.

public boolean isResultLong ()

Returns whether the decoded number is representable as a long.

public void reset ()

Reset the decoder. Erases the result of the last call to decode(boolean, byte[], int).

public double resultAsDouble ()

Returns the decoded number as a double, or throws IllegalArgumentException if not possible.

public long resultAsLong ()

Returns the decoded number as a long, or throws IllegalArgumentException if not possible.