Package org.xbill.DNS

Class Master

java.lang.Object
org.xbill.DNS.Master
All Implemented Interfaces:
AutoCloseable

public class Master extends Object implements AutoCloseable
A DNS master file parser. This incrementally parses the file, returning one record at a time. When directives are seen, they are added to the state and used when parsing future records.
  • Field Details

    • origin

      private Name origin
    • file

      private File file
    • last

      private Record last
    • defaultTTL

      private long defaultTTL
    • included

      private Master included
    • st

      private final Tokenizer st
    • currentType

      private int currentType
    • currentDClass

      private int currentDClass
    • currentTTL

      private long currentTTL
    • needSOATTL

      private boolean needSOATTL
    • generator

      private Generator generator
    • generators

      private List<Generator> generators
    • noExpandGenerate

      private boolean noExpandGenerate
    • noExpandIncludes

      private boolean noExpandIncludes
    • includeThrowsException

      private boolean includeThrowsException
  • Constructor Details

    • Master

      Master(File file, Name origin, long initialTTL) throws IOException
      Throws:
      IOException
    • Master

      public Master(String filename, Name origin, long ttl) throws IOException
      Initializes the master file reader and opens the specified master file.
      Parameters:
      filename - The master file.
      origin - The initial origin to append to relative names.
      ttl - The initial default TTL.
      Throws:
      IOException - The master file could not be opened.
    • Master

      public Master(String filename, Name origin) throws IOException
      Initializes the master file reader and opens the specified master file.
      Parameters:
      filename - The master file.
      origin - The initial origin to append to relative names.
      Throws:
      IOException - The master file could not be opened.
    • Master

      public Master(String filename) throws IOException
      Initializes the master file reader and opens the specified master file.
      Parameters:
      filename - The master file.
      Throws:
      IOException - The master file could not be opened.
    • Master

      public Master(InputStream in, Name origin, long ttl)
      Initializes the master file reader.
      Parameters:
      in - The input stream containing a master file.
      origin - The initial origin to append to relative names.
      ttl - The initial default TTL.
    • Master

      public Master(InputStream in, Name origin)
      Initializes the master file reader.
      Parameters:
      in - The input stream containing a master file.
      origin - The initial origin to append to relative names.
    • Master

      public Master(InputStream in)
      Initializes the master file reader.
      Parameters:
      in - The input stream containing a master file.
  • Method Details

    • parseName

      private Name parseName(String s, Name origin) throws TextParseException
      Throws:
      TextParseException
    • parseTTLClassAndType

      private void parseTTLClassAndType() throws IOException
      Throws:
      IOException
    • parseUInt32

      private long parseUInt32(String s)
    • startGenerate

      private void startGenerate() throws IOException
      Throws:
      IOException
    • endGenerate

      private void endGenerate() throws IOException
      Throws:
      IOException
    • nextGenerated

      private Record nextGenerated() throws IOException
      Throws:
      IOException
    • nextRecordInternal

      private Record nextRecordInternal() throws IOException
      Returns the next record in the master file. This will process any directives before the next record.
      Returns:
      The next record.
      Throws:
      IOException - The master file could not be read, or was syntactically invalid.
    • nextRecord

      public Record nextRecord() throws IOException
      Returns the next record in the master file. This will process any directives before the next record.
      Returns:
      The next record.
      Throws:
      IOException - The master file could not be read, or was syntactically invalid.
    • disableIncludes

      public void disableIncludes()
      Disable processing of $INCLUDE directives. When disabled, $INCLUDE statements will not be processed. Depending on the contents of the file that would have been included, this may cause the zone to be invalid. (e.g. if there is no SOA or NS at the apex)
    • disableIncludes

      public void disableIncludes(boolean strict)
      Disable processing of $INCLUDE directives. When disabled, $INCUDE statements will not be processed. Depending on the contents of the file that would have been included, this may cause the zone to be invalid. (e.g. if there's no SOA or NS at the apex)
      Parameters:
      strict - If true, an exception will be thrown if $INCLUDE is encountered.
    • expandGenerate

      public void expandGenerate(boolean wantExpand)
      Specifies whether $GENERATE statements should be expanded. Whether expanded or not, the specifications for generated records are available by calling generators. This must be called before a $GENERATE statement is seen during iteration to have an effect.
    • generators

      public Iterator<Generator> generators()
      Returns an iterator over the generators specified in the master file; that is, the parsed contents of $GENERATE statements.
      See Also:
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable