Format buffers
This commit is contained in:
parent
bb855a6e27
commit
5a10da543d
@ -24,6 +24,7 @@ import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HexFormat;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
@ -37,6 +38,7 @@ import org.jetbrains.annotations.VisibleForTesting;
|
||||
|
||||
class ByteListBuf extends ByteArrayList implements Buf {
|
||||
|
||||
private static final HexFormat HEX_FORMAT = HexFormat.of().withUpperCase();
|
||||
private static final String IMMUTABLE_ERROR = "The buffer is immutable";
|
||||
private static final VariableLengthLexiconographicComparator VAR_LENGTH_LEX_COMP = new VariableLengthLexiconographicComparator();
|
||||
|
||||
@ -240,6 +242,11 @@ class ByteListBuf extends ByteArrayList implements Buf {
|
||||
return getString(0, size, charset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return HEX_FORMAT.formatHex(a, 0, size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(int i, int length, Charset charset) {
|
||||
return new String(a, i, length, charset);
|
||||
@ -532,6 +539,11 @@ class ByteListBuf extends ByteArrayList implements Buf {
|
||||
return new String(a, from, size(), charset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return HEX_FORMAT.formatHex(a, from, from + size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(int i, int length, Charset charset) {
|
||||
checkFromIndexSize(i, length, to - from);
|
||||
|
Loading…
Reference in New Issue
Block a user