public class ByteArrayScanner extends Object
ByteSequenceReader
, it isolates the latter against legacy type conversions from the
replication protocol.Constructor and Description |
---|
ByteArrayScanner(byte[] bytes)
Builds a ByteArrayScanner object that will read from the supplied byte array.
|
Modifier and Type | Method and Description |
---|---|
Asn1Reader |
getASN1Reader()
Returns a new ASN1Reader that will read bytes from this ByteArrayScanner.
|
boolean |
isEmpty()
Returns whether the scanner has more bytes to consume.
|
boolean |
nextBoolean()
Reads the next boolean.
|
byte |
nextByte()
Reads the next byte.
|
byte[] |
nextByteArray(int length)
Return a new byte array containing the requested number of bytes.
|
CSN |
nextCSN()
Reads the next CSN.
|
CSN |
nextCSNUTF8()
Reads the next CSN that was encoded as a UTF8 string.
|
Dn |
nextDN()
Reads the next DN.
|
int |
nextInt()
Reads the next int.
|
int |
nextIntUTF8()
Reads the next int that was encoded as a UTF8 string.
|
long |
nextLong()
Reads the next long.
|
long |
nextLongUTF8()
Reads the next long that was encoded as a UTF8 string.
|
ServerState |
nextServerStateMustComeLast()
Reads the next ServerState.
|
short |
nextShort()
Reads the next short.
|
String |
nextString()
Reads the next UTF8-encoded string.
|
<T extends Collection<String>> |
nextStrings(T output)
Reads the next UTF8-encoded strings in the provided collection.
|
byte[] |
remainingBytes()
Return a new byte array containing all remaining bytes in this ByteArrayScanner.
|
byte[] |
remainingBytesZeroTerminated()
Return a new byte array containing all remaining bytes in this ByteArrayScanner bar the last one which is a zero
terminated byte (compatible with legacy code).
|
void |
skipZeroSeparator()
Skips the next byte and verifies it is effectively the zero separator.
|
String |
toString() |
public ByteArrayScanner(byte[] bytes)
bytes
- the byte array input that will be read frompublic boolean nextBoolean() throws DataFormatException
DataFormatException
- if no more data can be read from the inputpublic byte nextByte() throws DataFormatException
DataFormatException
- if no more data can be read from the inputpublic short nextShort() throws DataFormatException
DataFormatException
- if no more data can be read from the inputpublic int nextInt() throws DataFormatException
DataFormatException
- if no more data can be read from the inputpublic long nextLong() throws DataFormatException
DataFormatException
- if no more data can be read from the inputpublic int nextIntUTF8() throws DataFormatException
DataFormatException
- if no more data can be read from the inputpublic long nextLongUTF8() throws DataFormatException
DataFormatException
- if no more data can be read from the inputpublic String nextString() throws DataFormatException
DataFormatException
- if no more data can be read from the inputpublic <T extends Collection<String>> T nextStrings(T output) throws DataFormatException
T
- the collection's concrete typeoutput
- the collection where to add the next UTF8-encoded stringsDataFormatException
- if no more data can be read from the inputpublic CSN nextCSN() throws DataFormatException
DataFormatException
- if CSN was incorrectly encoded or no more data can be read from the inputpublic CSN nextCSNUTF8() throws DataFormatException
DataFormatException
- if legacy CSN was incorrectly encoded or no more data can be read from the inputpublic Dn nextDN() throws DataFormatException
DataFormatException
- if DN was incorrectly encoded or no more data can be read from the inputpublic byte[] remainingBytes()
public byte[] remainingBytesZeroTerminated()
public byte[] nextByteArray(int length)
length
- the number of bytes to be read and copied to the new byte array.public ServerState nextServerStateMustComeLast() throws DataFormatException
Caution: ServerState MUST be the last field (see
ByteArrayBuilder.appendServerStateMustComeLast(ServerState)
javadoc).
Note: the super long method name it is intentional: nobody will want to use it, which is good because nobody should.
DataFormatException
- if ServerState was incorrectly encoded or no more data can be read from the inputByteArrayBuilder.appendServerStateMustComeLast(ServerState)
public void skipZeroSeparator() throws DataFormatException
DataFormatException
- if the next byte is not the zero separator.public Asn1Reader getASN1Reader()
public boolean isEmpty()
Copyright 2010-2020 ForgeRock AS.