db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r171353 [8/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/
Date Sun, 22 May 2005 18:09:00 GMT
Added: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/LongLiteralExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/LongLiteralExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/LongLiteralExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/LongLiteralExpr.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.LongLiteralExpression;
+import org.apache.jdo.jdoql.tree.NodeVisitor;
+
+
+/**
+ * This node represents a long literal. It does not have any children.
+ *
+ * @author Michael Watzek
+ */
+public final class LongLiteralExpr
+    extends ConstantExpr implements LongLiteralExpression
+{
+    /**
+     * 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 LongLiteralExpr()
+    {}
+
+    /**
+     * 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 LongLiteralExpr(antlr.Token token)
+    {   initialize( token );
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param l the long value
+     */
+    LongLiteralExpr(Long l)
+    {   super( JDOQLTokenTypes.LONG_LITERAL, l.toString(), l ); //NOI18N
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param l the long value
+     */
+    LongLiteralExpr(long l)
+    {   this( new Long(l) );
+    }
+
+    /**
+     * Returns the long value represented by this expression.
+     * @return the long value
+     */
+    public long getLong()
+    {   return ((Long)this.value).longValue();
+    }
+
+    /**
+     * 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/MethodCallExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/MethodCallExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/MethodCallExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/MethodCallExpr.java Sun May 22 11:08:57 2005
@@ -0,0 +1,114 @@
+/*
+ * 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;
+import org.apache.jdo.jdoql.tree.MethodCallExpression;
+import org.apache.jdo.jdoql.tree.Node;
+
+/**
+ * This node represents a method call expression.
+ * Examples of method call expressions are
+ * <code>ContainsCallExpression</code>, <code>IsEmptyCallExpression</code>,
+ * <code>EndsWithCallExpression</code> and
+ * <code>StartsWithCallExpression</code>.
+ *
+ * @author Michael Watzek
+ */
+public abstract class MethodCallExpr extends Expr implements MethodCallExpression
+{
+    Expression[] args;
+
+    /**
+     * 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 MethodCallExpr()
+    {}
+
+    /**
+     * This constructor is called by specialized nodes.
+     * It calls <code>setChildren</code> in order to initialize the node's
+     * child <code>expr</code>.
+     * @param tokenType the token tpye
+     * @param tokenName the name of this node
+     * @param clazz the Java type of this node
+     * @param target the target expression of this method call
+     * @param args the arguments of this method call
+     */
+    MethodCallExpr(int tokenType, String tokenName, Class clazz, Expression target, Expression[] args)
+    {   super( tokenType, tokenName, clazz );
+        this.args = args;
+        int nrOfChildren = 1;
+        if( args!=null )
+            nrOfChildren += args.length;
+        Node[] children = new Node[nrOfChildren];
+        children[0] = target;
+        if( args!=null )
+            System.arraycopy( args, 0, children, 1, args.length );
+        setChildren( children );
+    }
+
+    /**
+     * Creates and returns a copy of this object.
+     * @return the copy
+     * @exception CloneNotSupportedException thrown by <code>super.clone()</code>
+     */
+    protected Object clone() throws CloneNotSupportedException
+    {   MethodCallExpr copy = (MethodCallExpr) super.clone();
+        copy.args = null;
+        return copy;
+    }
+
+    /**
+     * Returns the target expression of this method call.
+     * 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 method name.
+     * @return the method name
+     */
+    public String getMethodName()
+    {   return getText();
+    }
+
+    /**
+     * Returns the argument array of this method call.
+     * @return the argument array
+     */
+    public Expression[] getArguments()
+    {   ASTToChildren();
+        if( args==null &&
+            this.children.length>1 )
+        {   this.args = new Expression[this.children.length-1];
+            System.arraycopy( this.children, 1, this.args, 0, this.args.length );
+        }
+        return args;
+    }
+}

Added: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/MinusExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/MinusExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/MinusExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/MinusExpr.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.MinusExpression;
+import org.apache.jdo.jdoql.tree.NodeVisitor;
+
+
+/**
+ * This node represents a binary minus operator.
+ * The string representation of this operator is <code>-</code>.
+ *
+ * @author Michael Watzek
+ */
+public final class MinusExpr extends BinaryExpr implements MinusExpression
+{
+    /**
+     * 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 MinusExpr()
+    {}
+
+    /**
+     * 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 MinusExpr(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
+     */
+    MinusExpr(Expression left, Expression right)
+    {   super( JDOQLTokenTypes.MINUS, "Minus", 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/NodeImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/NodeImpl.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/NodeImpl.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/NodeImpl.java Sun May 22 11:08:57 2005
@@ -0,0 +1,259 @@
+/*
+ * 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.*;
+import java.util.HashMap;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.apache.jdo.impl.jdoql.jdoqlc.JDOQLAST;
+import org.apache.jdo.impl.model.java.runtime.RuntimeJavaModelFactory;
+import org.apache.jdo.jdoql.JDOQueryException;
+import org.apache.jdo.jdoql.tree.Node;
+import org.apache.jdo.jdoql.tree.NodeVisitor;
+import org.apache.jdo.util.I18NHelper;
+
+import antlr.collections.AST;
+
+
+/**
+ * This is the base class of all nodes. Examples of nodes are
+ * <CandidateClass</code>, <code>Declaration</code>, <code>Expression</code>
+ * and <code>OrderingExpression<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 NodeImpl extends JDOQLAST implements Node
+{
+    /** I18N support */
+    final static I18NHelper msg = I18NHelper.getInstance(
+        "org.apache.jdo.impl.jdoql.Bundle", NodeImpl.class.getClassLoader()); //NOI18N
+
+    /** RuntimeJavaModelFactory. */
+    private static final RuntimeJavaModelFactory javaModelFactory =
+        (RuntimeJavaModelFactory) AccessController.doPrivileged(
+            new PrivilegedAction () {
+                public Object run () {
+                    return RuntimeJavaModelFactory.getInstance();
+                }
+            }
+        );
+
+    Node parent = null;
+    Node[] children = null;
+    Object object = null;
+    transient Class clazz = null;
+
+    /**
+     * 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 NodeImpl()
+    {}
+
+    /**
+     * 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 NodeImpl(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 tpye
+     * @param tokenName the name of this node
+     * @param clazz the Java type of this node
+     */
+    NodeImpl(int tokenType, String tokenName, Class clazz)
+    {   initialize( tokenType, tokenName );
+        this.clazz = clazz;
+    }
+
+    /**
+     * Creates and returns a copy of this object nullifying fields
+     * <code>parent</code>, <code>children</code> and <code>clazz</code>.
+     * @return the copy
+     * @exception CloneNotSupportedException thrown by <code>super.clone()</code>
+     */
+    protected Object clone() throws CloneNotSupportedException
+    {   NodeImpl copy = (NodeImpl) super.clone();
+        copy.parent = null;
+        copy.children = null;
+        return copy;
+    }
+
+    public String toString()
+    {   if( getTypeInfo()==null )
+            return getText();
+        else
+            return super.toString();
+    }
+
+
+    /**
+     * Returns the Java type of this node.
+     * @return the Java type
+     */
+    public Class getJavaClass()
+    {   if( this.clazz==null &&
+            getTypeInfo()!=null )
+            this.clazz = javaModelFactory.getJavaClass(getTypeInfo());
+        return this.clazz;
+    }
+
+    /**
+     * Returns the token type of this node.
+     * @return the token type
+     */
+    public int getTokenType()
+    {   return getType();
+    }
+
+    /**
+     * Returns the user object.
+     * @return the ouser object
+     */
+    public Object getObject()
+    {   return this.object;
+    }
+
+    /**
+     * Sets the user object.
+     * @param object the user object
+     */
+    public void setObject(Object object)
+    {   this.object = object;
+    }
+
+    /**
+     * Returns this node's parent node.
+     * @return the parent node
+     */
+    public Node getParent()
+    {   return this.parent;
+    }
+
+    /**
+     * Sets the parent of this node.
+     * @param parent the parent node
+     */
+    public void setParent(Node parent)
+    {   this.parent = parent;
+    }
+
+    /**
+     * Returns this node's children.
+     * Ensures that this node's children corresponds with the underlying
+     * ANTLR tree structure.
+     * @return the children
+     */
+    public Node[] getChildren()
+    {   ASTToChildren();
+        return this.children;
+    }
+
+    /**
+     * Implements a noop as a default implementation.
+     * @param visitor the node visitor
+     */
+    public void arrive(NodeVisitor visitor)
+    {}
+
+    /**
+     * Returns <code>null</code> as a default implementation.
+     * @param visitor the node visitor
+     * @param results the result array containing result instances of
+     * this node's children
+     */
+    public Object leave(NodeVisitor visitor, Object[] results)
+    {   return null;
+    }
+
+    /**
+     * Returns <code>true</code> as a default implementation.
+     * @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 <code>true</code>
+     */
+    public boolean walkNextChild(NodeVisitor visitor,
+                                 Object resultOfPreviousChild,
+                                 int indexOfNextChild)
+    {   return true;
+    }
+
+    /**
+     * Sets the children of this node specified by the argument
+     * <code>children</code>.
+     * It is called in constructors of specialized nodes. These
+     * constructors are called by factory methods
+     * when you build the tree yourself.
+     * @param children the child nodes
+     * @exception JDOQueryException if an instance in the children
+     * array is <code>null</code> or already has a parent node
+     */
+    void setChildren(Node[] children)
+    {   if( children!=null )
+        {   setFirstChild( null );
+            for( int i=0; i<children.length; i++ )
+            {   Node current = children[i];
+                if( current==null )
+                    throw new JDOQueryException(
+                        msg.msg("EXC_CannotProcessNullNodes", this) ); //NOI18N
+                if( current.getParent()!=null )
+                    throw new JDOQueryException(
+                        msg.msg("EXC_CannotReuseNodes", current, 
+                                current.getParent()) ); //NOI18N
+                current.setParent( this );
+                if( current instanceof AST )
+                    addChild( (AST) current );
+        }   }
+        this.children = children;
+        this.parent = null;
+    }
+
+    /**
+     * This method initializes the children of this node
+     * based on underlying ANTLR tree structure.
+     * It is called in method <code>getChildren</code> of this class.
+     */
+    void ASTToChildren()
+    {   if( this.children==null )
+        {   int nrOfChildren;
+            AST current = getFirstChild();
+            for( nrOfChildren=0; current!=null; nrOfChildren++ )
+                current = current.getNextSibling();
+            if( nrOfChildren!=0 )
+            {   this.children = new Node[nrOfChildren];
+                current = getFirstChild();
+                for( nrOfChildren=0; current!=null; nrOfChildren++ )
+                {   this.children[nrOfChildren] = (Node) current;
+                    current = current.getNextSibling();
+        }   }   }
+    }
+}

Added: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/NotEqualsExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/NotEqualsExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/NotEqualsExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/NotEqualsExpr.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.NodeVisitor;
+import org.apache.jdo.jdoql.tree.NotEqualsExpression;
+
+
+/**
+ * This node represents a not equals operator.
+ * A not equals operator is a binary expression.
+ * The string representation of this operator is <code>!=</code>.
+ *
+ * @author Michael Watzek
+ */
+public final class NotEqualsExpr
+    extends BinaryExpr implements NotEqualsExpression
+{
+    /**
+     * 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 NotEqualsExpr()
+    {}
+
+    /**
+     * 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 NotEqualsExpr(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
+     */
+    NotEqualsExpr(Expression left, Expression right)
+    {   super( JDOQLTokenTypes.NOT_EQUAL, "NotEquals", 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/NotExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/NotExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/NotExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/NotExpr.java Sun May 22 11:08:57 2005
@@ -0,0 +1,77 @@
+/*
+ * 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.NodeVisitor;
+import org.apache.jdo.jdoql.tree.NotExpression;
+
+
+/**
+ * This node represents a logical not operator.
+ * A logical not operator is a unary expression.
+ * The string representation of this operator is <code>!</code>.
+ *
+ * @author Michael Watzek
+ */
+public final class NotExpr extends UnaryExpr implements NotExpression
+{
+    /**
+     * 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 NotExpr()
+    {}
+
+    /**
+     * 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 NotExpr(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 to compute the complement for
+     */
+    NotExpr(Expression expr)
+    {   super( JDOQLTokenTypes.LNOT, "Not", 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/OrExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/OrExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/OrExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/OrExpr.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.NodeVisitor;
+import org.apache.jdo.jdoql.tree.OrExpression;
+
+
+/**
+ * This node represents a logical or operator.
+ * A logical operator is based on boolean types.
+ * The string representation of this operator is <code>|</code>.
+ *
+ * @author Michael Watzek
+ */
+public final class OrExpr extends BinaryExpr implements OrExpression
+{
+    /**
+     * 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 OrExpr()
+    {}
+
+    /**
+     * 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 OrExpr(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
+     */
+    OrExpr(Expression left, Expression right)
+    {   super( JDOQLTokenTypes.BOR, "Or", 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/OrderingExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/OrderingExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/OrderingExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/OrderingExpr.java Sun May 22 11:08:57 2005
@@ -0,0 +1,64 @@
+/*
+ * 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;
+import org.apache.jdo.jdoql.tree.Node;
+import org.apache.jdo.jdoql.tree.OrderingExpression;
+
+/**
+ * This node represents an ordering expression. Examples of ordering expressions
+ * are <code>AscendingOrderingExpression</code> and
+ * <code>DescendingOrderingExpression</code>.
+ *
+ * @author Michael Watzek
+ */
+public abstract class OrderingExpr extends NodeImpl implements OrderingExpression
+{
+    /**
+     * 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 OrderingExpr()
+    {}
+
+    /**
+     * This constructor is called by specialized nodes.
+     * It calls <code>setChildren</code> in order to initialize the node's
+     * child <code>expr</code>.
+     * @param tokenType the token tpye
+     * @param tokenName the name of this node
+     * @param expr the expression defining the order
+     */
+    OrderingExpr(int tokenType, String tokenName, Expression expr)
+    {   super( tokenType, tokenName, expr.getJavaClass() );
+        setChildren( new Node[] {expr} );
+    }
+
+    /**
+     * Returns the node's ordering expression.
+     * @return the node's expression
+     */
+    public Expression getOrdering()
+    {   ASTToChildren();
+        if( this.children==null ||
+            this.children.length<1 )
+            return null;
+        return (Expression) this.children[0];
+    }
+}

Added: incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/ParameterAccessExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/ParameterAccessExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/ParameterAccessExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/ParameterAccessExpr.java Sun May 22 11:08:57 2005
@@ -0,0 +1,81 @@
+/*
+ * 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.Declaration;
+import org.apache.jdo.jdoql.tree.Expression;
+import org.apache.jdo.jdoql.tree.NodeVisitor;
+import org.apache.jdo.jdoql.tree.ParameterAccessExpression;
+
+
+/**
+ * This node represents a parameter access expression.
+ * It does not have any children.
+ *
+ * @author Michael Watzek
+ */
+public final class ParameterAccessExpr
+    extends IdentifierExpr implements ParameterAccessExpression
+{
+    /**
+     * 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 ParameterAccessExpr()
+    {}
+
+    /**
+     * 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 ParameterAccessExpr(antlr.Token token)
+    {   initialize( token );
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param clazz the Java type of this identifier
+     * @param name the name of this identifier
+     */
+    ParameterAccessExpr(Class clazz, String name)
+    {   super( JDOQLTokenTypes.PARAMETER_ACCESS, name,
+               Tree.toWrapperClass(clazz) );
+    }
+
+    /**
+     * 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/ParameterDecl.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/ParameterDecl.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/ParameterDecl.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/ParameterDecl.java Sun May 22 11:08:57 2005
@@ -0,0 +1,77 @@
+/*
+ * 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.NodeVisitor;
+import org.apache.jdo.jdoql.tree.ParameterDeclaration;
+import org.apache.jdo.jdoql.tree.Type;
+
+
+/**
+ * This node represents a parameter declaration.
+ * It does not have any children.
+ *
+ * @author Michael Watzek
+ */
+public final class ParameterDecl extends Decl implements ParameterDeclaration
+{
+    /**
+     * 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 ParameterDecl()
+    {}
+
+    /**
+     * 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 ParameterDecl(antlr.Token token)
+    {   initialize( token );
+    }
+
+    /**
+     * This constructor delegates to the super class constructor.
+     * @param type the type instance wrapping the Java class
+     * @param name the name of the parameter
+     */
+    ParameterDecl(Type type, String name)
+    {   super( JDOQLTokenTypes.PARAMETER_DECL, "ParameterDeclaration",
+               type, name ); //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/PlusExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/PlusExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/PlusExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/PlusExpr.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.NodeVisitor;
+import org.apache.jdo.jdoql.tree.PlusExpression;
+
+
+/**
+ * This node represents a binary plus operator.
+ * The string representation of this operator is <code>+</code>.
+ *
+ * @author Michael Watzek
+ */
+public final class PlusExpr extends BinaryExpr implements PlusExpression
+{
+    /**
+     * 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 PlusExpr()
+    {}
+
+    /**
+     * 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 PlusExpr(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
+     */
+    PlusExpr(Expression left, Expression right)
+    {   super( JDOQLTokenTypes.PLUS, "Plus", 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/ShortLiteralExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/ShortLiteralExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/ShortLiteralExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/ShortLiteralExpr.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.NodeVisitor;
+import org.apache.jdo.jdoql.tree.ShortLiteralExpression;
+
+
+/**
+ * This node represents a short literal. It does not have any children.
+ *
+ * @author Michael Watzek
+ */
+public final class ShortLiteralExpr
+    extends ConstantExpr implements ShortLiteralExpression
+{
+    /**
+     * 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 ShortLiteralExpr()
+    {}
+
+    /**
+     * 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 ShortLiteralExpr(antlr.Token token)
+    {   initialize( token );
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param s the short value
+     */
+    ShortLiteralExpr(Short s)
+    {   super( JDOQLTokenTypes.SHORT_LITERAL, s.toString(), s ); //NOI18N
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param s the short value
+     */
+    ShortLiteralExpr(short s)
+    {   this( new Short(s) );
+    }
+
+    /**
+     * Returns the short value represented by this expression.
+     * @return the short value
+     */
+    public short getShort()
+    {   return ((Short)this.value).shortValue();
+    }
+
+    /**
+     * 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/StartsWithCallExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/StartsWithCallExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/StartsWithCallExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/StartsWithCallExpr.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.Expression;
+import org.apache.jdo.jdoql.tree.NodeVisitor;
+import org.apache.jdo.jdoql.tree.StartsWithCallExpression;
+
+
+
+/**
+ * This node represents the method call expression
+ * <code>String.startsWith</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 StartsWithCallExpr
+    extends MethodCallExpr implements StartsWithCallExpression
+{
+    /**
+     * 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 StartsWithCallExpr()
+    {}
+
+    /**
+     * 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 StartsWithCallExpr(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
+     */
+    StartsWithCallExpr(Expression target, Expression[] args)
+    {   super( JDOQLTokenTypes.STARTS_WITH, "startsWith", 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
+     */
+    StartsWithCallExpr(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/StaticFieldAccessExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/StaticFieldAccessExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/StaticFieldAccessExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/StaticFieldAccessExpr.java Sun May 22 11:08:57 2005
@@ -0,0 +1,166 @@
+/*
+ * 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.tree.Node;
+import org.apache.jdo.jdoql.tree.NodeVisitor;
+import org.apache.jdo.jdoql.tree.StaticFieldAccessExpression;
+import org.apache.jdo.model.java.JavaField;
+import org.apache.jdo.model.java.JavaType;
+import org.apache.jdo.pm.PersistenceManagerInternal;
+
+import java.lang.reflect.Field;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * This node represents a static field access expression.
+ * It inherits from <code>FieldAccessExpr</code>.
+ * Static Field access expressions have exactly one child, the target expression.
+ * That target expression is an identifier expression.
+ *
+ * @author Michael Watzek
+ */
+public final class StaticFieldAccessExpr
+    extends IdentifierExpr implements StaticFieldAccessExpression
+{
+    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 StaticFieldAccessExpr()
+    {}
+
+    /**
+     * 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 StaticFieldAccessExpr(antlr.Token token)
+    {   initialize( token );
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param type the type of the instance wrapping the Java clazz
+     * defining the static field
+     * @param fieldName the field name of this static field access expression
+     * @exception JDOQueryException if the field cannot be found in the
+     * the result type of target.
+     */
+    StaticFieldAccessExpr(TypeImpl type, String fieldName)
+    {   super( JDOQLTokenTypes.STATIC_FIELD_ACCESS, fieldName, null );
+        setChildren( new Node[] {type} );
+        this.fieldName = 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 value of the field corresponding with this static
+     * field access expression.
+     * @param pm the persistence manager of the query
+     * @return the field value
+     * @exception JDOQueryException if access to the corresponding field of this
+     * expression is denied
+     */
+    public Object getFieldValue(PersistenceManager pm)
+    {   JavaField javaField = getFieldInfo();
+        return TypeSupport.getFieldValue( getField(), null );
+    }
+
+    /**
+     * 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 );
+    }
+
+    /**
+     * 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 )
+        {   ASTToChildren();
+            if( this.children==null ||
+                this.children.length<1 )
+                return null;
+            TypeImpl type = (TypeImpl) this.children[0];
+            JavaType classType = (JavaType) type.getTypeInfo();
+            if( classType!=null )
+                this.javaField = classType.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/ThisExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/ThisExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/ThisExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/ThisExpr.java Sun May 22 11:08:57 2005
@@ -0,0 +1,76 @@
+/*
+ * 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.NodeVisitor;
+import org.apache.jdo.jdoql.tree.ThisExpression;
+
+
+/**
+ * This node represents an access to <code>this</code>.
+ * It does not have any children.
+ *
+ * @author Michael Watzek
+ */
+public final class ThisExpr extends IdentifierExpr implements ThisExpression
+{
+    /**
+     * 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 ThisExpr()
+    {
+    }
+
+    /**
+     * 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 ThisExpr(antlr.Token token)
+    {   initialize( token );
+    }
+
+    /**
+     * This constructor is called by the query tree instance.
+     * It delegates to the super class constructor.
+     * @param clazz the Java type of this
+     */
+    ThisExpr(Class clazz)
+    {   super( JDOQLTokenTypes.THIS, "this", clazz ); //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/TimesExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/TimesExpr.java?rev=171353&view=auto
==============================================================================
--- incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/TimesExpr.java (added)
+++ incubator/jdo/trunk/query20/src/java/org/apache/jdo/impl/jdoql/tree/TimesExpr.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.NodeVisitor;
+import org.apache.jdo.jdoql.tree.TimesExpression;
+
+
+/**
+ * This node represents a times operator.
+ * A times operator is a binary expression.
+ * The string representation of this operator is <code>*</code>.
+ *
+ * @author Michael Watzek
+ */
+public final class TimesExpr extends BinaryExpr implements TimesExpression
+{
+    /**
+     * 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 TimesExpr()
+    {}
+
+    /**
+     * 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 TimesExpr(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
+     */
+    TimesExpr(Expression left, Expression right)
+    {   super( JDOQLTokenTypes.STAR, "Times", 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 );
+    }
+}



Mime
View raw message