Class ASTNode

java.lang.Object
org.openhab.core.voice.text.ASTNode

public class ASTNode extends Object
Abstract syntax tree node. Result of parsing an expression.
Author:
Tilman Kamp - Initial contribution
  • Constructor Details

    • ASTNode

      public ASTNode()
    • ASTNode

      public ASTNode(ASTNode[] children, TokenList remainingTokens)
      Constructs a new AST node.
      Parameters:
      children - the node's children
      remainingTokens - remaining token list starting with the first token that was not covered/consumed
  • Method Details

    • findNode

      public ASTNode findNode(String name)
      Breadth searching this (sub-) tree/node for a node with the given name.
      Parameters:
      name - the name that's used for looking up the tree
      Returns:
      first node with the given name or null, if none was found
    • getValueAsStringArray

      public String[] getValueAsStringArray()
      Returns:
      the value of this node as String[]
    • getValueAsString

      public String getValueAsString()
      Returns:
      the value of this node as String.
    • findValueAsStringArray

      public String[] findValueAsStringArray(String name)
      Breadth searches this (sub-) tree/node for a node with the given name and returning its value as a String[].
      Parameters:
      name - the name of the named node to be found
      Returns:
      the value of the resulting node as String[] or null if not found
    • findValueAsString

      public String findValueAsString(String name)
      Breadth searches this (sub-) tree/node for a node with the given name and returning its value as a String .
      Parameters:
      name - the name of the named node to be found
      Returns:
      the value of the resulting node as String or null if not found
    • findValue

      public Object findValue(String name, Class<?> cls)
      Breadth searches this (sub-) tree/node for a node with the given name and type and returning its value.
      Parameters:
      name - the name of the named node to be found
      cls - the node's value has to be assignable to a reference of this class to match during search
      Returns:
      the value of the resulting node. Null, if not found or the value does not match cls.
    • findValue

      public Object findValue(String name)
      Breadth searches this (sub-) tree/node for a node with the given name and returning its value.
      Parameters:
      name - the name of the named node to be found
      Returns:
      the value of the resulting node. Null, if not found.
    • isSuccess

      public boolean isSuccess()
      Returns:
      if the node is a valid one (true) or parsing was not successful (false)
    • setSuccess

      public void setSuccess(boolean success)
      Parameters:
      success - if the node is a valid one (true) or parsing was not successful (false)
    • getChildren

      public ASTNode[] getChildren()
      Returns:
      the children
    • setChildren

      public void setChildren(ASTNode[] children)
      Parameters:
      children - the children to set
    • getRemainingTokens

      public TokenList getRemainingTokens()
      Returns:
      the remainingTokens
    • setRemainingTokens

      public void setRemainingTokens(TokenList remainingTokens)
      Parameters:
      remainingTokens - the remainingTokens to set
    • getName

      public String getName()
      Returns:
      the name
    • setName

      public void setName(String name)
      Parameters:
      name - the name to set
    • getValue

      public Object getValue()
      Returns:
      the value
    • setValue

      public void setValue(Object value)
      Parameters:
      value - the value to set
    • getTag

      public Object getTag()
      Returns:
      the tag
    • setTag

      public void setTag(Object tag)
      Parameters:
      tag - the tag to set