Package org.xbill.DNS

Class DNSOutput

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

public class DNSOutput extends Object
A class for rendering DNS messages.
Author:
Brian Wellington
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new DNSOutput
    DNSOutput(int size)
    Create a new DNSOutput with a specified size.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the current position.
    void
    jump(int index)
    Resets the current position of the output stream to the specified index.
    void
    Restores the input stream to its state before the call to save().
    void
    Saves the current state of the output stream.
    byte[]
    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
    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 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 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.