Interface Config.Key

All Superinterfaces:
Comparable<Config.Key>
All Known Subinterfaces:
Config.Key
Enclosing interface:
Config

public static interface Config.Key extends Comparable<Config.Key>
Object represents fully-qualified key of config node.

Fully-qualified key is list of key tokens separated by . (dot character). Depending on context the key token is evaluated one by one:

  • in Type#OBJECT node the token represents a name of object member;
  • in Type#LIST node the token represents an zero-based index of list element, an unsigned base-10 integer value, leading zeros are not allowed.

The ABNF syntax of config key is:


 config-key = *1( key-token *( "." key-token ) )
  key-token = *( unescaped / escaped )
  unescaped = %x00-2D / %x2F-7D / %x7F-10FFFF
            ; %x2E ('.') and %x7E ('~') are excluded from 'unescaped'
    escaped = "~" ( "0" / "1" )
            ; representing '~' and '.', respectively
 
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Create a child key to the current key.
    static String
    Escape '~' to ~0 and '.' to ~1 in specified name.
    boolean
    Returns true in case the key represents root config node, otherwise it returns false.
    Returns the name of Config node.
    Returns instance of Key that represents key of parent config node.
    Returns formatted fully-qualified key.
    static String
    unescapeName(String escapedName)
    Unescape ~0 to '~' and ~1 to '.' in specified escaped name.

    Methods inherited from interface java.lang.Comparable

    compareTo
  • Method Details

    • escapeName

      static String escapeName(String name)
      Escape '~' to ~0 and '.' to ~1 in specified name.
      Parameters:
      name - name to be escaped
      Returns:
      escaped name
    • unescapeName

      static String unescapeName(String escapedName)
      Unescape ~0 to '~' and ~1 to '.' in specified escaped name.
      Parameters:
      escapedName - escaped name
      Returns:
      unescaped name
    • parent

      Config.Key parent() throws ConfigException
      Returns instance of Key that represents key of parent config node.

      If the key represents root config node it throws an exception.

      Returns:
      key that represents key of parent config node.
      Throws:
      IllegalStateException - in case you attempt to call this method on a root node
      ConfigException - if not defined
      See Also:
    • isRoot

      boolean isRoot()
      Returns true in case the key represents root config node, otherwise it returns false.
      Returns:
      true in case the key represents root node, otherwise false.
      Throws:
      ConfigException - if not defined
      See Also:
    • name

      String name()
      Returns the name of Config node.

      The name of a node is the last token in fully-qualified key. Depending on context the name is evaluated one by one:

      • in Type#OBJECT} node the name represents a name of object member;
      • in Type#LIST} node the name represents an zero-based index of list element, an unsigned base-10 integer value, leading zeros are not allowed.
      Returns:
      name of config node
      See Also:
    • toString

      String toString()
      Returns formatted fully-qualified key.
      Overrides:
      toString in class Object
      Returns:
      formatted fully-qualified key.
    • child

      Config.Key child(Config.Key key)
      Create a child key to the current key.
      Parameters:
      key - child key (relative to current key)
      Returns:
      a new resolved key
      Throws:
      ConfigException - if not defined