public class BigEndianAscendingWordSerializer extends Object implements IWordSerializer
[31, 1, 5]
. In big-endian binary format, the values are
[0b11111, 0b00001, 0b00101]
. We use 15 of 16 bits in two bytes
and pad the last (lowest) bit of the last byte with a zero:
[0b11111000, 0b01001010] = [0xF8, 0x4A]
.Constructor and Description |
---|
BigEndianAscendingWordSerializer(int wordLength,
int wordCount,
int bytePadding) |
Modifier and Type | Method and Description |
---|---|
byte[] |
getBytes()
Returns the backing array of
byte s that contain the serialized
words. |
void |
writeWord(long word)
Writes the word to the backing array.
|
public BigEndianAscendingWordSerializer(int wordLength, int wordCount, int bytePadding)
wordLength
- the length in bits of the words to be serialized. Must
be greater than or equal to 1 and less than or equal to 64.wordCount
- the number of words to be serialized. Must be greater than
or equal to zero.bytePadding
- the number of leading bytes that should pad the
serialized words. Must be greater than or equal to zero.public void writeWord(long word)
IWordSerializer
writeWord
in interface IWordSerializer
word
- the word to write.public byte[] getBytes()
IWordSerializer
byte
s that contain the serialized
words.getBytes
in interface IWordSerializer
byte[]
.Copyright © 2016. All rights reserved.