public class DNSInput extends Object
Constructor and Description |
---|
DNSInput(byte[] input)
Creates a new DNSInput
|
DNSInput(ByteBuffer byteBuffer)
Creates a new DNSInput from the given
ByteBuffer |
Modifier and Type | Method and Description |
---|---|
void |
clearActive()
Clears the active region of the string.
|
int |
current()
Returns the current position.
|
void |
jump(int index)
Resets the current position of the input stream to the specified index, and clears the active
region.
|
byte[] |
readByteArray()
Reads a byte array consisting of the remainder of the stream (or the active region, if one is
set.
|
void |
readByteArray(byte[] b,
int off,
int len)
Reads a byte array of a specified length from the stream into an existing array.
|
byte[] |
readByteArray(int len)
Reads a byte array of a specified length from the stream.
|
byte[] |
readCountedString()
Reads a counted string from the stream.
|
int |
readU16()
Reads an unsigned 16 bit value from the stream, as an int.
|
long |
readU32()
Reads an unsigned 32 bit value from the stream, as a long.
|
int |
readU8()
Reads an unsigned 8 bit value from the stream, as an int.
|
int |
remaining()
Returns the number of bytes that can be read from this stream before reaching the end.
|
void |
restore()
Restores the input stream to its state before the call to
save() . |
void |
restoreActive(int pos)
Restores the previously set active region.
|
void |
save()
Saves the current state of the input stream.
|
int |
saveActive()
Returns the position of the end of the current active region.
|
void |
setActive(int len)
Marks the following bytes in the stream as active.
|
public DNSInput(byte[] input)
input
- The byte array to read frompublic DNSInput(ByteBuffer byteBuffer)
ByteBuffer
byteBuffer
- The ByteBufferpublic int current()
public int remaining()
public void setActive(int len)
len
- The number of bytes in the active region.IllegalArgumentException
- The number of bytes in the active region is longer than the
remainder of the input.public void clearActive()
public int saveActive()
public void restoreActive(int pos)
pos
- The end of the active region.public void jump(int index)
index
- The position to continue parsing at.IllegalArgumentException
- The index is not within the input.public void save()
IllegalArgumentException
- The index is not within the input.public void restore()
save()
.public int readU8() throws WireParseException
WireParseException
- The end of the stream was reached.public int readU16() throws WireParseException
WireParseException
- The end of the stream was reached.public long readU32() throws WireParseException
WireParseException
- The end of the stream was reached.public void readByteArray(byte[] b, int off, int len) throws WireParseException
b
- The array to read into.off
- The offset of the array to start copying data into.len
- The number of bytes to copy.WireParseException
- The end of the stream was reached.public byte[] readByteArray(int len) throws WireParseException
WireParseException
- The end of the stream was reached.public byte[] readByteArray()
public byte[] readCountedString() throws WireParseException
WireParseException
- The end of the stream was reached.Copyright © 2022 dnsjava.org. All rights reserved.