org.apache.jdo.impl.jdoql.tree
Class FilterExpressionDumper

java.lang.Object
  extended by org.apache.jdo.jdoql.tree.AbstractNodeVisitor
      extended by org.apache.jdo.impl.jdoql.tree.FilterExpressionDumper
All Implemented Interfaces:
NodeVisitor

public class FilterExpressionDumper
extends AbstractNodeVisitor

An instance of this class is used to print a query tree into a print stream. The tree is printed as a string representation. The filter of this representation can be used as argument for method Query.setFilter. As this class inherits from AbstractNodeVisitor, it only overwrites those methods that need to dump and relies on the delegation mechanism for the remaining methods implemented in AbstractNodeVisitor .

Author:
Michael Watzek

Constructor Summary
FilterExpressionDumper()
          Constructs an instance of this class.
FilterExpressionDumper(java.io.PrintStream out)
          Constructs an instance of this class.
 
Method Summary
 void arrive(AscendingOrderingExpression node)
          Ascending ordering expressions are dumped like Ascending(expression).
protected  void arrive(BinaryExpression node)
          Binary expressions are dumped in parenthesized manner.
 void arrive(CastExpression node)
          Cast expressions are dumped like (type)expression.
 void arrive(ComplementExpression node)
          Complement expressions are dumped like ~expression.
 void arrive(ConstantExpression node)
          Dumps the value of the argument node.
 void arrive(DescendingOrderingExpression node)
          Descending ordering expressions are dumped like Descending(expression).
 void arrive(FieldAccessExpression node)
          Field access expressions are dumped like target.fieldName.
 void arrive(IdentifierExpression node)
          Dumps the name of an identifier expression.
 void arrive(NotExpression node)
          Dumps a not expression.
 void arrive(UnaryMinusExpression node)
          Unary minus expressions are dumped like -expression.
protected  java.lang.Object leave(BinaryExpression node, java.lang.Object[] results)
          Binary expressions are dumped in parenthesized manner.
 java.lang.Object leave(FieldAccessExpression node, java.lang.Object[] results)
          Field access expressions are dumped like target.fieldName.
protected  java.lang.Object leave(MethodCallExpression node, java.lang.Object[] results)
          Method call expressions are dumped like target.methodName(arguments).
protected  java.lang.Object leave(OrderingExpression node, java.lang.Object[] results)
          Ordering expressions are dumped like Ascending/Descending(expression).
 java.lang.Object leave(QueryTree node, java.lang.Object[] results)
          Query trees are dumped like orderingExpressions, filterExpression.
 boolean walkNextChild(AndExpression node, java.lang.Object resultOfPreviousChild, int indexOfNextChild)
          A logical and expression is dumped like (leftExpression & rightExpression).
 boolean walkNextChild(ConditionalAndExpression node, java.lang.Object resultOfPreviousChild, int indexOfNextChild)
          A conditional and expression is dumped like (leftExpression && rightExpression).
 boolean walkNextChild(ConditionalOrExpression node, java.lang.Object resultOfPreviousChild, int indexOfNextChild)
          A logical or expression is dumped like (leftExpression || rightExpression).
 boolean walkNextChild(DivideExpression node, java.lang.Object resultOfPreviousChild, int indexOfNextChild)
          A divide expression is dumped like (leftExpression / rightExpression).
 boolean walkNextChild(EqualsExpression node, java.lang.Object resultOfPreviousChild, int indexOfNextChild)
          An equals expression is dumped like (leftExpression == rightExpression).
 boolean walkNextChild(GreaterThanEqualsExpression node, java.lang.Object resultOfPreviousChild, int indexOfNextChild)
          A greater than equals expression is dumped like (leftExpression >= rightExpression).
 boolean walkNextChild(GreaterThanExpression node, java.lang.Object resultOfPreviousChild, int indexOfNextChild)
          A greater than expression is dumped like (leftExpression > rightExpression).
 boolean walkNextChild(LessThanEqualsExpression node, java.lang.Object resultOfPreviousChild, int indexOfNextChild)
          A less than equals expression is dumped like (leftExpression <= rightExpression).
 boolean walkNextChild(LessThanExpression node, java.lang.Object resultOfPreviousChild, int indexOfNextChild)
          A less than expression is dumped like (leftExpression < rightExpression).
protected  boolean walkNextChild(MethodCallExpression node, java.lang.Object resultOfPreviousChild, int indexOfNextChild)
          Method call expressions are dumped like target.methodName(arguments).
 boolean walkNextChild(MinusExpression node, java.lang.Object resultOfPreviousChild, int indexOfNextChild)
          A minus expression is dumped like (leftExpression - rightExpression).
 boolean walkNextChild(NotEqualsExpression node, java.lang.Object resultOfPreviousChild, int indexOfNextChild)
          Dumps a not equals expression.
 boolean walkNextChild(OrExpression node, java.lang.Object resultOfPreviousChild, int indexOfNextChild)
          A logical or expression is dumped like (leftExpression | rightExpression).
 boolean walkNextChild(PlusExpression node, java.lang.Object resultOfPreviousChild, int indexOfNextChild)
          A plus expression is dumped like (leftExpression + rightExpression).
 boolean walkNextChild(QueryTree node, java.lang.Object resultOfPreviousChild, int indexOfNextChild)
          Query trees are dumped like orderingExpressions, filterExpression.
 boolean walkNextChild(TimesExpression node, java.lang.Object resultOfPreviousChild, int indexOfNextChild)
          A times expression is dumped like (leftExpression * rightExpression).
 
Methods inherited from class org.apache.jdo.jdoql.tree.AbstractNodeVisitor
arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, arrive, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, leave, walkNextChild, walkNextChild, walkNextChild, walkNextChild, walkNextChild, walkNextChild, walkNextChild, walkNextChild, walkNextChild, walkNextChild, walkNextChild, walkNextChild, walkNextChild, walkNextChild, walkNextChild, walkNextChild, walkNextChild, walkNextChild, walkNextChild
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilterExpressionDumper

public FilterExpressionDumper()
Constructs an instance of this class. The print stream used to dump the tree is System.out.


FilterExpressionDumper

public FilterExpressionDumper(java.io.PrintStream out)
Constructs an instance of this class. The print stream used to dump the tree is the argument out.

Parameters:
out - the print stream to dump to
Method Detail

arrive

protected void arrive(BinaryExpression node)
Binary expressions are dumped in parenthesized manner. Thus, this method dumps the left parenthesis and it's corresponding leave method dumps the right parenthesis.

Overrides:
arrive in class AbstractNodeVisitor
Parameters:
node - the node to dump

leave

protected java.lang.Object leave(BinaryExpression node,
                                 java.lang.Object[] results)
Binary expressions are dumped in parenthesized manner. Thus, this method dumps the right parenthesis and it's corresponding leave method dumps the left parenthesis.

Overrides:
leave in class AbstractNodeVisitor
Parameters:
node - the node to dump
results - an array of null instances
Returns:
null

leave

protected java.lang.Object leave(MethodCallExpression node,
                                 java.lang.Object[] results)
Method call expressions are dumped like target.methodName(arguments).

Overrides:
leave in class AbstractNodeVisitor
Parameters:
node - the node to dump
results - an array of null instances
Returns:
null

leave

protected java.lang.Object leave(OrderingExpression node,
                                 java.lang.Object[] results)
Ordering expressions are dumped like Ascending/Descending(expression).

Overrides:
leave in class AbstractNodeVisitor
Parameters:
node - the node to dump
results - an array of null instances
Returns:
null

walkNextChild

protected boolean walkNextChild(MethodCallExpression node,
                                java.lang.Object resultOfPreviousChild,
                                int indexOfNextChild)
Method call expressions are dumped like target.methodName(arguments).

Overrides:
walkNextChild in class AbstractNodeVisitor
Parameters:
node - the parent node of the children currently dumped
resultOfPreviousChild - the result of the previsous child node
indexOfNextChild - the index of the next child to be dumped
Returns:
true

arrive

public void arrive(AscendingOrderingExpression node)
Ascending ordering expressions are dumped like Ascending(expression).

Specified by:
arrive in interface NodeVisitor
Overrides:
arrive in class AbstractNodeVisitor
Parameters:
node - the node to dump

arrive

public void arrive(DescendingOrderingExpression node)
Descending ordering expressions are dumped like Descending(expression).

Specified by:
arrive in interface NodeVisitor
Overrides:
arrive in class AbstractNodeVisitor
Parameters:
node - the node to dump

arrive

public void arrive(ConstantExpression node)
Dumps the value of the argument node. If that node holds a String instance, then the string value is dumped in double quotes.

Specified by:
arrive in interface NodeVisitor
Overrides:
arrive in class AbstractNodeVisitor
Parameters:
node - the node to dump

arrive

public void arrive(CastExpression node)
Cast expressions are dumped like (type)expression.

Specified by:
arrive in interface NodeVisitor
Overrides:
arrive in class AbstractNodeVisitor
Parameters:
node - the node to dump

arrive

public void arrive(FieldAccessExpression node)
Field access expressions are dumped like target.fieldName.

Specified by:
arrive in interface NodeVisitor
Overrides:
arrive in class AbstractNodeVisitor
Parameters:
node - the node to dump

arrive

public void arrive(ComplementExpression node)
Complement expressions are dumped like ~expression.

Specified by:
arrive in interface NodeVisitor
Overrides:
arrive in class AbstractNodeVisitor
Parameters:
node - the node to dump

arrive

public void arrive(IdentifierExpression node)
Dumps the name of an identifier expression.

Specified by:
arrive in interface NodeVisitor
Overrides:
arrive in class AbstractNodeVisitor
Parameters:
node - the node to dump

arrive

public void arrive(NotExpression node)
Dumps a not expression. It is dumped like !expression.

Specified by:
arrive in interface NodeVisitor
Overrides:
arrive in class AbstractNodeVisitor
Parameters:
node - the node to dump

arrive

public void arrive(UnaryMinusExpression node)
Unary minus expressions are dumped like -expression.

Specified by:
arrive in interface NodeVisitor
Overrides:
arrive in class AbstractNodeVisitor
Parameters:
node - the node to dump

leave

public java.lang.Object leave(FieldAccessExpression node,
                              java.lang.Object[] results)
Field access expressions are dumped like target.fieldName.

Specified by:
leave in interface NodeVisitor
Overrides:
leave in class AbstractNodeVisitor
Parameters:
node - the node to dump
results - the results of walking the node's children
Returns:
the result of the delegation call

leave

public java.lang.Object leave(QueryTree node,
                              java.lang.Object[] results)
Query trees are dumped like orderingExpressions, filterExpression.

Specified by:
leave in interface NodeVisitor
Overrides:
leave in class AbstractNodeVisitor
Parameters:
node - the node to dump
results - the results of walking the node's children
Returns:
the result of the delegation call

walkNextChild

public boolean walkNextChild(AndExpression node,
                             java.lang.Object resultOfPreviousChild,
                             int indexOfNextChild)
A logical and expression is dumped like (leftExpression & rightExpression).

Specified by:
walkNextChild in interface NodeVisitor
Overrides:
walkNextChild in class AbstractNodeVisitor
Parameters:
node - the parent node of the children currently dumped
resultOfPreviousChild - an array of null instances
indexOfNextChild - the index of the next child to be dumped
Returns:
true

walkNextChild

public boolean walkNextChild(ConditionalAndExpression node,
                             java.lang.Object resultOfPreviousChild,
                             int indexOfNextChild)
A conditional and expression is dumped like (leftExpression && rightExpression).

Specified by:
walkNextChild in interface NodeVisitor
Overrides:
walkNextChild in class AbstractNodeVisitor
Parameters:
node - the parent node of the children currently dumped
resultOfPreviousChild - an array of null instances
indexOfNextChild - the index of the next child to be dumped
Returns:
true

walkNextChild

public boolean walkNextChild(ConditionalOrExpression node,
                             java.lang.Object resultOfPreviousChild,
                             int indexOfNextChild)
A logical or expression is dumped like (leftExpression || rightExpression).

Specified by:
walkNextChild in interface NodeVisitor
Overrides:
walkNextChild in class AbstractNodeVisitor
Parameters:
node - the parent node of the children currently dumped
resultOfPreviousChild - an array of null instances
indexOfNextChild - the index of the next child to be dumped
Returns:
true

walkNextChild

public boolean walkNextChild(DivideExpression node,
                             java.lang.Object resultOfPreviousChild,
                             int indexOfNextChild)
A divide expression is dumped like (leftExpression / rightExpression).

Specified by:
walkNextChild in interface NodeVisitor
Overrides:
walkNextChild in class AbstractNodeVisitor
Parameters:
node - the parent node of the children currently dumped
resultOfPreviousChild - an array of null instances
indexOfNextChild - the index of the next child to be dumped
Returns:
true

walkNextChild

public boolean walkNextChild(EqualsExpression node,
                             java.lang.Object resultOfPreviousChild,
                             int indexOfNextChild)
An equals expression is dumped like (leftExpression == rightExpression).

Specified by:
walkNextChild in interface NodeVisitor
Overrides:
walkNextChild in class AbstractNodeVisitor
Parameters:
node - the parent node of the children currently dumped
resultOfPreviousChild - an array of null instances
indexOfNextChild - the index of the next child to be dumped
Returns:
true

walkNextChild

public boolean walkNextChild(GreaterThanEqualsExpression node,
                             java.lang.Object resultOfPreviousChild,
                             int indexOfNextChild)
A greater than equals expression is dumped like (leftExpression >= rightExpression).

Specified by:
walkNextChild in interface NodeVisitor
Overrides:
walkNextChild in class AbstractNodeVisitor
Parameters:
node - the parent node of the children currently dumped
resultOfPreviousChild - an array of null instances
indexOfNextChild - the index of the next child to be dumped
Returns:
true

walkNextChild

public boolean walkNextChild(GreaterThanExpression node,
                             java.lang.Object resultOfPreviousChild,
                             int indexOfNextChild)
A greater than expression is dumped like (leftExpression > rightExpression).

Specified by:
walkNextChild in interface NodeVisitor
Overrides:
walkNextChild in class AbstractNodeVisitor
Parameters:
node - the parent node of the children currently dumped
resultOfPreviousChild - an array of null instances
indexOfNextChild - the index of the next child to be dumped
Returns:
true

walkNextChild

public boolean walkNextChild(LessThanEqualsExpression node,
                             java.lang.Object resultOfPreviousChild,
                             int indexOfNextChild)
A less than equals expression is dumped like (leftExpression <= rightExpression).

Specified by:
walkNextChild in interface NodeVisitor
Overrides:
walkNextChild in class AbstractNodeVisitor
Parameters:
node - the parent node of the children currently dumped
resultOfPreviousChild - an array of null instances
indexOfNextChild - the index of the next child to be dumped
Returns:
true

walkNextChild

public boolean walkNextChild(LessThanExpression node,
                             java.lang.Object resultOfPreviousChild,
                             int indexOfNextChild)
A less than expression is dumped like (leftExpression < rightExpression).

Specified by:
walkNextChild in interface NodeVisitor
Overrides:
walkNextChild in class AbstractNodeVisitor
Parameters:
node - the parent node of the children currently dumped
resultOfPreviousChild - an array of null instances
indexOfNextChild - the index of the next child to be dumped
Returns:
true

walkNextChild

public boolean walkNextChild(MinusExpression node,
                             java.lang.Object resultOfPreviousChild,
                             int indexOfNextChild)
A minus expression is dumped like (leftExpression - rightExpression).

Specified by:
walkNextChild in interface NodeVisitor
Overrides:
walkNextChild in class AbstractNodeVisitor
Parameters:
node - the parent node of the children currently dumped
resultOfPreviousChild - an array of null instances
indexOfNextChild - the index of the next child to be dumped
Returns:
true

walkNextChild

public boolean walkNextChild(NotEqualsExpression node,
                             java.lang.Object resultOfPreviousChild,
                             int indexOfNextChild)
Dumps a not equals expression. It is dumped like (leftExpression != rightExpression).

Specified by:
walkNextChild in interface NodeVisitor
Overrides:
walkNextChild in class AbstractNodeVisitor
Parameters:
node - the parent node of the children currently dumped
resultOfPreviousChild - an array of null instances
indexOfNextChild - the index of the next child to be dumped
Returns:
true

walkNextChild

public boolean walkNextChild(OrExpression node,
                             java.lang.Object resultOfPreviousChild,
                             int indexOfNextChild)
A logical or expression is dumped like (leftExpression | rightExpression).

Specified by:
walkNextChild in interface NodeVisitor
Overrides:
walkNextChild in class AbstractNodeVisitor
Parameters:
node - the parent node of the children currently dumped
resultOfPreviousChild - an array of null instances
indexOfNextChild - the index of the next child to be dumped
Returns:
true

walkNextChild

public boolean walkNextChild(QueryTree node,
                             java.lang.Object resultOfPreviousChild,
                             int indexOfNextChild)
Query trees are dumped like orderingExpressions, filterExpression.

Specified by:
walkNextChild in interface NodeVisitor
Overrides:
walkNextChild in class AbstractNodeVisitor
Parameters:
node - the parent node of the children currently dumped
resultOfPreviousChild - an array of null instances
indexOfNextChild - the index of the next child to be dumped
Returns:
true

walkNextChild

public boolean walkNextChild(PlusExpression node,
                             java.lang.Object resultOfPreviousChild,
                             int indexOfNextChild)
A plus expression is dumped like (leftExpression + rightExpression).

Specified by:
walkNextChild in interface NodeVisitor
Overrides:
walkNextChild in class AbstractNodeVisitor
Parameters:
node - the parent node of the children currently dumped
resultOfPreviousChild - an array of null instances
indexOfNextChild - the index of the next child to be dumped
Returns:
true

walkNextChild

public boolean walkNextChild(TimesExpression node,
                             java.lang.Object resultOfPreviousChild,
                             int indexOfNextChild)
A times expression is dumped like (leftExpression * rightExpression).

Specified by:
walkNextChild in interface NodeVisitor
Overrides:
walkNextChild in class AbstractNodeVisitor
Parameters:
node - the parent node of the children currently dumped
resultOfPreviousChild - an array of null instances
indexOfNextChild - the index of the next child to be dumped
Returns:
true


Copyright © 2005-2011 Apache Software Foundation. All Rights Reserved.