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

org.xbill.DNS

## Class Zone

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

- All Implemented Interfaces:
    Serializable

      public class Zone
      extends Object
      implements Serializable

  A DNS Zone. This encapsulates all data related to a Zone, and provides convenient lookup methods.
  Author:
    Brian Wellington
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `PRIMARY` A primary zone
    `static int` | `SECONDARY` A secondary zone

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Zone(Name zone, int dclass, String remote)` Creates a Zone by performing a zone transfer to the specified host.
    `Zone(Name zone, Record[] records)` Creates a Zone from an array of records.
    `Zone(Name zone, String file)` Creates a Zone from the records in the specified master file.
    `Zone(ZoneTransferIn xfrin)` Creates a Zone by doing the specified zone transfer.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addRecord(Record r)` Adds a Record to the Zone
    `void` | `addRRset(RRset rrset)` Adds an RRset to the Zone
    `Iterator` | `AXFR()` Returns an Iterator over the RRsets in the zone that can be used to construct an AXFR response.
    `RRset` | `findExactMatch(Name name, int type)` Looks up Records in the zone, finding exact matches only.
    `SetResponse` | `findRecords(Name name, int type)` Looks up Records in the Zone.
    `int` | `getDClass()` Returns the Zone's class
    `RRset` | `getNS()` Returns the Zone origin's NS records
    `Name` | `getOrigin()` Returns the Zone's origin
    `SOARecord` | `getSOA()` Returns the Zone's SOA record
    `Iterator` | `iterator()` Returns an Iterator over the RRsets in the zone.
    `void` | `removeRecord(Record r)` Removes a record from the Zone
    `String` | `toMasterFile()` Returns the contents of the Zone in master file format.
    `String` | `toString()` Returns the contents of the Zone as a string (in master file format).

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

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

- - ### Field Detail

    - #### PRIMARY

          public static final int PRIMARY

      A primary zone
      See Also:
        Constant Field Values

    - #### SECONDARY

          public static final int SECONDARY

      A secondary zone
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Zone

          public Zone(Name zone,
              String file)
               throws IOException

      Creates a Zone from the records in the specified master file.
      Parameters:
        `zone` - The name of the zone.
        `file` - The master file to read from.
      Throws:
        `IOException`
      See Also:
        `Master`

    - #### Zone

          public Zone(Name zone,
              Record[] records)
               throws IOException

      Creates a Zone from an array of records.
      Parameters:
        `zone` - The name of the zone.
        `records` - The records to add to the zone.
      Throws:
        `IOException`
      See Also:
        `Master`

    - #### Zone

          public Zone(ZoneTransferIn xfrin)
               throws IOException,
                      ZoneTransferException

      Creates a Zone by doing the specified zone transfer.
      Parameters:
        `xfrin` - The incoming zone transfer to execute.
      Throws:
        `IOException`
        `ZoneTransferException`
      See Also:
        `ZoneTransferIn`

    - #### Zone

          public Zone(Name zone,
              int dclass,
              String remote)
               throws IOException,
                      ZoneTransferException

      Creates a Zone by performing a zone transfer to the specified host.
      Throws:
        `IOException`
        `ZoneTransferException`
      See Also:
        `ZoneTransferIn`

  - ### Method Detail

    - #### getOrigin

          public Name getOrigin()

      Returns the Zone's origin

    - #### getNS

          public RRset getNS()

      Returns the Zone origin's NS records

    - #### getSOA

          public SOARecord getSOA()

      Returns the Zone's SOA record

    - #### getDClass

          public int getDClass()

      Returns the Zone's class

    - #### findRecords

          public SetResponse findRecords(Name name,
                                int type)

      Looks up Records in the Zone. This follows CNAMEs and wildcards.
      Parameters:
        `name` - The name to look up
        `type` - The type to look up
      Returns:
        A SetResponse object
      See Also:
        `SetResponse`

    - #### findExactMatch

          public RRset findExactMatch(Name name,
                             int type)

      Looks up Records in the zone, finding exact matches only.
      Parameters:
        `name` - The name to look up
        `type` - The type to look up
      Returns:
        The matching RRset
      See Also:
        `RRset`

    - #### addRRset

          public void addRRset(RRset rrset)

      Adds an RRset to the Zone
      Parameters:
        `rrset` - The RRset to be added
      See Also:
        `RRset`

    - #### addRecord

          public void addRecord(Record r)

      Adds a Record to the Zone
      Parameters:
        `r` - The record to be added
      See Also:
        `Record`

    - #### removeRecord

          public void removeRecord(Record r)

      Removes a record from the Zone
      Parameters:
        `r` - The record to be removed
      See Also:
        `Record`

    - #### iterator

          public Iterator iterator()

      Returns an Iterator over the RRsets in the zone.

    - #### AXFR

          public Iterator AXFR()

      Returns an Iterator over the RRsets in the zone that can be used to construct an AXFR response. This is identical to `iterator()` except that the SOA is returned at the end as well as the beginning.

    - #### toMasterFile

          public String toMasterFile()

      Returns the contents of the Zone in master file format.

    - #### toString

          public String toString()

      Returns the contents of the Zone as a string (in master file format).
      Overrides:
        `toString` in class `Object`