Package org.xbill.DNS
Class DNSOutput
java.lang.Object
org.xbill.DNS.DNSOutput
A class for rendering DNS messages.
- Author:
- Brian Wellington
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcurrent()Returns the current position.voidjump(int index) Resets the current position of the output stream to the specified index.voidrestore()Restores the input stream to its state before the call tosave().voidsave()Saves the current state of the output stream.byte[]Returns a byte array containing the current contents of the stream.voidwriteByteArray(byte[] b) Writes a byte array to the stream.voidwriteByteArray(byte[] b, int off, int len) Writes a byte array to the stream.voidwriteCountedString(byte[] s) Writes a counted string from the stream.voidwriteU16(int val) Writes an unsigned 16 bit value to the stream.voidwriteU16At(int val, int where) Writes an unsigned 16 bit value to the specified position in the stream.voidwriteU32(long val) Writes an unsigned 32 bit value to the stream.voidwriteU8(int val) Writes an unsigned 8 bit value to the stream.
-
Constructor Details
-
DNSOutput
public DNSOutput(int size) Create a new DNSOutput with a specified size.- Parameters:
size- The initial size
-
DNSOutput
public DNSOutput()Create a new DNSOutput
-
-
Method Details
-
current
public int current()Returns the current position. -
jump
public void jump(int index) Resets the current position of the output stream to the specified index.- Parameters:
index- The new current position.- Throws:
IllegalArgumentException- The index is not within the output.
-
save
public void save()Saves the current state of the output stream.- Throws:
IllegalArgumentException- The index is not within the output.
-
restore
public void restore()Restores the input stream to its state before the call tosave(). -
writeU8
public void writeU8(int val) Writes an unsigned 8 bit value to the stream.- Parameters:
val- The value to be written
-
writeU16
public void writeU16(int val) Writes an unsigned 16 bit value to the stream.- Parameters:
val- The value to be written
-
writeU16At
public void writeU16At(int val, int where) Writes an unsigned 16 bit value to the specified position in the stream.- Parameters:
val- The value to be writtenwhere- The position to write the value.
-
writeU32
public void writeU32(long val) Writes an unsigned 32 bit value to the stream.- Parameters:
val- The value to be written
-
writeByteArray
public void writeByteArray(byte[] b, int off, int len) Writes a byte array to the stream.- Parameters:
b- The array to write.off- The offset of the array to start copying data from.len- The number of bytes to write.
-
writeByteArray
public void writeByteArray(byte[] b) Writes a byte array to the stream.- Parameters:
b- The array to write.
-
writeCountedString
public void writeCountedString(byte[] s) Writes a counted string from the stream. A counted string is a one byte value indicating string length, followed by bytes of data.- Parameters:
s- The string to write.
-
toByteArray
public byte[] toByteArray()Returns a byte array containing the current contents of the stream.
-