org.xbill.DNS
Class DNSOutput

java.lang.Object
  extended by org.xbill.DNS.DNSOutput

public class DNSOutput
extends java.lang.Object

A class for rendering DNS messages.

Author:
Brian Wellington

Constructor Summary
DNSOutput()
          Create a new DNSOutput
DNSOutput(int size)
          Create a new DNSOutput with a specified size.
 
Method Summary
 int current()
          Returns the current position.
 void jump(int index)
          Resets the current position of the output stream to the specified index.
 void restore()
          Restores the input stream to its state before the call to save().
 void save()
          Saves the current state of the output stream.
 byte[] toByteArray()
          Returns a byte array containing the current contents of the stream.
 void writeByteArray(byte[] b)
          Writes a byte array to the stream.
 void writeByteArray(byte[] b, int off, int len)
          Writes a byte array to the stream.
 void writeCountedString(byte[] s)
          Writes a counted string from the stream.
 void writeU16(int val)
          Writes an unsigned 16 bit value to the stream.
 void writeU16At(int val, int where)
          Writes an unsigned 16 bit value to the specified position in the stream.
 void writeU32(long val)
          Writes an unsigned 32 bit value to the stream.
 void writeU8(int val)
          Writes an unsigned 8 bit value to the stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 Detail

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:
java.lang.IllegalArgumentException - The index is not within the output.

save

public void save()
Saves the current state of the output stream.

Throws:
java.lang.IllegalArgumentException - The index is not within the output.

restore

public void restore()
Restores the input stream to its state before the call to save().


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 written
where - 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.



Copyright © 2014. All Rights Reserved.