java.lang.Object
org.minidns.edns.EdnsOption
Direct Known Subclasses:
Nsid, UnknownEdnsOption

public abstract class EdnsOptionextends Object
Abstract base class for EDNS options.
  • Field Details

    • optionCode

      public final int optionCode
      The EDNS option code.
    • optionLength

      public final int optionLength
      The length of the option data.
    • optionData

      protected final byte[] optionData
      The raw option data.
    • toStringCache

      private volatile String toStringCache
      The rendered form, computed once and kept.
    • terminalOutputCache

      private String terminalOutputCache
      The terminal-rendered form, computed once and kept.
  • Constructor Details

    • EdnsOption

      protected EdnsOption(int optionCode, byte[] optionData)
      Creates a new EDNS option with the specified option code and data.
      Parameters:
      optionCode - the option code
      optionData - the option data
    • EdnsOption

      protected EdnsOption(byte[] optionData)
      Build an option whose code is taken from the subclass's option code.
      Parameters:
      optionData - the raw option payload; its length becomes the option length
  • Method Details

    • writeToDos

      public final void writeToDos(DataOutputStream dos) throws IOException
      Writes this EDNS option to the specified data output stream.
      Parameters:
      dos - the data output stream to write to
      Throws:
      IOException - if an I/O error occurs
    • getOptionCode

      public abstract Edns.OptionCode getOptionCode()
      Returns the option code for this EDNS option.
      Returns:
      the option code
    • toString

      public final String toString()
      Returns the cached string form, computing it from toStringInternal() on first use.
      Overrides:
      toString in class Object
      Returns:
      the string form of this option
    • toStringInternal

      protected abstract CharSequence toStringInternal()
      Returns the string representation of this EDNS option.
      Returns:
      the string representation
    • asTerminalOutput

      public final String asTerminalOutput()
      Returns the terminal output representation of this EDNS option.
      Returns:
      the terminal output representation
    • asTerminalOutputInternal

      protected abstract CharSequence asTerminalOutputInternal()
      Returns the terminal output representation of this EDNS option.
      Returns:
      the terminal output representation
    • parse

      public static EdnsOption parse(int intOptionCode, byte[] optionData)
      Parses an EDNS option from the specified option code and data.
      Parameters:
      intOptionCode - the option code as an integer
      optionData - the option data
      Returns:
      the parsed EDNS option