Package org.xbill.DNS
Class Zone
java.lang.Object
org.xbill.DNS.Zone
- All Implemented Interfaces:
Serializable,Iterable<RRset>
A DNS zone. This encapsulates all data related to a zone, and provides convenient lookup methods.
A zone always contains a
SOARecord and at least one NSRecord.- Author:
- Brian Wellington
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a zone by performing a zone transfer from the specified host.Creates a zone from the records in the specified master file.Creates a zone from an array of records.Zone(ZoneTransferIn xfrin) Creates a zone by doing the specified zone transfer. -
Method Summary
Modifier and TypeMethodDescription<T extends Record>
voidaddRecord(T r) Adds a record to the zone.voidAdds an RRset to the zone.AXFR()Returns an Iterator over theRRsetsin the zone that can be used to construct an AXFR response.findExactMatch(Name name, int type) Looks up Records in the zone, finding exact matches only.findRecords(Name name, int type) Looks up Records in the zone.intReturns the zone'sclass.getNS()Returns the zone origin'sNS records.Returns the zone's origin.getSOA()Returns the zone'sSOA record.iterator()Returns an iterator over theRRsetsin the zone.voidRemoves a record from the zone.voidremoveRRset(Name name, int type) Removes an RRset from the zone.Returns the contents of the zone in master file format.toString()Returns the contents of the zone as a string.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
PRIMARY
public static final int PRIMARYA primary zone.- See Also:
-
SECONDARY
public static final int SECONDARYA secondary zone.- See Also:
-
-
Constructor Details
-
Zone
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:
IllegalArgumentException- ifzoneorfileisnull.IOException- if the zone file does not contain aSOARecordor noNSRecords.- See Also:
-
Zone
Creates a zone from an array of records.- Parameters:
zone- The name of the zone.records- The records to add to the zone.- Throws:
IllegalArgumentException- ifzoneorrecordsisnull.IOException- if the records do not contain aSOARecordor noNSRecords.- See Also:
-
Zone
Creates a zone by doing the specified zone transfer.- Parameters:
xfrin- The incoming zone transfer to execute.- Throws:
IllegalArgumentException- ifxfrinisnull.IOException- if the zone does not contain aSOARecordor noNSRecords.ZoneTransferException- See Also:
-
Zone
Creates a zone by performing a zone transfer from the specified host. This uses the default port and noTSIG. UseZone(ZoneTransferIn)for more control.- Parameters:
zone- The zone to transfer.dclass- TheDClassof the zone to transfer.remote- The remote host to transfer from.- Throws:
IllegalArgumentException- ifzoneorremoteisnull.IOException- if the zone does not contain aSOARecordor noNSRecords.InvalidDClassException- ifdclassis not a validDClass.ZoneTransferException- See Also:
-
-
Method Details
-
getDClass
public int getDClass()Returns the zone'sclass. -
getNS
Returns the zone origin'sNS records. -
iterator
Returns an iterator over theRRsetsin the zone. -
AXFR
Returns an Iterator over theRRsetsin the zone that can be used to construct an AXFR response. This is identical toiterator()except that the SOA is returned at the end as well as the beginning. -
addRecord
Adds a record to the zone. If there is an existingRRsetof the sameNameandType, the record is added to this set.- Parameters:
r- The record to add.- Throws:
IllegalArgumentException- ifnameisnullor if the rrset name does not match the zone origin.
-
removeRecord
Removes a record from the zone.- Parameters:
r- The record to remove.- Throws:
IllegalArgumentException- ifrisnull, if the record to remove is theSOARecordor the lastNSRecord.
-
addRRset
Adds an RRset to the zone.- Parameters:
rrset- The RRset to add.- Throws:
IllegalArgumentException- ifrrsetisnullor if the rrset name is not asubdomainof the zone origin (or, in case of a SOA, is not equal to the zone origin).- See Also:
-
removeRRset
Removes an RRset from the zone.- Parameters:
name- The name to remove.type- The type to remove.- Throws:
IllegalArgumentException- ifnameisnull.InvalidTypeException- if the specifiedtypeis invalid orType.SOAorType.NS.- Since:
- 3.6
- See Also:
-
findExactMatch
Looks up Records in the zone, finding exact matches only.- Parameters:
name- The name to look uptype- The type to look up- Returns:
- The matching RRset or
nullif no exact match is found. - Throws:
IllegalArgumentException- ifnameisnull.InvalidTypeException- if the specifiedtypeis invalid.- See Also:
-
findRecords
Looks up Records in the zone. The answer can be aCNAMEinstead of the actual requested type and wildcards are expanded.- Parameters:
name- The name to look uptype- The type to look up- Returns:
- A SetResponse object
- Throws:
IllegalArgumentException- ifnameisnull.InvalidTypeException- if the specifiedtypeis invalid.- See Also:
-
toMasterFile
Returns the contents of the zone in master file format.- See Also:
-
toString
Returns the contents of the zone as a string. -
getOrigin
Returns the zone's origin. -
getSOA
Returns the zone'sSOA record.
-