Package org.xbill.DNS

Class Mnemonic

java.lang.Object
org.xbill.DNS.Mnemonic
Direct Known Subclasses:
DClass.DClassMnemonic, SVCBBase.ParameterMnemonic, Type.TypeMnemonic

class Mnemonic extends Object
A utility class for converting between numeric codes and mnemonics for those codes. Mnemonics are case insensitive.
  • Field Details

  • Constructor Details

    • Mnemonic

      public Mnemonic(String description, int wordcase)
      Creates a new Mnemonic table.
      Parameters:
      description - A short description of the mnemonic to use when
      wordcase - Whether to convert strings into uppercase, lowercase, or leave them unchanged. throwing exceptions.
  • Method Details

    • setMaximum

      public void setMaximum(int max)
      Sets the maximum numeric value
    • setPrefix

      public void setPrefix(String prefix)
      Sets the prefix to use when converting to and from values that don't have mnemonics.
    • setNumericAllowed

      public void setNumericAllowed(boolean numeric)
      Sets whether numeric values stored in strings are acceptable.
    • check

      public void check(int val)
      Checks that a numeric value is within the range [0..max]
    • sanitize

      private String sanitize(String str)
    • parseNumeric

      private int parseNumeric(String s)
    • add

      public void add(int val, String str)
      Defines the text representation of a numeric value.
      Parameters:
      val - The numeric value
      str - The text string
    • remove

      public void remove(int val)
      Removes both the numeric value and its text representation, including all aliases.
      Parameters:
      val - The numeric value
      Since:
      3.1
    • addAlias

      public void addAlias(int val, String str)
      Defines an additional text representation of a numeric value. This will be used by getValue(), but not getText().
      Parameters:
      val - The numeric value
      str - The text string
    • removeAlias

      public void removeAlias(String str)
      Removes an additional text representation of a numeric value.
      Parameters:
      str - The text string
      Since:
      3.1
    • addAll

      public void addAll(Mnemonic source)
      Copies all mnemonics from one table into another.
      Parameters:
      source - The source mnemonic
      Throws:
      IllegalArgumentException - The wordcases of the Mnemonics do not match.
    • getText

      public String getText(int val)
      Gets the text mnemonic corresponding to a numeric value.
      Parameters:
      val - The numeric value
      Returns:
      The corresponding text mnemonic.
    • getValue

      public int getValue(String str)
      Gets the numeric value corresponding to a text mnemonic.
      Parameters:
      str - The text mnemonic
      Returns:
      The corresponding numeric value, or -1 if there is none