You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-commits@db.apache.org by mb...@apache.org on 2005/05/22 20:09:00 UTC

svn commit: r171353 [7/13] - in /incubator/jdo/trunk/query20: ./ src/ src/conf/ src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/jdo/ src/java/org/apache/jdo/impl/ src/java/org/apache/jdo/impl/jdoql/ src/java/org/apache/jdo/impl/jdoql/jdoqlc/ src/java/org/apache/jdo/impl/jdoql/scope/ src/java/org/apache/jdo/impl/jdoql/tree/ src/java/org/apache/jdo/jdoql/ src/java/org/apache/jdo/jdoql/tree/

Added: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/ContainsCallExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/ContainsCallExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/ContainsCallExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/ContainsCallExpr.java Sun May 22 11:08:57 2005
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.impl.jdoql.tree;
+
+
+import java.util.Collection;
+
+import org.apache.jdo.impl.jdoql.jdoqlc.JDOQLTokenTypes;
+import org.apache.jdo.jdoql.JDOQueryException;
+import org.apache.jdo.jdoql.tree.ContainsCallExpression;
+import org.apache.jdo.jdoql.tree.Expression;
+import org.apache.jdo.jdoql.tree.NodeVisitor;
+
+
+/**
+ * This node represents the method call expression
+ * <code>Collection.contains</code>. Children of this node are a target
+ * expression (e.g. a <code>FieldAccessExpression</code>) and the method
+ * argument which is an arbitrary expression.
+ *
+ * @author Michael Watzek
+ */
+public final class ContainsCallExpr 
+    extends MethodCallExpr implements ContainsCallExpression
+{
+    /**
+     * The noarg constructor is needed for ANTLR support and deserialization.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public ContainsCallExpr()
+    {}
+
+    /**
+     * The noarg constructor is needed for ANTLR support.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public ContainsCallExpr(antlr.Token token)
+    {   initialize( token );
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param target the target expression of this method call
+     * @param args the arguments of this method call
+     * @exception JDOQueryException if the result type of target is
+     * not a collection type or the length of args is not equal 1.
+     */
+    ContainsCallExpr(Expression target, Expression[] args)
+    {   super( JDOQLTokenTypes.CONTAINS, "contains", Boolean.class, 
+               target, args ); //NOI18N
+        if( target.getJavaClass()!=null &&
+            !Collection.class.isAssignableFrom(target.getJavaClass()) )
+            throw new JDOQueryException( msg.msg("EXC_NoCollectionType", 
+                                                 target, this) ); //NOI18N
+        if( args==null ||
+            args.length!=1 )
+            throw new JDOQueryException(
+                msg.msg("EXC_IllegalNumberOfParameters", this) ); //NOI18N
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param target the target expression of this method call
+     * @param arg the argument of this method call
+     */
+    ContainsCallExpr(Expression target, Expression arg)
+    {   this( target, new Expression[] {arg} );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     */
+    public void arrive(NodeVisitor visitor)
+    {   visitor.arrive( this );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     * @param results the result array
+     * @return the object returned by the visitor instance
+     */
+    public Object leave(NodeVisitor visitor, Object[] results)
+    {   return visitor.leave( this, results );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     * @param resultOfPreviousChild the result computed by leaving the
+     * previous child node
+     * @param indexOfNextChild the index in the children array of the
+     * next child to walk
+     * @return the boolean value returned by the visitor instance
+     */
+    public boolean walkNextChild(NodeVisitor visitor, 
+                                 Object resultOfPreviousChild, 
+                                 int indexOfNextChild)
+    {   return visitor.walkNextChild( this, resultOfPreviousChild, 
+                                      indexOfNextChild );
+    }
+}

Added: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/Decl.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/Decl.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/Decl.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/Decl.java Sun May 22 11:08:57 2005
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.impl.jdoql.tree;
+
+import org.apache.jdo.jdoql.tree.Declaration;
+import org.apache.jdo.jdoql.tree.Node;
+import org.apache.jdo.jdoql.tree.Type;
+
+/**
+ * This node represents a declaration expression. Examples of
+ * declarations expressions are
+ * <code>ParameterDeclarationExpression</code> and
+ * <code>VariableDeclarationExpression</code>. Declaration expressions
+ * do not have any children.
+ *
+ * @author Michael Watzek
+ */
+public abstract class Decl extends NodeImpl implements Declaration
+{
+    String  name;
+
+    /**
+     * The noarg constructor is needed for ANTLR support and deserialization.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public Decl()
+    {}
+
+    /**
+     * This constructor is called by specialized nodes.
+     * @param tokenType the token tpye
+     * @param tokenName the name of this node
+     * @param type the type instance wrapping the Java class
+     * @param name the name of the specialized declaration
+     */
+    Decl(int tokenType, String tokenName, Type type, String name)
+    {   super( tokenType, tokenName, type.getJavaClass() );
+        setChildren( new Node[] {type} );
+        this.name = name;
+    }
+
+    /**
+     * Returns the name of the specialized declaration.
+     * @return the name
+     */
+    public String getName()
+    {   return this.name;
+    }
+
+
+    /**
+     * Sets the name of the specialized declaration.
+     * This method is used by semantic analysis only.
+     * @param name the name
+     */
+    public void setName(String name)
+    {   this.name = name;
+    }
+
+    /**
+     * Returns the Java type name of the specialized declaration.
+     * @return the Java type name
+     */
+    public String getTypeName()
+    {   ASTToChildren();
+        if( this.children==null ||
+            this.children.length<1 )
+            return null;
+        return ((Type)this.children[0]).getTypeName();
+    }
+}
+

Added: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/DescendingOrderingExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/DescendingOrderingExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/DescendingOrderingExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/DescendingOrderingExpr.java Sun May 22 11:08:57 2005
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.impl.jdoql.tree;
+
+import org.apache.jdo.impl.jdoql.jdoqlc.JDOQLTokenTypes;
+import org.apache.jdo.jdoql.tree.DescendingOrderingExpression;
+import org.apache.jdo.jdoql.tree.Expression;
+import org.apache.jdo.jdoql.tree.NodeVisitor;
+
+
+/**
+ * This node represents an operator defining descendent ordering of instances
+ * returned by a query execution. The order is determined by an expression
+ * such as <code>FieldAccessExpression</code>. This expression is this node's
+ * child.
+ *
+ * @author Michael Watzek
+ */
+public final class DescendingOrderingExpr 
+    extends OrderingExpr implements DescendingOrderingExpression
+{
+    /**
+     * The noarg constructor is needed for ANTLR support and deserialization.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public DescendingOrderingExpr()
+    {}
+
+    /**
+     * The noarg constructor is needed for ANTLR support.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public DescendingOrderingExpr(antlr.Token token)
+    {   initialize( token );
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param expr the expression defining the order
+     */
+    DescendingOrderingExpr(Expression expr)
+    {   super( JDOQLTokenTypes.DESCENDING, "DescendingOrderingExpression", expr ); //NOI18N
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     */
+    public void arrive(NodeVisitor visitor)
+    {   visitor.arrive( this );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     * @param results the result array
+     * @return the object returned by the visitor instance
+     */
+    public Object leave(NodeVisitor visitor, Object[] results)
+    {   return visitor.leave( this, results );
+    }
+}

Added: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/DivideExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/DivideExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/DivideExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/DivideExpr.java Sun May 22 11:08:57 2005
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.impl.jdoql.tree;
+
+import org.apache.jdo.impl.jdoql.jdoqlc.JDOQLTokenTypes;
+import org.apache.jdo.jdoql.tree.DivideExpression;
+import org.apache.jdo.jdoql.tree.Expression;
+import org.apache.jdo.jdoql.tree.NodeVisitor;
+
+
+/**
+ * This node represents a division operator.
+ * A division operator is a binary expression.
+ * The string representation of this operator is <code>/</code>.
+ *
+ * @author Michael Watzek
+ */
+public final class DivideExpr extends BinaryExpr implements DivideExpression
+{
+    /**
+     * The noarg constructor is needed for ANTLR support and deserialization.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public DivideExpr()
+    {}
+
+    /**
+     * The noarg constructor is needed for ANTLR support.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public DivideExpr(antlr.Token token)
+    {   initialize( token );
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param left the left operand
+     * @param right the right operand
+     */
+    DivideExpr(Expression left, Expression right)
+    {   super( JDOQLTokenTypes.DIV, "Divide", null, left, right ); //NOI18N
+        this.clazz = this.commonOperandType;
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     */
+    public void arrive(NodeVisitor visitor)
+    {   visitor.arrive( this );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     * @param results the result array
+     * @return the object returned by the visitor instance
+     */
+    public Object leave(NodeVisitor visitor, Object[] results)
+    {   return visitor.leave( this, results );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     * @param resultOfPreviousChild the result computed by leaving the
+     * previous child node
+     * @param indexOfNextChild the index in the children array of the
+     * next child to walk
+     * @return the boolean value returned by the visitor instance
+     */
+    public boolean walkNextChild(NodeVisitor visitor, 
+                                 Object resultOfPreviousChild, 
+                                 int indexOfNextChild)
+    {   return visitor.walkNextChild( this, resultOfPreviousChild, 
+                                      indexOfNextChild );
+    }
+}

Added: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/DoubleLiteralExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/DoubleLiteralExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/DoubleLiteralExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/DoubleLiteralExpr.java Sun May 22 11:08:57 2005
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.impl.jdoql.tree;
+
+import org.apache.jdo.impl.jdoql.jdoqlc.JDOQLTokenTypes;
+import org.apache.jdo.jdoql.tree.DoubleLiteralExpression;
+import org.apache.jdo.jdoql.tree.NodeVisitor;
+
+
+/**
+ * This node represents a double literal. It does not have any children.
+ *
+ * @author Michael Watzek
+ */
+public final class DoubleLiteralExpr 
+    extends ConstantExpr implements DoubleLiteralExpression
+{
+    /**
+     * The noarg constructor is needed for ANTLR support and deserialization.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public DoubleLiteralExpr()
+    {}
+
+    /**
+     * The noarg constructor is needed for ANTLR support.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public DoubleLiteralExpr(antlr.Token token)
+    {   initialize( token );
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param d the double value
+     */
+    DoubleLiteralExpr(Double d)
+    {   super( JDOQLTokenTypes.DOUBLE_LITERAL, d.toString(), d ); //NOI18N
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param d the double value
+     */
+    DoubleLiteralExpr(double d)
+    {   this( new Double(d) );
+    }
+
+    /**
+     * Returns the double value represented by this expression.
+     * @return the double value
+     */
+    public double getDouble()
+    {   return ((Double)this.value).doubleValue();
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     */
+    public void arrive(NodeVisitor visitor)
+    {   visitor.arrive( this );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     * @param results the result array
+     * @return the object returned by the visitor instance
+     */
+    public Object leave(NodeVisitor visitor, Object[] results)
+    {   return visitor.leave( this, results );
+    }
+}

Added: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/EndsWithCallExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/EndsWithCallExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/EndsWithCallExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/EndsWithCallExpr.java Sun May 22 11:08:57 2005
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.impl.jdoql.tree;
+
+import org.apache.jdo.impl.jdoql.jdoqlc.JDOQLTokenTypes;
+import org.apache.jdo.jdoql.JDOQueryException;
+import org.apache.jdo.jdoql.tree.EndsWithCallExpression;
+import org.apache.jdo.jdoql.tree.Expression;
+import org.apache.jdo.jdoql.tree.NodeVisitor;
+
+
+
+/**
+ * This node represents the method call expression
+ * <code>String.endsWith</code>. Children of this node are a target
+ * expression (e.g. a <code>FieldAccessExpression</code>) and the method
+ * argument which is an arbitrary expression.
+ *
+ * @author Michael Watzek
+ */
+public final class EndsWithCallExpr 
+    extends MethodCallExpr implements EndsWithCallExpression
+{
+    /**
+     * The noarg constructor is needed for ANTLR support and deserialization.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public EndsWithCallExpr()
+    {}
+
+    /**
+     * The noarg constructor is needed for ANTLR support.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public EndsWithCallExpr(antlr.Token token)
+    {   initialize( token );
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param target the target expression of this method call
+     * @param args the arguments of this method call
+     * @exception JDOQueryException if the result type of target is not a string
+     * or the length of args is not equal 1.
+     */
+    EndsWithCallExpr(Expression target, Expression[] args)
+    {   super( JDOQLTokenTypes.ENDS_WITH, "endsWith", Boolean.class, 
+               target, args ); //NOI18N
+        if( target.getJavaClass()!=null &&
+            !String.class.isAssignableFrom(target.getJavaClass()) )
+            throw new JDOQueryException( msg.msg("EXC_NoStringType", 
+                                                 target, this) ); //NOI18N
+        if( args==null ||
+            args.length!=1 )
+            throw new JDOQueryException(
+                msg.msg("EXC_IllegalNumberOfParameters", this) ); //NOI18N
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param target the target expression of this method call
+     * @param arg the argument of this method call
+     */
+    EndsWithCallExpr(Expression target, Expression arg)
+    {   this( target, new Expression[] {arg} );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     */
+    public void arrive(NodeVisitor visitor)
+    {   visitor.arrive( this );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     * @param results the result array
+     * @return the object returned by the visitor instance
+     */
+    public Object leave(NodeVisitor visitor, Object[] results)
+    {   return visitor.leave( this, results );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     * @param resultOfPreviousChild the result computed by leaving the
+     * previous child node
+     * @param indexOfNextChild the index in the children array of the
+     * next child to walk
+     * @return the boolean value returned by the visitor instance
+     */
+    public boolean walkNextChild(NodeVisitor visitor,
+                                 Object resultOfPreviousChild,
+                                 int indexOfNextChild)
+    {   return visitor.walkNextChild( this, resultOfPreviousChild,
+                                      indexOfNextChild );
+    }
+}

Added: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/EqualsExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/EqualsExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/EqualsExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/EqualsExpr.java Sun May 22 11:08:57 2005
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.impl.jdoql.tree;
+
+import org.apache.jdo.impl.jdoql.jdoqlc.JDOQLTokenTypes;
+import org.apache.jdo.jdoql.tree.EqualsExpression;
+import org.apache.jdo.jdoql.tree.Expression;
+import org.apache.jdo.jdoql.tree.NodeVisitor;
+
+
+/**
+ * This node represents an equals operator.
+ * An equals operator is a binary expression.
+ * The string representation of this operator is <code>==</code>.
+ *
+ * @author Michael Watzek
+ */
+public final class EqualsExpr extends BinaryExpr implements EqualsExpression
+{
+    /**
+     * The noarg constructor is needed for ANTLR support and deserialization.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public EqualsExpr()
+    {}
+
+    /**
+     * The noarg constructor is needed for ANTLR support.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public EqualsExpr(antlr.Token token)
+    {   initialize( token );
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param left the left operand
+     * @param right the right operand
+     */
+    EqualsExpr(Expression left, Expression right)
+    {   super( JDOQLTokenTypes.EQUAL, "Equals", Boolean.class, left, right ); //NOI18N
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     */
+    public void arrive(NodeVisitor visitor)
+    {   visitor.arrive( this );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     * @param results the result array
+     * @return the object returned by the visitor instance
+     */
+    public Object leave(NodeVisitor visitor, Object[] results)
+    {   return visitor.leave( this, results );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     * @param resultOfPreviousChild the result computed by leaving the
+     * previous child node
+     * @param indexOfNextChild the index in the children array of the
+     * next child to walk
+     * @return the boolean value returned by the visitor instance
+     */
+    public boolean walkNextChild(NodeVisitor visitor,
+                                 Object resultOfPreviousChild,
+                                 int indexOfNextChild)
+    {   return visitor.walkNextChild( this, resultOfPreviousChild,
+                                      indexOfNextChild );
+    }
+}

Added: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/Expr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/Expr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/Expr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/Expr.java Sun May 22 11:08:57 2005
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.impl.jdoql.tree;
+
+import org.apache.jdo.jdoql.tree.Expression;
+
+/**
+ * This node represents a general expression. Examples of general expressions
+ * are <code>UnaryExpression</code>, <code>BinaryExpression</code>,
+ * <code>FieldAccessExpression</code>, <code>CastExpression</code>
+ * and <code>MethodCallExpression</code>.
+ *
+ * @author Michael Watzek
+ */
+public abstract class Expr extends NodeImpl implements Expression
+{
+    /**
+     * The noarg constructor is needed for ANTLR support and deserialization.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public Expr()
+    {}
+
+    /**
+     * This constructor is called by specialized nodes.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     * @param tokenType the token tpye
+     * @param tokenName the name of this node
+     * @param clazz the Java type of this node
+     */
+    Expr(int tokenType, String tokenName, Class clazz)
+    {   super( tokenType, tokenName, clazz );
+    }
+}

Added: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/FieldAccessExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/FieldAccessExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/FieldAccessExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/FieldAccessExpr.java Sun May 22 11:08:57 2005
@@ -0,0 +1,204 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.impl.jdoql.tree;
+
+import javax.jdo.PersistenceManager;
+
+import org.apache.jdo.impl.jdoql.jdoqlc.JDOQLTokenTypes;
+import org.apache.jdo.impl.jdoql.jdoqlc.TypeSupport;
+import org.apache.jdo.jdoql.JDOQueryException;
+import org.apache.jdo.jdoql.tree.Expression;
+import org.apache.jdo.jdoql.tree.FieldAccessExpression;
+import org.apache.jdo.jdoql.tree.Node;
+import org.apache.jdo.jdoql.tree.NodeVisitor;
+import org.apache.jdo.model.java.JavaField;
+import org.apache.jdo.pm.PersistenceManagerInternal;
+
+import java.lang.reflect.Field;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * This node represents a field access expression. Field access expressions
+ * have exactly one child, the target expression.
+ * This expression can be an arbitrary expression.
+ *
+ * @author Michael Watzek
+ */
+public final class FieldAccessExpr 
+    extends IdentifierExpr implements FieldAccessExpression
+{
+    String fieldName;
+    transient JavaField javaField;
+    transient Field field;
+
+    /**
+     * The noarg constructor is needed for ANTLR support and deserialization.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public FieldAccessExpr()
+    {}
+
+    /**
+     * The noarg constructor is needed for ANTLR support.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public FieldAccessExpr(antlr.Token token)
+    {   initialize( token );
+    }
+
+    /**
+     * This constructor is called by <code>StaticFieldAccessExpr</code>.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     * @param tokenType the token type
+     * @param name the name of this identifier
+     * @param clazz the Java type of this identifier
+     */
+    FieldAccessExpr(int tokenType, String name, Class clazz)
+    {   super( tokenType, name, clazz );
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param target the target expression
+     * @param fieldName the field name of this field access expression
+     */
+    FieldAccessExpr(Expression target, String fieldName)
+    {   super( JDOQLTokenTypes.FIELD_ACCESS, fieldName, null );
+        init( target, fieldName );
+    }
+
+    /**
+     * Returns the name of the accessed field.
+     * Please note, that this name does not contain any information
+     * about the target object of this field access.
+     * @return the field name
+     */
+    public String getName()
+    {   return this.fieldName;
+    }
+
+    /**
+     * Sets the name of the accessed field.
+     * Please note, that this name must not contain any information
+     * about the target object of this field access.
+     * This method is used by semantic analysis only.
+     * @param fieldName the field name
+     */
+    public void setName(String fieldName)
+    {   this.fieldName = fieldName;
+    }
+
+    /**
+     * Returns the target expression of this field access.
+     * The target expression can be an instance of
+     * <code>ThisExpression</code> or an instance of an arbitrary other
+     * <code>Expression</code>, e.g. <code>FieldAccessExpression</code>.
+     * @return the target expression
+     */
+    public Expression getTarget()
+    {   ASTToChildren();
+        if( this.children==null ||
+            this.children.length<1 )
+            return null;
+        return (Expression) this.children[0];
+    }
+
+    /**
+     * Returns the value of the field corresponding with this
+     * field access expression for the argument <code>object</code>.
+     * Note: If the field value is obtained via reflection and
+     * the reflection call throws an <code>IllegalAccessException</code>,
+     * then undefined is returned.
+     * @param pm the persistence manager of the query
+     * @param object the instance for which to return the field value
+     * @return the field value for <code>object</code>
+     * @exception JDOQueryException if the access to the desired field is denied
+     */
+    public Object getFieldValue(PersistenceManager pm, Object object)
+    {   JavaField javaField = getFieldInfo();
+        int fieldNumber = TypeSupport.getFieldNumber( javaField.getJDOField(), 
+                                                      pm, object );
+        if (fieldNumber == -1) {
+            return TypeSupport.getFieldValue( getField(), object );
+        }
+        else {
+            return TypeSupport.getFieldValue(
+                fieldNumber, (PersistenceManagerInternal)pm, object );
+        }
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     */
+    public void arrive(NodeVisitor visitor)
+    {   visitor.arrive( this );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     * @param results the result array
+     * @return the object returned by the visitor instance
+     */
+    public Object leave(NodeVisitor visitor, Object[] results)
+    {   return visitor.leave( this, results );
+    }
+
+    /**
+     * Initializes fields of <code>this</code>.
+     * @param target the target expression of this field access
+     * @param fieldName the name of the field to access
+     */
+    void init(Expression target, String fieldName)
+    {   setChildren( new Node[] {target} );
+        this.fieldName = fieldName;
+    }
+
+    /**
+     * Returns the model's field object assciated with this instance.
+     * If that field object is <code>null</code>,
+     * then it is computed by this method.
+     * @return the model's field object
+     * @exception JDOQueryException if the access to the desired field is denied
+     */
+    JavaField getFieldInfo()
+    {   if( this.javaField==null )
+        {   Expr target = (Expr) getTarget();
+            this.javaField = target.getTypeInfo().getJavaField(this.fieldName);
+        }
+        return this.javaField;
+    }
+
+    /** */
+    private Field getField()
+    {   if( this.field==null )
+            this.field = (Field) AccessController.doPrivileged(
+               new PrivilegedAction() {
+                   public Object run () {
+                       return TypeSupport.getAccessibleField(getFieldInfo());
+                   }});
+        return this.field;
+    }
+    
+}
+

Added: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/FilterExpressionDumper.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/FilterExpressionDumper.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/FilterExpressionDumper.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/FilterExpressionDumper.java Sun May 22 11:08:57 2005
@@ -0,0 +1,497 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.impl.jdoql.tree;
+
+import java.io.PrintStream;
+
+import org.apache.jdo.jdoql.tree.AbstractNodeVisitor;
+import org.apache.jdo.jdoql.tree.AndExpression;
+import org.apache.jdo.jdoql.tree.AscendingOrderingExpression;
+import org.apache.jdo.jdoql.tree.BinaryExpression;
+import org.apache.jdo.jdoql.tree.CastExpression;
+import org.apache.jdo.jdoql.tree.ComplementExpression;
+import org.apache.jdo.jdoql.tree.ConditionalAndExpression;
+import org.apache.jdo.jdoql.tree.ConditionalOrExpression;
+import org.apache.jdo.jdoql.tree.ConstantExpression;
+import org.apache.jdo.jdoql.tree.DescendingOrderingExpression;
+import org.apache.jdo.jdoql.tree.DivideExpression;
+import org.apache.jdo.jdoql.tree.EqualsExpression;
+import org.apache.jdo.jdoql.tree.Expression;
+import org.apache.jdo.jdoql.tree.FieldAccessExpression;
+import org.apache.jdo.jdoql.tree.GreaterThanEqualsExpression;
+import org.apache.jdo.jdoql.tree.GreaterThanExpression;
+import org.apache.jdo.jdoql.tree.IdentifierExpression;
+import org.apache.jdo.jdoql.tree.LessThanEqualsExpression;
+import org.apache.jdo.jdoql.tree.LessThanExpression;
+import org.apache.jdo.jdoql.tree.MethodCallExpression;
+import org.apache.jdo.jdoql.tree.MinusExpression;
+import org.apache.jdo.jdoql.tree.NotEqualsExpression;
+import org.apache.jdo.jdoql.tree.NotExpression;
+import org.apache.jdo.jdoql.tree.OrExpression;
+import org.apache.jdo.jdoql.tree.OrderingExpression;
+import org.apache.jdo.jdoql.tree.PlusExpression;
+import org.apache.jdo.jdoql.tree.QueryTree;
+import org.apache.jdo.jdoql.tree.TimesExpression;
+import org.apache.jdo.jdoql.tree.UnaryMinusExpression;
+
+/**
+ * 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
+ * <code>Query.setFilter</code>.
+ * As this class inherits from <code>AbstractNodeVisitor</code>, it only
+ * overwrites those methods that need to dump and relies on the delegation
+ * mechanism for the remaining methods implemented in
+ * <code>AbstractNodeVisitor</code> .
+ *
+ * @author Michael Watzek
+ */
+public class FilterExpressionDumper extends AbstractNodeVisitor
+{
+    final PrintStream out;
+
+    /**
+     * Constructs an instance of this class. The print stream used to
+     * dump the tree is <code>System.out</code>.
+     */
+    public FilterExpressionDumper()
+    {   this.out = System.out;
+    }
+
+    /**
+     * Constructs an instance of this class. The print stream used to
+     * dump the tree is the argument <code>out</code>.
+     * @param out the print stream to dump to
+     */
+    public FilterExpressionDumper(PrintStream out)
+    {   this.out = out;
+    }
+
+    //protected methods
+
+    /**
+     * Binary expressions are dumped in parenthesized manner. Thus, this
+     * method dumps the left parenthesis and it's corresponding leave method
+     * dumps the right parenthesis.
+     * @param node the node to dump
+     */
+    protected void arrive(BinaryExpression node)
+    {   out.print( "(" ); //NOI18N
+    }
+
+    /**
+     * Binary expressions are dumped in parenthesized manner. Thus, this
+     * method dumps the right parenthesis and it's corresponding leave method
+     * dumps the left parenthesis.
+     * @param node the node to dump
+     * @param results an array of <code>null</code> instances
+     * @return <code>null</code>
+     */
+    protected Object leave(BinaryExpression node, Object[] results)
+    {   out.print( ")" ); //NOI18N
+        return null;
+    }
+
+    /**
+     * Method call expressions are dumped like
+     * <code>target.methodName(arguments)</code>.
+     * @param node the node to dump
+     * @param results an array of <code>null</code> instances
+     * @return <code>null</code>
+     */
+    protected Object leave(MethodCallExpression node, Object[] results)
+    {   if( node.getArguments()==null )
+            out.print( "."+node.getMethodName()+"(" ); //NOI18N
+        out.print( ")" ); //NOI18N
+        return null;
+    }
+
+    /**
+     * Ordering expressions are dumped like
+     * <code>Ascending/Descending(expression)</code>.
+     * @param node the node to dump
+     * @param results an array of <code>null</code> instances
+     * @return <code>null</code>
+     */
+    protected Object leave(OrderingExpression node, Object[] results)
+    {   out.print( ")" ); //NOI18N
+        return null;
+    }
+
+    /**
+     * Method call expressions are dumped like
+     * <code>target.methodName(arguments)</code>.
+     * @param node the parent node of the children currently dumped
+     * @param resultOfPreviousChild the result of the previsous child node
+     * @param indexOfNextChild the index of the next child to be dumped
+     * @return <code>true</code>
+     */
+    protected boolean walkNextChild(MethodCallExpression node, 
+                                    Object resultOfPreviousChild, 
+                                    int indexOfNextChild)
+    {   if( indexOfNextChild==1 )
+            out.print( "."+node.getMethodName()+"(" ); //NOI18N
+        else if( indexOfNextChild>1 )
+            out.print( ", " ); //NOI18N
+        return true;
+    }
+
+    //public methods
+
+    /**
+     * Ascending ordering expressions are dumped like
+     * <code>Ascending(expression)</code>.
+     * @param node the node to dump
+     */
+    public void arrive(AscendingOrderingExpression node)
+    {   out.print( "Ascending(" ); //NOI18N
+    }
+
+    /**
+     * Descending ordering expressions are dumped like
+     * <code>Descending(expression)</code>.
+     * @param node the node to dump
+     */
+    public void arrive(DescendingOrderingExpression node)
+    {   out.print( "Descending(" ); //NOI18N
+    }
+
+    /**
+     * Dumps the value of the argument <code>node</code>. If that node holds
+     * a String instance, then the string value is dumped in double quotes.
+     * @param node the node to dump
+     */
+    public void arrive(ConstantExpression node)
+    {   Object value = node.getValue();
+        if( value instanceof String )
+            out.print( "\""+value+"\"" ); //NOI18N
+        else
+            out.print( value );
+    }
+
+    /**
+     * Cast expressions are dumped like <code>(type)expression</code>.
+     * @param node the node to dump
+     */
+    public void arrive(CastExpression node)
+    {   out.print( "("+node.getTypeName()+")" ); //NOI18N
+    }
+
+    /**
+     * Field access expressions are dumped like <code>target.fieldName</code>.
+     * @param node the node to dump
+     */
+    public void arrive(FieldAccessExpression node)
+    {}
+
+    /**
+     * Complement expressions are dumped like <code>~expression</code>.
+     * @param node the node to dump
+     */
+    public void arrive(ComplementExpression node)
+    {   out.print( "~" ); //NOI18N
+    }
+
+    /**
+     * Dumps the name of an identifier expression.
+     * @param node the node to dump
+     */
+    public void arrive(IdentifierExpression node)
+    {   out.print( node.getName() );
+    }
+
+    /**
+     * Dumps a not expression.
+     * It is dumped like <code>!expression</code>.
+     * @param node the node to dump
+     */
+    public void arrive(NotExpression node)
+    {   out.print( "!" ); //NOI18N
+    }
+
+    /**
+     * Unary minus expressions are dumped like <code>-expression</code>.
+     * @param node the node to dump
+     */
+    public void arrive(UnaryMinusExpression node)
+    {   out.print( "-" ); //NOI18N
+    }
+
+    /**
+     * Field access expressions are dumped like <code>target.fieldName</code>.
+     * @param node the node to dump
+     */
+    public Object leave(FieldAccessExpression node, Object[] results)
+    {   out.print( "."+node.getName() ); //NOI18N
+        return null;
+    }
+
+    /**
+     * Query trees are dumped like 
+     * <code>orderingExpressions, filterExpression</code>.
+     * @param node the node to dump
+     */
+    public Object leave(QueryTree node, Object[] results)
+    {   out.println();
+        return null;
+    }
+
+
+    /**
+     * A logical and expression is dumped like
+     * <code>(leftExpression & rightExpression)</code>.
+     * @param node the parent node of the children currently dumped
+     * @param resultOfPreviousChild an array of <code>null</code> instances
+     * @param indexOfNextChild the index of the next child to be dumped
+     * @return <code>true</code>
+     */
+    public boolean walkNextChild(AndExpression node, 
+                                 Object resultOfPreviousChild, 
+                                 int indexOfNextChild)
+    {   if( indexOfNextChild==1 )
+            out.print( " & " ); //NOI18N
+        return true;
+    }
+
+    /**
+     * A conditional and expression is dumped like
+     * <code>(leftExpression && rightExpression)</code>.
+     * @param node the parent node of the children currently dumped
+     * @param resultOfPreviousChild an array of <code>null</code> instances
+     * @param indexOfNextChild the index of the next child to be dumped
+     * @return <code>true</code>
+     */
+    public boolean walkNextChild(ConditionalAndExpression node, 
+                                 Object resultOfPreviousChild, 
+                                 int indexOfNextChild)
+    {   if( indexOfNextChild==1 )
+            out.print( " && " ); //NOI18N
+        return true;
+    }
+
+    /**
+     * A logical or expression is dumped like
+     * <code>(leftExpression || rightExpression)</code>.
+     * @param node the parent node of the children currently dumped
+     * @param resultOfPreviousChild an array of <code>null</code> instances
+     * @param indexOfNextChild the index of the next child to be dumped
+     * @return <code>true</code>
+     */
+    public boolean walkNextChild(ConditionalOrExpression node, 
+                                 Object resultOfPreviousChild, 
+                                 int indexOfNextChild)
+    {   if( indexOfNextChild==1 )
+            out.print( " || " ); //NOI18N
+        return true;
+    }
+
+    /**
+     * A divide expression is dumped like
+     * <code>(leftExpression / rightExpression)</code>.
+     * @param node the parent node of the children currently dumped
+     * @param resultOfPreviousChild an array of <code>null</code> instances
+     * @param indexOfNextChild the index of the next child to be dumped
+     * @return <code>true</code>
+     */
+    public boolean walkNextChild(DivideExpression node, 
+                                 Object resultOfPreviousChild, 
+                                 int indexOfNextChild)
+    {   if( indexOfNextChild==1 )
+            out.print( " / " ); //NOI18N
+        return true;
+    }
+
+    /**
+     * An equals expression is dumped like
+     * <code>(leftExpression == rightExpression)</code>.
+     * @param node the parent node of the children currently dumped
+     * @param resultOfPreviousChild an array of <code>null</code> instances
+     * @param indexOfNextChild the index of the next child to be dumped
+     * @return <code>true</code>
+     */
+    public boolean walkNextChild(EqualsExpression node, 
+                                 Object resultOfPreviousChild, 
+                                 int indexOfNextChild)
+    {   if( indexOfNextChild==1 )
+            out.print( " == " ); //NOI18N
+        return true;
+    }
+
+    /**
+     * A greater than equals expression is dumped like
+     * <code>(leftExpression >= rightExpression)</code>.
+     * @param node the parent node of the children currently dumped
+     * @param resultOfPreviousChild an array of <code>null</code> instances
+     * @param indexOfNextChild the index of the next child to be dumped
+     * @return <code>true</code>
+     */
+    public boolean walkNextChild(GreaterThanEqualsExpression node, 
+                                 Object resultOfPreviousChild,
+                                 int indexOfNextChild)
+    {   if( indexOfNextChild==1 )
+            out.print( " >= " ); //NOI18N
+        return true;
+    }
+
+    /**
+     * A greater than expression is dumped like
+     * <code>(leftExpression > rightExpression)</code>.
+     * @param node the parent node of the children currently dumped
+     * @param resultOfPreviousChild an array of <code>null</code> instances
+     * @param indexOfNextChild the index of the next child to be dumped
+     * @return <code>true</code>
+     */
+    public boolean walkNextChild(GreaterThanExpression node, 
+                                 Object resultOfPreviousChild, 
+                                 int indexOfNextChild)
+    {   if( indexOfNextChild==1 )
+            out.print( " > " ); //NOI18N
+        return true;
+    }
+
+    /**
+     * A less than equals expression is dumped like
+     * <code>(leftExpression <= rightExpression)</code>.
+     * @param node the parent node of the children currently dumped
+     * @param resultOfPreviousChild an array of <code>null</code> instances
+     * @param indexOfNextChild the index of the next child to be dumped
+     * @return <code>true</code>
+     */
+    public boolean walkNextChild(LessThanEqualsExpression node, 
+                                 Object resultOfPreviousChild, 
+                                 int indexOfNextChild)
+    {   if( indexOfNextChild==1 )
+            out.print( " <= " ); //NOI18N
+        return true;
+    }
+
+    /**
+     * A less than expression is dumped like
+     * <code>(leftExpression < rightExpression)</code>.
+     * @param node the parent node of the children currently dumped
+     * @param resultOfPreviousChild an array of <code>null</code> instances
+     * @param indexOfNextChild the index of the next child to be dumped
+     * @return <code>true</code>
+     */
+    public boolean walkNextChild(LessThanExpression node, 
+                                 Object resultOfPreviousChild, 
+                                 int indexOfNextChild)
+    {   if( indexOfNextChild==1 )
+            out.print( " < " ); //NOI18N
+        return true;
+    }
+
+    /**
+     * A minus expression is dumped like
+     * <code>(leftExpression - rightExpression)</code>.
+     * @param node the parent node of the children currently dumped
+     * @param resultOfPreviousChild an array of <code>null</code> instances
+     * @param indexOfNextChild the index of the next child to be dumped
+     * @return <code>true</code>
+     */
+    public boolean walkNextChild(MinusExpression node, 
+                                 Object resultOfPreviousChild, 
+                                 int indexOfNextChild)
+    {   if( indexOfNextChild==1 )
+            out.print( " - " ); //NOI18N
+        return true;
+    }
+
+    /**
+     * Dumps a not equals expression.
+     * It is dumped like <code>(leftExpression != rightExpression)</code>.
+     * @param node the parent node of the children currently dumped
+     * @param resultOfPreviousChild an array of <code>null</code> instances
+     * @param indexOfNextChild the index of the next child to be dumped
+     * @return <code>true</code>
+     */
+    public boolean walkNextChild(NotEqualsExpression node, 
+                                 Object resultOfPreviousChild, 
+                                 int indexOfNextChild)
+    {   if( indexOfNextChild==1 )
+            out.print( " != " ); //NOI18N
+        return true;
+    }
+
+    /**
+     * A logical or expression is dumped like
+     * <code>(leftExpression | rightExpression)</code>.
+     * @param node the parent node of the children currently dumped
+     * @param resultOfPreviousChild an array of <code>null</code> instances
+     * @param indexOfNextChild the index of the next child to be dumped
+     * @return <code>true</code>
+     */
+    public boolean walkNextChild(OrExpression node, 
+                                 Object resultOfPreviousChild, 
+                                 int indexOfNextChild)
+    {   if( indexOfNextChild==1 )
+            out.print( " | " ); //NOI18N
+        return true;
+    }
+
+    /**
+     * Query trees are dumped like <code>orderingExpressions, 
+     * filterExpression</code>.
+     * @param node the parent node of the children currently dumped
+     * @param resultOfPreviousChild an array of <code>null</code> instances
+     * @param indexOfNextChild the index of the next child to be dumped
+     * @return <code>true</code>
+     */
+    public boolean walkNextChild(QueryTree node, 
+                                 Object resultOfPreviousChild, 
+                                 int indexOfNextChild)
+    {   Object[] children = node.getChildren();
+        if( indexOfNextChild!=0 &&
+            (children[indexOfNextChild-1] instanceof OrderingExpression &&
+             (children[indexOfNextChild] instanceof OrderingExpression ||
+              children[indexOfNextChild] instanceof Expression)) )
+            out.print( ", " ); //NOI18N
+        return true;
+    }
+
+    /**
+     * A plus expression is dumped like
+     * <code>(leftExpression + rightExpression)</code>.
+     * @param node the parent node of the children currently dumped
+     * @param resultOfPreviousChild an array of <code>null</code> instances
+     * @param indexOfNextChild the index of the next child to be dumped
+     * @return <code>true</code>
+     */
+    public boolean walkNextChild(PlusExpression node, 
+                                 Object resultOfPreviousChild, 
+                                 int indexOfNextChild)
+    {   if( indexOfNextChild==1 )
+            out.print( " + " ); //NOI18N
+        return true;
+    }
+
+    /**
+     * A times expression is dumped like
+     * <code>(leftExpression * rightExpression)</code>.
+     * @param node the parent node of the children currently dumped
+     * @param resultOfPreviousChild an array of <code>null</code> instances
+     * @param indexOfNextChild the index of the next child to be dumped
+     * @return <code>true</code>
+     */
+    public boolean walkNextChild(TimesExpression node, 
+                                 Object resultOfPreviousChild, 
+                                 int indexOfNextChild)
+    {   if( indexOfNextChild==1 )
+            out.print( " * " ); //NOI18N
+        return true;
+    }
+}

Added: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/FloatLiteralExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/FloatLiteralExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/FloatLiteralExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/FloatLiteralExpr.java Sun May 22 11:08:57 2005
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.impl.jdoql.tree;
+
+import org.apache.jdo.impl.jdoql.jdoqlc.JDOQLTokenTypes;
+import org.apache.jdo.jdoql.tree.FloatLiteralExpression;
+import org.apache.jdo.jdoql.tree.NodeVisitor;
+
+
+/**
+ * This node represents a float literal. It does not have any children.
+ *
+ * @author Michael Watzek
+ */
+public final class FloatLiteralExpr
+    extends ConstantExpr implements FloatLiteralExpression
+{
+    /**
+     * The noarg constructor is needed for ANTLR support and deserialization.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public FloatLiteralExpr()
+    {}
+
+    /**
+     * The noarg constructor is needed for ANTLR support.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public FloatLiteralExpr(antlr.Token token)
+    {   initialize( token );
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param f the float value
+     */
+    FloatLiteralExpr(Float f)
+    {   super( JDOQLTokenTypes.FLOAT_LITERAL, f.toString(), f ); //NOI18N
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param f the float value
+     */
+    FloatLiteralExpr(float f)
+    {   this( new Float(f) );
+    }
+
+    /**
+     * Returns the float value represented by this expression.
+     * @return the float value
+     */
+    public float getFloat()
+    {   return ((Float)this.value).floatValue();
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     */
+    public void arrive(NodeVisitor visitor)
+    {   visitor.arrive( this );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     * @param results the result array
+     * @return the object returned by the visitor instance
+     */
+    public Object leave(NodeVisitor visitor, Object[] results)
+    {   return visitor.leave( this, results );
+    }
+}

Added: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/GreaterThanEqualsExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/GreaterThanEqualsExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/GreaterThanEqualsExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/GreaterThanEqualsExpr.java Sun May 22 11:08:57 2005
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.impl.jdoql.tree;
+
+import org.apache.jdo.impl.jdoql.jdoqlc.JDOQLTokenTypes;
+import org.apache.jdo.jdoql.tree.Expression;
+import org.apache.jdo.jdoql.tree.GreaterThanEqualsExpression;
+import org.apache.jdo.jdoql.tree.NodeVisitor;
+
+
+/**
+ * This node represents a greater than equals operator.
+ * A greater than equals operator is a binary expression.
+ * The string representation of this operator is <code>>=</code>.
+ *
+ * @author Michael Watzek
+ */
+public final class GreaterThanEqualsExpr
+    extends BinaryExpr implements GreaterThanEqualsExpression
+{
+    /**
+     * The noarg constructor is needed for ANTLR support and deserialization.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public GreaterThanEqualsExpr()
+    {}
+
+    /**
+     * The noarg constructor is needed for ANTLR support.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public GreaterThanEqualsExpr(antlr.Token token)
+    {   initialize( token );
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param left the first child
+     * @param right the second child
+     */
+    GreaterThanEqualsExpr(Expression left, Expression right)
+    {   super( JDOQLTokenTypes.GE, "GreaterThanEquals", Boolean.class, left,
+               right ); //NOI18N
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     */
+    public void arrive(NodeVisitor visitor)
+    {   visitor.arrive( this );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     * @param results the result array
+     * @return the object returned by the visitor instance
+     */
+    public Object leave(NodeVisitor visitor, Object[] results)
+    {   return visitor.leave( this, results );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     * @param resultOfPreviousChild the result computed by leaving the
+     * previous child node
+     * @param indexOfNextChild the index in the children array of the
+     * next child to walk
+     * @return the boolean value returned by the visitor instance
+     */
+    public boolean walkNextChild(NodeVisitor visitor,
+                                 Object resultOfPreviousChild,
+                                 int indexOfNextChild)
+    {   return visitor.walkNextChild( this, resultOfPreviousChild,
+                                      indexOfNextChild );
+    }
+}

Added: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/GreaterThanExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/GreaterThanExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/GreaterThanExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/GreaterThanExpr.java Sun May 22 11:08:57 2005
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.impl.jdoql.tree;
+
+import org.apache.jdo.impl.jdoql.jdoqlc.JDOQLTokenTypes;
+import org.apache.jdo.jdoql.tree.Expression;
+import org.apache.jdo.jdoql.tree.GreaterThanExpression;
+import org.apache.jdo.jdoql.tree.NodeVisitor;
+
+
+/**
+ * This node represents a greater than operator.
+ * A greater equals operator is a binary expression.
+ * The string representation of this operator is <code>></code>.
+ *
+ * @author Michael Watzek
+ */
+public final class GreaterThanExpr
+    extends BinaryExpr implements GreaterThanExpression
+{
+    /**
+     * The noarg constructor is needed for ANTLR support and deserialization.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public GreaterThanExpr()
+    {}
+
+    /**
+     * The noarg constructor is needed for ANTLR support.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public GreaterThanExpr(antlr.Token token)
+    {   initialize( token );
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param left the first child
+     * @param right the second child
+     */
+    GreaterThanExpr(Expression left, Expression right)
+    {   super( JDOQLTokenTypes.GT, "GreaterThan", Boolean.class, left, right ); //NOI18N
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     */
+    public void arrive(NodeVisitor visitor)
+    {   visitor.arrive( this );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     * @param results the result array
+     * @return the object returned by the visitor instance
+     */
+    public Object leave(NodeVisitor visitor, Object[] results)
+    {   return visitor.leave( this, results );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     * @param resultOfPreviousChild the result computed by leaving the
+     * previous child node
+     * @param indexOfNextChild the index in the children array of the
+     * next child to walk
+     * @return the boolean value returned by the visitor instance
+     */
+    public boolean walkNextChild(NodeVisitor visitor,
+                                 Object resultOfPreviousChild,
+                                 int indexOfNextChild)
+    {   return visitor.walkNextChild( this, resultOfPreviousChild,
+                                      indexOfNextChild );
+    }
+}

Added: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/IdentifierExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/IdentifierExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/IdentifierExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/IdentifierExpr.java Sun May 22 11:08:57 2005
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.impl.jdoql.tree;
+
+import org.apache.jdo.jdoql.tree.Declaration;
+import org.apache.jdo.jdoql.tree.IdentifierExpression;
+import org.apache.jdo.jdoql.tree.NodeVisitor;
+
+/**
+ * This node represents an identifier expression.
+ * Examples of identifier expressions are
+ * <code>FieldAccessExpression</code>, <code>ParameterAccessExpression</code>,
+ * <code>ThisExpression</code>or <code>VariableAccessExpression</code>.
+ * This class is not defined
+ * <code>abstract</code> to allow the syntactical analysis to
+ * construct general nodes, which are replaced by the semantic analysis
+ * with their specialized counterparts.
+ *
+ * @author Michael Watzek
+ */
+public class IdentifierExpr extends Expr implements IdentifierExpression
+{
+    /**
+     * The noarg constructor is needed for ANTLR support and deserialization.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public IdentifierExpr()
+    {}
+
+    /**
+     * The noarg constructor is needed for ANTLR support.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public IdentifierExpr(antlr.Token token)
+    {   initialize( token );
+    }
+
+    /**
+     * This constructor is called by specialized nodes.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     * @param tokenType the token type
+     * @param name the name of this identifier
+     * @param clazz the Java type of this identifier
+     */
+    IdentifierExpr(int tokenType, String name, Class clazz)
+    {   super( tokenType, name, clazz );
+    }
+
+    /**
+     * Returns the name of the specialized identifier.
+     * @return the name
+     */
+    public String getName()
+    {   return getText();
+    }
+
+    /**
+     * Returns the Java type name of the specialized identifier.
+     * @return the Java type name
+     */
+    public String getTypeName()
+    {   return getJavaClass().getName();
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     */
+    public void arrive(NodeVisitor visitor)
+    {   visitor.arrive( this );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     * @param results the result array
+     * @return the object returned by the visitor instance
+     */
+    public Object leave(NodeVisitor visitor, Object[] results)
+    {   return visitor.leave( this, results );
+    }
+
+}

Added: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/IntLiteralExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/IntLiteralExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/IntLiteralExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/IntLiteralExpr.java Sun May 22 11:08:57 2005
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.impl.jdoql.tree;
+
+import org.apache.jdo.impl.jdoql.jdoqlc.JDOQLTokenTypes;
+import org.apache.jdo.jdoql.tree.IntLiteralExpression;
+import org.apache.jdo.jdoql.tree.NodeVisitor;
+
+
+/**
+ * This node represents a integer literal. It does not have any children.
+ *
+ * @author Michael Watzek
+ */
+public final class IntLiteralExpr
+    extends ConstantExpr implements IntLiteralExpression
+{
+    /**
+     * The noarg constructor is needed for ANTLR support and deserialization.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public IntLiteralExpr()
+    {}
+
+    /**
+     * The noarg constructor is needed for ANTLR support.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public IntLiteralExpr(antlr.Token token)
+    {   initialize( token );
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param i the int value
+     */
+    IntLiteralExpr(Integer i)
+    {   super( JDOQLTokenTypes.INT_LITERAL, i.toString(), i ); //NOI18N
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param i the int value
+     */
+    IntLiteralExpr(int i)
+    {   this( new Integer(i) );
+    }
+
+    /**
+     * Returns the int value represented by this expression.
+     * @return the int value
+     */
+    public int getInt()
+    {   return ((Integer)this.value).intValue();
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     */
+    public void arrive(NodeVisitor visitor)
+    {   visitor.arrive( this );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     * @param results the result array
+     * @return the object returned by the visitor instance
+     */
+    public Object leave(NodeVisitor visitor, Object[] results)
+    {   return visitor.leave( this, results );
+    }
+}

Added: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/IsEmptyCallExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/IsEmptyCallExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/IsEmptyCallExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/IsEmptyCallExpr.java Sun May 22 11:08:57 2005
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.impl.jdoql.tree;
+
+
+import java.util.Collection;
+
+import org.apache.jdo.impl.jdoql.jdoqlc.JDOQLTokenTypes;
+import org.apache.jdo.jdoql.JDOQueryException;
+import org.apache.jdo.jdoql.tree.Expression;
+import org.apache.jdo.jdoql.tree.IsEmptyCallExpression;
+import org.apache.jdo.jdoql.tree.NodeVisitor;
+
+
+/**
+ * This node represents the method call expression
+ * <code>Collection.isEmpty</code>. This node's child is a target
+ * expression (e.g. an instance of <code>FieldAccessExpression</code>).
+ *
+ * @author Michael Watzek
+ */
+public final class IsEmptyCallExpr
+    extends MethodCallExpr implements IsEmptyCallExpression
+{
+    /**
+     * The noarg constructor is needed for ANTLR support and deserialization.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public IsEmptyCallExpr()
+    {}
+
+    /**
+     * The noarg constructor is needed for ANTLR support.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public IsEmptyCallExpr(antlr.Token token)
+    {   initialize( token );
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param target the target expression of this method call
+     * @exception JDOQueryException if the result type of target is
+     * not a collection type
+     */
+    IsEmptyCallExpr(Expression target)
+    {   super( JDOQLTokenTypes.IS_EMPTY, "isEmpty", Boolean.class,
+               target, null ); //NOI18N
+        if( target.getJavaClass()!=null &&
+            !Collection.class.isAssignableFrom(target.getJavaClass()) )
+            throw new JDOQueryException(
+                msg.msg("EXC_NoCollectionType", target, this) ); //NOI18N
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     */
+    public void arrive(NodeVisitor visitor)
+    {   visitor.arrive( this );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     * @param results the result array
+     * @return the object returned by the visitor instance
+     */
+    public Object leave(NodeVisitor visitor, Object[] results)
+    {   return visitor.leave( this, results );
+    }
+}

Added: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/LessThanEqualsExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/LessThanEqualsExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/LessThanEqualsExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/LessThanEqualsExpr.java Sun May 22 11:08:57 2005
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.impl.jdoql.tree;
+
+import org.apache.jdo.impl.jdoql.jdoqlc.JDOQLTokenTypes;
+import org.apache.jdo.jdoql.tree.Expression;
+import org.apache.jdo.jdoql.tree.LessThanEqualsExpression;
+import org.apache.jdo.jdoql.tree.NodeVisitor;
+
+
+/**
+ * This node represents a less than equals operator.
+ * A less than equals operator is a binary expression.
+ * The string representation of this operator is <code><=</code>.
+ *
+ * @author Michael Watzek
+ */
+public final class LessThanEqualsExpr
+    extends BinaryExpr implements LessThanEqualsExpression
+{
+    /**
+     * The noarg constructor is needed for ANTLR support and deserialization.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public LessThanEqualsExpr()
+    {}
+
+    /**
+     * The noarg constructor is needed for ANTLR support.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public LessThanEqualsExpr(antlr.Token token)
+    {   initialize( token );
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param left the first child
+     * @param right the second child
+     */
+    LessThanEqualsExpr(Expression left, Expression right)
+    {   super( JDOQLTokenTypes.LE, "LessThanEquals", Boolean.class, left,
+               right ); //NOI18N
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     */
+    public void arrive(NodeVisitor visitor)
+    {   visitor.arrive( this );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     * @param results the result array
+     * @return the object returned by the visitor instance
+     */
+    public Object leave(NodeVisitor visitor, Object[] results)
+    {   return visitor.leave( this, results );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     * @param resultOfPreviousChild the result computed by leaving the
+     * previous child node
+     * @param indexOfNextChild the index in the children array of the
+     * next child to walk
+     * @return the boolean value returned by the visitor instance
+     */
+    public boolean walkNextChild(NodeVisitor visitor,
+                                 Object resultOfPreviousChild,
+                                 int indexOfNextChild)
+    {   return visitor.walkNextChild( this, resultOfPreviousChild,
+                                      indexOfNextChild );
+    }
+}

Added: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/LessThanExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/LessThanExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/LessThanExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/LessThanExpr.java Sun May 22 11:08:57 2005
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.impl.jdoql.tree;
+
+import org.apache.jdo.impl.jdoql.jdoqlc.JDOQLTokenTypes;
+import org.apache.jdo.jdoql.tree.Expression;
+import org.apache.jdo.jdoql.tree.LessThanExpression;
+import org.apache.jdo.jdoql.tree.NodeVisitor;
+
+
+/**
+ * This node represents a less than operator.
+ * A less than operator is a binary expression.
+ * The string representation of this operator is <code><</code>.
+ *
+ * @author Michael Watzek
+ */
+public final class LessThanExpr extends BinaryExpr implements LessThanExpression
+{
+    /**
+     * The noarg constructor is needed for ANTLR support and deserialization.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public LessThanExpr()
+    {}
+
+    /**
+     * The noarg constructor is needed for ANTLR support.
+     * The caller must make sure to set the ANTLR tree structure himself
+     * or, call <code>setChildren</code> optionally.
+     */
+    public LessThanExpr(antlr.Token token)
+    {   initialize( token );
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param left the first child
+     * @param right the second child
+     */
+    LessThanExpr(Expression left, Expression right)
+    {   super( JDOQLTokenTypes.LT, "LessThan", Boolean.class, left, right ); //NOI18N
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     */
+    public void arrive(NodeVisitor visitor)
+    {   visitor.arrive( this );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     * @param results the result array
+     * @return the object returned by the visitor instance
+     */
+    public Object leave(NodeVisitor visitor, Object[] results)
+    {   return visitor.leave( this, results );
+    }
+
+    /**
+     * Delegates to the argument <code>visitor</code>.
+     * @param visitor the node visitor
+     * @param resultOfPreviousChild the result computed by leaving the
+     * previous child node
+     * @param indexOfNextChild the index in the children array of the
+     * next child to walk
+     * @return the boolean value returned by the visitor instance
+     */
+    public boolean walkNextChild(NodeVisitor visitor,
+                                 Object resultOfPreviousChild,
+                                 int indexOfNextChild)
+    {   return visitor.walkNextChild( this, resultOfPreviousChild,
+                                      indexOfNextChild );
+    }
+}