org.apache.commons.jexl3.internal

## Class Debugger

- java.lang.Object
- - org.apache.commons.jexl3.parser.ParserVisitor
  - - org.apache.commons.jexl3.internal.Debugger

- All Implemented Interfaces:
    JexlInfo.Detail
  Direct Known Subclasses:
    TemplateDebugger

      public class Debugger
      extends ParserVisitor
      implements JexlInfo.Detail

  Helps pinpoint the cause of problems in expressions that fail during evaluation.

  It rebuilds an expression string from the tree and the start/end offsets of the cause in that string. This implies that exceptions during evaluation do always carry the node that's causing the error.

  Since:
    2.0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected StringBuilder` | `builder` The builder to compose messages.
    `protected JexlNode` | `cause` The cause of the issue to debug.
    `protected int` | `end` The ending character location offset of the cause in the builder.
    `protected int` | `indent` Perform indentation?.
    `protected int` | `indentLevel` The indentation level.
    `protected static Pattern` | `QUOTED_IDENTIFIER` Checks identifiers that contain space, quote, double-quotes or backspace.
    `protected int` | `start` The starting character location offset of the cause in the builder.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Debugger()` Creates a Debugger.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Object` | `accept(JexlNode node, Object data)` Checks if a child node is the cause to debug & adds its representation to the rebuilt expression.
    `protected Object` | `acceptStatement(JexlNode child, Object data)` Adds a statement node to the rebuilt expression.
    `protected Object` | `additiveNode(JexlNode node, String op, Object data)` Rebuilds an additive expression.
    `protected Object` | `check(JexlNode node, String image, Object data)` Checks if a terminal node is the the cause to debug & adds its representation to the rebuilt expression.
    `String` | `data(JexlNode node)` Rebuilds an expression from a JEXL node.
    `boolean` | `debug(JexlExpression jscript)` Position the debugger on the root of an expression.
    `boolean` | `debug(JexlNode node)` Seeks the location of an error cause (a node) in an expression.
    `boolean` | `debug(JexlNode node, boolean r)` Seeks the location of an error cause (a node) in an expression.
    `boolean` | `debug(JexlScript jscript)` Position the debugger on the root of a script.
    `int` | `end()`
    `protected Object` | `infixChildren(JexlNode node, String infix, boolean paren, Object data)` Checks if the children of a node using infix notation is the cause to debug, adds their representation to the rebuilt expression.
    `protected Object` | `prefixChild(JexlNode node, String prefix, Object data)` Checks if the child of a node using prefix notation is the cause to debug, adds their representation to the rebuilt expression.
    `void` | `setIndentation(int level)` Sets the indentation level.
    `int` | `start()`
    `String` | `toString()`
    `protected Object` | `visit(ASTAddNode node, Object data)`
    `protected Object` | `visit(ASTAndNode node, Object data)`
    `protected Object` | `visit(ASTArguments node, Object data)`
    `protected Object` | `visit(ASTArrayAccess node, Object data)`
    `protected Object` | `visit(ASTArrayLiteral node, Object data)`
    `protected Object` | `visit(ASTAssignment node, Object data)`
    `protected Object` | `visit(ASTBitwiseAndNode node, Object data)`
    `protected Object` | `visit(ASTBitwiseComplNode node, Object data)`
    `protected Object` | `visit(ASTBitwiseOrNode node, Object data)`
    `protected Object` | `visit(ASTBitwiseXorNode node, Object data)`
    `protected Object` | `visit(ASTBlock node, Object data)`
    `protected Object` | `visit(ASTBreak node, Object data)`
    `protected Object` | `visit(ASTConstructorNode node, Object data)`
    `protected Object` | `visit(ASTContinue node, Object data)`
    `protected Object` | `visit(ASTDivNode node, Object data)`
    `protected Object` | `visit(ASTEmptyFunction node, Object data)`
    `protected Object` | `visit(ASTEmptyMethod node, Object data)`
    `protected Object` | `visit(ASTEQNode node, Object data)`
    `protected Object` | `visit(ASTERNode node, Object data)`
    `protected Object` | `visit(ASTEWNode node, Object data)`
    `protected Object` | `visit(ASTExtendedLiteral node, Object data)`
    `protected Object` | `visit(ASTFalseNode node, Object data)`
    `protected Object` | `visit(ASTForeachStatement node, Object data)`
    `protected Object` | `visit(ASTFunctionNode node, Object data)`
    `protected Object` | `visit(ASTGENode node, Object data)`
    `protected Object` | `visit(ASTGTNode node, Object data)`
    `protected Object` | `visit(ASTIdentifierAccess node, Object data)`
    `protected Object` | `visit(ASTIdentifier node, Object data)`
    `protected Object` | `visit(ASTIfStatement node, Object data)`
    `protected Object` | `visit(ASTJexlScript node, Object data)`
    `protected Object` | `visit(ASTJxltLiteral node, Object data)`
    `protected Object` | `visit(ASTLENode node, Object data)`
    `protected Object` | `visit(ASTLTNode node, Object data)`
    `protected Object` | `visit(ASTMapEntry node, Object data)`
    `protected Object` | `visit(ASTMapLiteral node, Object data)`
    `protected Object` | `visit(ASTMethodNode node, Object data)`
    `protected Object` | `visit(ASTModNode node, Object data)`
    `protected Object` | `visit(ASTMulNode node, Object data)`
    `protected Object` | `visit(ASTNENode node, Object data)`
    `protected Object` | `visit(ASTNEWNode node, Object data)`
    `protected Object` | `visit(ASTNotNode node, Object data)`
    `protected Object` | `visit(ASTNRNode node, Object data)`
    `protected Object` | `visit(ASTNSWNode node, Object data)`
    `protected Object` | `visit(ASTNullLiteral node, Object data)`
    `protected Object` | `visit(ASTNumberLiteral node, Object data)`
    `protected Object` | `visit(ASTOrNode node, Object data)`
    `protected Object` | `visit(ASTRangeNode node, Object data)`
    `protected Object` | `visit(ASTReferenceExpression node, Object data)`
    `protected Object` | `visit(ASTReference node, Object data)`
    `protected Object` | `visit(ASTReturnStatement node, Object data)`
    `protected Object` | `visit(ASTSetAddNode node, Object data)`
    `protected Object` | `visit(ASTSetAndNode node, Object data)`
    `protected Object` | `visit(ASTSetDivNode node, Object data)`
    `protected Object` | `visit(ASTSetLiteral node, Object data)`
    `protected Object` | `visit(ASTSetModNode node, Object data)`
    `protected Object` | `visit(ASTSetMultNode node, Object data)`
    `protected Object` | `visit(ASTSetOrNode node, Object data)`
    `protected Object` | `visit(ASTSetSubNode node, Object data)`
    `protected Object` | `visit(ASTSetXorNode node, Object data)`
    `protected Object` | `visit(ASTSizeFunction node, Object data)`
    `protected Object` | `visit(ASTSizeMethod node, Object data)`
    `protected Object` | `visit(ASTStringLiteral node, Object data)`
    `protected Object` | `visit(ASTSubNode node, Object data)`
    `protected Object` | `visit(ASTSWNode node, Object data)`
    `protected Object` | `visit(ASTTernaryNode node, Object data)`
    `protected Object` | `visit(ASTTrueNode node, Object data)`
    `protected Object` | `visit(ASTUnaryMinusNode node, Object data)`
    `protected Object` | `visit(ASTVar node, Object data)`
    `protected Object` | `visit(ASTWhileStatement node, Object data)`
    `protected String` | `visitParameter(String p, Object data)` A pseudo visitor for parameters.

    - ### Methods inherited from class org.apache.commons.jexl3.parser.ParserVisitor

      `visit, visit`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### builder

          protected final StringBuilder builder

      The builder to compose messages.

    - #### cause

          protected JexlNode cause

      The cause of the issue to debug.

    - #### start

          protected int start

      The starting character location offset of the cause in the builder.

    - #### end

          protected int end

      The ending character location offset of the cause in the builder.

    - #### indentLevel

          protected int indentLevel

      The indentation level.

    - #### indent

          protected int indent

      Perform indentation?.

    - #### QUOTED_IDENTIFIER

          protected static final Pattern QUOTED_IDENTIFIER

      Checks identifiers that contain space, quote, double-quotes or backspace.

  - ### Constructor Detail

    - #### Debugger

          public Debugger()

      Creates a Debugger.

  - ### Method Detail

    - #### debug

          public boolean debug(JexlExpression jscript)

      Position the debugger on the root of an expression.
      Parameters:
        `jscript` - the expression
      Returns:
        true if the expression was a `Script` instance, false otherwise

    - #### debug

          public boolean debug(JexlScript jscript)

      Position the debugger on the root of a script.
      Parameters:
        `jscript` - the script
      Returns:
        true if the script was a `Script` instance, false otherwise

    - #### debug

          public boolean debug(JexlNode node)

      Seeks the location of an error cause (a node) in an expression.
      Parameters:
        `node` - the node to debug
      Returns:
        true if the cause was located, false otherwise

    - #### debug

          public boolean debug(JexlNode node,
                      boolean r)

      Seeks the location of an error cause (a node) in an expression.
      Parameters:
        `node` - the node to debug
        `r` - whether we should actively find the root node of the debugged node
      Returns:
        true if the cause was located, false otherwise

    - #### toString

          public String toString()

      Specified by:
        `toString` in interface `JexlInfo.Detail`
      Overrides:
        `toString` in class `Object`
      Returns:
        The rebuilt expression

    - #### data

          public String data(JexlNode node)

      Rebuilds an expression from a JEXL node.
      Parameters:
        `node` - the node to rebuilt from
      Returns:
        the rebuilt expression
      Since:
        3.0

    - #### start

          public int start()

      Specified by:
        `start` in interface `JexlInfo.Detail`
      Returns:
        The starting offset location of the cause in the expression

    - #### end

          public int end()

      Specified by:
        `end` in interface `JexlInfo.Detail`
      Returns:
        The end offset location of the cause in the expression

    - #### setIndentation

          public void setIndentation(int level)

      Sets the indentation level.
      Parameters:
        `level` - the number of spaces for indentation, none if less or equal to zero

    - #### accept

          protected Object accept(JexlNode node,
                      Object data)

      Checks if a child node is the cause to debug & adds its representation to the rebuilt expression.
      Parameters:
        `node` - the child node
        `data` - visitor pattern argument
      Returns:
        visitor pattern value

    - #### acceptStatement

          protected Object acceptStatement(JexlNode child,
                               Object data)

      Adds a statement node to the rebuilt expression.
      Parameters:
        `child` - the child node
        `data` - visitor pattern argument
      Returns:
        visitor pattern value

    - #### check

          protected Object check(JexlNode node,
                     String image,
                     Object data)

      Checks if a terminal node is the the cause to debug & adds its representation to the rebuilt expression.
      Parameters:
        `node` - the child node
        `image` - the child node token image (may be null)
        `data` - visitor pattern argument
      Returns:
        visitor pattern value

    - #### infixChildren

          protected Object infixChildren(JexlNode node,
                             String infix,
                             boolean paren,
                             Object data)

      Checks if the children of a node using infix notation is the cause to debug, adds their representation to the rebuilt expression.
      Parameters:
        `node` - the child node
        `infix` - the child node token
        `paren` - whether the child should be parenthesized
        `data` - visitor pattern argument
      Returns:
        visitor pattern value

    - #### prefixChild

          protected Object prefixChild(JexlNode node,
                           String prefix,
                           Object data)

      Checks if the child of a node using prefix notation is the cause to debug, adds their representation to the rebuilt expression.
      Parameters:
        `node` - the node
        `prefix` - the node token
        `data` - visitor pattern argument
      Returns:
        visitor pattern value

    - #### visit

          protected Object visit(ASTAddNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTSubNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### additiveNode

          protected Object additiveNode(JexlNode node,
                            String op,
                            Object data)

      Rebuilds an additive expression.
      Parameters:
        `node` - the node
        `op` - the operator
        `data` - visitor pattern argument
      Returns:
        visitor pattern value

    - #### visit

          protected Object visit(ASTAndNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTArrayAccess node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTExtendedLiteral node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTArrayLiteral node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTRangeNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTAssignment node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTBitwiseAndNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTBitwiseComplNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTBitwiseOrNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTBitwiseXorNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTBlock node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTDivNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTEmptyFunction node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTEmptyMethod node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTEQNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTERNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTSWNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTEWNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTNSWNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTNEWNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTFalseNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTContinue node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTBreak node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTForeachStatement node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTGENode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTGTNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTIdentifier node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTIdentifierAccess node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTIfStatement node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTNumberLiteral node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visitParameter

          protected String visitParameter(String p,
                              Object data)

      A pseudo visitor for parameters.
      Parameters:
        `p` - the parameter name
        `data` - the visitor argument
      Returns:
        the parameter name to use

    - #### visit

          protected Object visit(ASTJexlScript node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTLENode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTLTNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTMapEntry node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTSetLiteral node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTMapLiteral node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTConstructorNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTFunctionNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTMethodNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTArguments node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTModNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTMulNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTNENode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTNRNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTNotNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTNullLiteral node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTOrNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTReference node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTReferenceExpression node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTReturnStatement node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTSizeFunction node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTSizeMethod node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTStringLiteral node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTTernaryNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTTrueNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTUnaryMinusNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTVar node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTWhileStatement node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTSetAddNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTSetSubNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTSetMultNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTSetDivNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTSetModNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTSetAndNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTSetOrNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTSetXorNode node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

    - #### visit

          protected Object visit(ASTJxltLiteral node,
                     Object data)

      Specified by:
        `visit` in class `ParserVisitor`

Copyright © 2001–2015 The Apache Software Foundation. All rights reserved.