public abstract class ByteAccumulator extends java.lang.Object implements java.lang.Comparable<ByteAccumulator>
ByteAccumulator takes a (large) byte-string x as input and outputs a byte array
representing f(x) for some function f.
The function f depends on the concrete instantiation of this class. It can be, for example, the identity function
ByteArrayAccumulator.
The input x can be given to the ByteAccumulator in substrings, so if x = x_1 || x_2 (|| denotes concatenation), then
after calling append(x_1) and append(x_2), extractBytes() will output f(x) = f(x_1 || x_2).
Usually, this class will be used in the context of the UniqueByteRepresentable interface.
To that end, it contains some helper methods to make it easier to insert certain x into this.
| Modifier and Type | Field and Description |
|---|---|
static byte |
SEPARATOR |
| Constructor and Description |
|---|
ByteAccumulator() |
| Modifier and Type | Method and Description |
|---|---|
void |
append(byte singleByte)
Appends a single byte to the accumulator.
|
abstract void |
append(byte[] bytes)
Appends bytes to the input x of this accumulator.
|
void |
append(int integer)
Appends the given integer as four bytes to the accumulator.
|
void |
append(java.lang.String str)
Appends the given String encoded as UTF-8 to the accumulator
|
void |
append(UniqueByteRepresentable ubr)
Updates the
ByteAccumulator with bytes from a UniqueByteRepresentable. |
void |
appendAndSeparate(byte[] bytes)
Appends the input and then appends a separator byte.
|
void |
appendAndSeparate(java.lang.String str)
Appends the input and then appends a separator byte.
|
void |
appendPadded(int length,
byte[] bytes)
Pads the bytes with leading zero bytes to the desired length and then appends that to the accumulator.
|
void |
appendSeperator()
Appends a special separator symbol to the accumulator.
|
int |
compareTo(ByteAccumulator byteAccumulator) |
void |
escapeAndAppend(byte[] bytes)
Escapes any occurrence of the separator symbol and appends the escaped string
to the byte accumulator.
|
void |
escapeAndAppend(java.lang.String str)
Escapes any occurrence of the separator symbol and appends the escaped string
to the byte accumulator.
|
void |
escapeAndAppend(UniqueByteRepresentable ubr)
Escapes any occurrence of the separator symbol and appends the escaped string
to the byte accumulator.
|
void |
escapeAndSeparate(byte[] bytes)
Escapes the separator symbol, appends the escaped bytes, then appends a separator symbol.
|
void |
escapeAndSeparate(java.lang.String str)
Escapes the separator symbol in the given string, appends the escaped bytes, then appends a separator symbol.
|
void |
escapeAndSeparate(UniqueByteRepresentable ubr)
Escapes the separator symbol, appends the escaped bytes, then appends a separator symbol.
|
abstract byte[] |
extractBytes()
Extracts f(x) from the accumulator, where x was input by
append() calls. |
public abstract void append(byte[] bytes)
public abstract byte[] extractBytes()
append() calls.public void appendAndSeparate(byte[] bytes)
public void appendAndSeparate(java.lang.String str)
public void escapeAndAppend(byte[] bytes)
public void escapeAndAppend(java.lang.String str)
public void escapeAndAppend(UniqueByteRepresentable ubr)
public void escapeAndSeparate(byte[] bytes)
public void escapeAndSeparate(java.lang.String str)
public void escapeAndSeparate(UniqueByteRepresentable ubr)
public void appendSeperator()
public void appendPadded(int length,
byte[] bytes)
length - the desired length of the appended byte stringbytes - the bytes to updatepublic void append(UniqueByteRepresentable ubr)
ByteAccumulator with bytes from a UniqueByteRepresentable.public void append(byte singleByte)
public void append(int integer)
public void append(java.lang.String str)
public int compareTo(ByteAccumulator byteAccumulator)
compareTo in interface java.lang.Comparable<ByteAccumulator>