Header (dnsjava documentation)
Date: 2013-04-10

org.xbill.DNS

## Class Header

- java.lang.Object
- - org.xbill.DNS.Header

- All Implemented Interfaces:
    Cloneable

      public class Header
      extends Object
      implements Cloneable

  A DNS message header
  Author:
    Brian Wellington
  See Also:
    `Message`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `LENGTH` The length of a DNS Header in wire format.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Header()` Create a new empty header with a random message id
    `Header(byte[] b)` Creates a new Header from its DNS wire format representation
    `Header(int id)` Create a new empty header.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Object` | `clone()`
    `int` | `getCount(int field)` Retrieves the record count for the given section
    `boolean` | `getFlag(int bit)` Retrieves a flag
    `int` | `getID()` Retrieves the message ID
    `int` | `getOpcode()` Retrieves the mesasge's opcode
    `int` | `getRcode()` Retrieves the mesasge's rcode
    `String` | `printFlags()` Converts the header's flags into a String
    `void` | `setFlag(int bit)` Sets a flag to the supplied value
    `void` | `setID(int id)` Sets the message ID
    `void` | `setOpcode(int value)` Sets the message's opcode
    `void` | `setRcode(int value)` Sets the message's rcode
    `String` | `toString()` Converts the header into a String
    `byte[]` | `toWire()`
    `void` | `unsetFlag(int bit)` Sets a flag to the supplied value

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### LENGTH

          public static final int LENGTH

      The length of a DNS Header in wire format.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Header

          public Header(int id)

      Create a new empty header.
      Parameters:
        `id` - The message id

    - #### Header

          public Header()

      Create a new empty header with a random message id

    - #### Header

          public Header(byte[] b)
                 throws IOException

      Creates a new Header from its DNS wire format representation
      Parameters:
        `b` - A byte array containing the DNS Header.
      Throws:
        `IOException`

  - ### Method Detail

    - #### toWire

          public byte[] toWire()

    - #### setFlag

          public void setFlag(int bit)

      Sets a flag to the supplied value
      See Also:
        `Flags`

    - #### unsetFlag

          public void unsetFlag(int bit)

      Sets a flag to the supplied value
      See Also:
        `Flags`

    - #### getFlag

          public boolean getFlag(int bit)

      Retrieves a flag
      See Also:
        `Flags`

    - #### getID

          public int getID()

      Retrieves the message ID

    - #### setID

          public void setID(int id)

      Sets the message ID

    - #### setRcode

          public void setRcode(int value)

      Sets the message's rcode
      See Also:
        `Rcode`

    - #### getRcode

          public int getRcode()

      Retrieves the mesasge's rcode
      See Also:
        `Rcode`

    - #### setOpcode

          public void setOpcode(int value)

      Sets the message's opcode
      See Also:
        `Opcode`

    - #### getOpcode

          public int getOpcode()

      Retrieves the mesasge's opcode
      See Also:
        `Opcode`

    - #### getCount

          public int getCount(int field)

      Retrieves the record count for the given section
      See Also:
        `Section`

    - #### printFlags

          public String printFlags()

      Converts the header's flags into a String

    - #### toString

          public String toString()

      Converts the header into a String
      Overrides:
        `toString` in class `Object`

    - #### clone

          public Object clone()

      Overrides:
        `clone` in class `Object`