Class ResourceRecord

java.lang.Object
filius.software.dns.ResourceRecord

public class ResourceRecord extends Object
Resource record format
The answer, authority, and additional sections all share the same format: a variable number of resource records, where the number of records is specified in the corresponding count field in the header. Each resource record has the following format: ...
  1. NAME a domain name to which this resource record pertains.
  2. TYPE two octets containing one of the RR type codes. This field specifies the meaning of the data in the RDATA field.
  3. CLASS two octets which specify the class of the data in the RDATA field.
  4. TTL a 32 bit unsigned integer that specifies the time interval (in seconds) that the resource record may be cached before it should be discarded. Zero values are interpreted to mean that the RR can only be used for the transaction in progress, and should not be cached.
  5. RDLENGTH an unsigned 16 bit integer that specifies the length in octets of the RDATA field.
  6. RDATA a variable length string of octets that describes the resource. The format of this information varies according to the TYPE and CLASS of the resource record. For example, the if the TYPE is A and the CLASS is IN, the RDATA field is a 4 octet ARPA Internet address.
  • Field Details

  • Constructor Details

    • ResourceRecord

      public ResourceRecord(String domainname, String typ, String rdata)
    • ResourceRecord

      public ResourceRecord(String rr)
      Ein Konstruktor, der aus einem String, der durch den Aufruf der Methode toString() erzeugt wurde, wieder einen Resource-Record erstellt.
      Parameters:
      rr - ein String, der durch die Methode toString() erstellt wurde
  • Method Details

    • isValid

      public boolean isValid()
    • toString

      public String toString()
      Diese Methode liefert einen Resource Record als String zurueck. Methode zum Abruf eines Resource Record. Das Rueckgabeformat ist NAME TYPE CLASS TTL RDATA (Bsp. web.de. A IN 3600 217.72.195.42)
      Overrides:
      toString in class Object
    • getDomainname

      public String getDomainname()
      Returns:
      the domainname
    • setDomainname

      public void setDomainname(String domainname)
      Parameters:
      domainname - the domainname to set
    • getRdata

      public String getRdata()
      Returns:
      the rdata
    • setRdata

      public void setRdata(String rdata)
      Parameters:
      rdata - the rdata to set
    • findRecord

      public static ResourceRecord findRecord(String domainname, String typ, List<ResourceRecord> recordList)
      Find the exact matching record for given domain and type.
      Parameters:
      domainname - the domainname to look for in field domainname of the resource record
      typ - one of A, NS, MX
      recordList - the list to search in
      Returns:
      the resource record or null if no applicable record could be found
    • findRecords

      public static List<ResourceRecord> findRecords(String domainname, String typ, List<ResourceRecord> recordList)
      Find the exact matching records for given domain and type.
      Parameters:
      domainname - the domainname to look for in field domainname of the resource record
      typ - one of A, NS, MX
      recordList - the list to search in
      Returns:
      the resource record list, emty if no applicable record could be found
    • findApplicableNSRecord

      public static ResourceRecord findApplicableNSRecord(String domainname, List<ResourceRecord> recordList)
      Find the best matching NS record for the given domain.
      Returns:
      the resource record or null if no applicable record could be found
    • getTtl

      public int getTtl()
      Returns:
      the ttl
    • setTtl

      public void setTtl(int ttl)
      Parameters:
      ttl - the ttl to set
    • getType

      public String getType()
      Returns:
      the type
    • setType

      public void setType(String type)
      Parameters:
      type - the type to set