Return-Path: Delivered-To: apmail-db-jdo-commits-archive@www.apache.org Received: (qmail 86808 invoked from network); 19 Mar 2005 05:09:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 19 Mar 2005 05:09:47 -0000 Received: (qmail 89427 invoked by uid 500); 19 Mar 2005 05:09:47 -0000 Mailing-List: contact jdo-commits-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-dev@db.apache.org Delivered-To: mailing list jdo-commits@db.apache.org Delivered-To: moderator for jdo-commits@db.apache.org Received: (qmail 4061 invoked by uid 99); 19 Mar 2005 01:32:49 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Message-ID: <20050319010606.28147.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Sat, 19 Mar 2005 01:06:06 -0000 Subject: svn commit: r158176 [34/79] - in incubator/jdo/trunk/ri11: ./ src/ src/conf/ src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/jdo/ src/java/org/apache/jdo/ejb/ src/java/org/apache/jdo/enhancer/ src/java/org/apache/jdo/impl/ src/java/org/apache/jdo/impl/enhancer/ src/java/org/apache/jdo/impl/enhancer/classfile/ src/java/org/apache/jdo/impl/enhancer/core/ src/java/org/apache/jdo/impl/enhancer/generator/ src/java/org/apache/jdo/impl/enhancer/meta/ src/java/org/apache/jdo/impl/enhancer/meta/model/ src/java/org/apache/jdo/impl/enhancer/meta/prop/ src/java/org/apache/jdo/impl/enhancer/meta/util/ src/java/org/apache/jdo/impl/enhancer/util/ src/java/org/apache/jdo/impl/fostore/ 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/impl/model/ src/java/org/apache/jdo/impl/model/java/ src/java/org/apache/jdo/impl/model/java/runtime/ src/java/org/apache/jdo/impl/model/jdo/ src/java/org/apache/jdo/impl/model/jdo/caching/ src/java/org/apache/jdo/impl/model/jdo/util/ src/java/org/apache/jdo/impl/model/jdo/xml/ src/java/org/apache/jdo/impl/pm/ src/java/org/apache/jdo/impl/sco/ src/java/org/apache/jdo/impl/state/ src/java/org/apache/jdo/jdoql/ src/java/org/apache/jdo/jdoql/tree/ src/java/org/apache/jdo/model/ src/java/org/apache/jdo/model/java/ src/java/org/apache/jdo/model/jdo/ src/java/org/apache/jdo/pm/ src/java/org/apache/jdo/sco/ src/java/org/apache/jdo/state/ src/java/org/apache/jdo/store/ src/java/org/apache/jdo/util/ test/ test/conf/ test/enhancer/ test/enhancer/sempdept/ test/enhancer/sempdept/src/ test/enhancer/sempdept/src/empdept/ test/fsuid2/ test/fsuid2/org/ test/fsuid2/org/apache/ test/fsuid2/org/apache/jdo/ test/fsuid2/org/apache/jdo/pc/ test/java/ test/java/org/ test/java/org/apache/ test/java/org/apache/jdo/ test/java/org/apache/jdo/impl/ test/java/org/apache/jdo/impl/fostore/ test/java/org/apache/jdo/pc/ test/java/org/apache/jdo/pc/appid/ test/java/org/apache/jdo/pc/empdept/ test/java/org/apache/jdo/pc/serializable/ test/java/org/apache/jdo/pc/xempdept/ test/java/org/apache/jdo/test/ test/java/org/apache/jdo/test/query/ test/java/org/apache/jdo/test/util/ test/jdo/ test/jdo/org/ test/jdo/org/apache/ test/jdo/org/apache/jdo/ test/jdo/org/apache/jdo/pc/ test/jdo/org/apache/jdo/pc/appid/ test/jdo/org/apache/jdo/pc/empdept/ test/jdo/org/apache/jdo/pc/serializable/ test/jdo/org/apache/jdo/pc/xempdept/ xdocs/ To: jdo-commits@db.apache.org From: mbo@apache.org X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Lon= gLiteralExpr.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/ap= ache/jdo/impl/jdoql/tree/LongLiteralExpr.java?view=3Dauto&rev=3D158176 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/LongLi= teralExpr.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/LongLi= teralExpr.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,92 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * 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 deserializati= on. + * The caller must make sure to set the ANTLR tree structure himself + * or, call setChildren 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 setChildren 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 visitor. + * @param visitor the node visitor + */ + public void arrive(NodeVisitor visitor) + { visitor.arrive( this ); + } + + /** + * Delegates to the argument visitor. + * @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/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Met= hodCallExpr.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/ap= ache/jdo/impl/jdoql/tree/MethodCallExpr.java?view=3Dauto&rev=3D158176 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Method= CallExpr.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Method= CallExpr.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,114 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * 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 + * ContainsCallExpression, IsEmptyCallExpression, + * EndsWithCallExpression and + * StartsWithCallExpression. + * + * @author Michael Watzek + */ +public abstract class MethodCallExpr extends Expr implements MethodCallExp= ression +{ + Expression[] args; + + /** + * The noarg constructor is needed for ANTLR support and deserializati= on. + * The caller must make sure to set the ANTLR tree structure himself + * or, call setChildren optionally. + */ + public MethodCallExpr() + {} + + /** + * This constructor is called by specialized nodes. + * It calls setChildren in order to initialize the node's + * child expr. + * @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, Expressio= n target, Expression[] args) + { super( tokenType, tokenName, clazz ); + this.args =3D args; + int nrOfChildren =3D 1; + if( args!=3Dnull ) + nrOfChildren +=3D args.length; + Node[] children =3D new Node[nrOfChildren]; + children[0] =3D target; + if( args!=3Dnull ) + 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 super.clone()= + */ + protected Object clone() throws CloneNotSupportedException + { MethodCallExpr copy =3D (MethodCallExpr) super.clone(); + copy.args =3D null; + return copy; + } + + /** + * Returns the target expression of this method call. + * The target expression can be an instance of + * ThisExpression or an instance of an arbitrary other + * Expression, e.g. FieldAccessExpression. + * @return the target expression + */ + public Expression getTarget() + { ASTToChildren(); + if( this.children=3D=3Dnull || + 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=3D=3Dnull && + this.children.length>1 ) + { this.args =3D new Expression[this.children.length-1]; + System.arraycopy( this.children, 1, this.args, 0, this.args.le= ngth ); + } + return args; + } +} Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Min= usExpr.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/ap= ache/jdo/impl/jdoql/tree/MinusExpr.java?view=3Dauto&rev=3D158176 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/MinusE= xpr.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/MinusE= xpr.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,94 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * 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 -. + * + * @author Michael Watzek + */ +public final class MinusExpr extends BinaryExpr implements MinusExpression +{ + /** + * The noarg constructor is needed for ANTLR support and deserializati= on. + * The caller must make sure to set the ANTLR tree structure himself + * or, call setChildren 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 setChildren 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 ); //NOI1= 8N + this.clazz =3D this.commonOperandType; + } + + /** + * Delegates to the argument visitor. + * @param visitor the node visitor + */ + public void arrive(NodeVisitor visitor) + { visitor.arrive( this ); + } + + /** + * Delegates to the argument visitor. + * @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 visitor. + * @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/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Nod= eImpl.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/ap= ache/jdo/impl/jdoql/tree/NodeImpl.java?view=3Dauto&rev=3D158176 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/NodeIm= pl.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/NodeIm= pl.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,259 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * 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 + * , Declaration, Expression + * and OrderingExpression. This class is not defined + * abstract 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 =3D I18NHelper.getInstance( + "org.apache.jdo.impl.jdoql.Bundle", NodeImpl.class.getClassLoader(= )); //NOI18N + + /** RuntimeJavaModelFactory. */ + private static final RuntimeJavaModelFactory javaModelFactory =3D + (RuntimeJavaModelFactory) AccessController.doPrivileged( + new PrivilegedAction () { + public Object run () { + return RuntimeJavaModelFactory.getInstance(); + } + } + ); + + Node parent =3D null; + Node[] children =3D null; + Object object =3D null; + transient Class clazz =3D null; + + /** + * The noarg constructor is needed for ANTLR support and deserializati= on. + * The caller must make sure to set the ANTLR tree structure himself + * or, call setChildren 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 setChildren 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 setChildren 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 =3D clazz; + } + + /** + * Creates and returns a copy of this object nullifying fields + * parent, children and clazz. + * @return the copy + * @exception CloneNotSupportedException thrown by super.clone()= + */ + protected Object clone() throws CloneNotSupportedException + { NodeImpl copy =3D (NodeImpl) super.clone(); + copy.parent =3D null; + copy.children =3D null; + return copy; + } + + public String toString() + { if( getTypeInfo()=3D=3Dnull ) + return getText(); + else + return super.toString(); + } + + + /** + * Returns the Java type of this node. + * @return the Java type + */ + public Class getJavaClass() + { if( this.clazz=3D=3Dnull && + getTypeInfo()!=3Dnull ) + this.clazz =3D 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 =3D 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 =3D 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 null 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 true 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 true + */ + public boolean walkNextChild(NodeVisitor visitor, + Object resultOfPreviousChild, + int indexOfNextChild) + { return true; + } + + /** + * Sets the children of this node specified by the argument + * children. + * 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 null or already has a parent node + */ + void setChildren(Node[] children) + { if( children!=3Dnull ) + { setFirstChild( null ); + for( int i=3D0; igetChildren of this class. + */ + void ASTToChildren() + { if( this.children=3D=3Dnull ) + { int nrOfChildren; + AST current =3D getFirstChild(); + for( nrOfChildren=3D0; current!=3Dnull; nrOfChildren++ ) + current =3D current.getNextSibling(); + if( nrOfChildren!=3D0 ) + { this.children =3D new Node[nrOfChildren]; + current =3D getFirstChild(); + for( nrOfChildren=3D0; current!=3Dnull; nrOfChildren++ ) + { this.children[nrOfChildren] =3D (Node) current; + current =3D current.getNextSibling(); + } } } + } +} Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Not= EqualsExpr.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/ap= ache/jdo/impl/jdoql/tree/NotEqualsExpr.java?view=3Dauto&rev=3D158176 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/NotEqu= alsExpr.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/NotEqu= alsExpr.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,96 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * 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 !=3D. + * + * @author Michael Watzek + */ +public final class NotEqualsExpr + extends BinaryExpr implements NotEqualsExpression +{ + /** + * The noarg constructor is needed for ANTLR support and deserializati= on. + * The caller must make sure to set the ANTLR tree structure himself + * or, call setChildren 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 setChildren 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= ,=20 + right ); //NOI18N + } + + /** + * Delegates to the argument visitor. + * @param visitor the node visitor + */ + public void arrive(NodeVisitor visitor) + { visitor.arrive( this ); + } + + /** + * Delegates to the argument visitor. + * @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 visitor. + * @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/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Not= Expr.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/ap= ache/jdo/impl/jdoql/tree/NotExpr.java?view=3Dauto&rev=3D158176 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/NotExp= r=2Ejava (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/NotExp= r=2Ejava Fri Mar 18 17:02:29 2005 @@ -0,0 +1,77 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * 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 !. + * + * @author Michael Watzek + */ +public final class NotExpr extends UnaryExpr implements NotExpression +{ + /** + * The noarg constructor is needed for ANTLR support and deserializati= on. + * The caller must make sure to set the ANTLR tree structure himself + * or, call setChildren 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 setChildren 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 visitor. + * @param visitor the node visitor + */ + public void arrive(NodeVisitor visitor) + { visitor.arrive( this ); + } + + /** + * Delegates to the argument visitor. + * @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/ri11/src/java/org/apache/jdo/impl/jdoql/tree/OrE= xpr.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/ap= ache/jdo/impl/jdoql/tree/OrExpr.java?view=3Dauto&rev=3D158176 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/OrExpr= .java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/OrExpr= .java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,94 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * 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 |. + * + * @author Michael Watzek + */ +public final class OrExpr extends BinaryExpr implements OrExpression +{ + /** + * The noarg constructor is needed for ANTLR support and deserializati= on. + * The caller must make sure to set the ANTLR tree structure himself + * or, call setChildren 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 setChildren 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 visitor. + * @param visitor the node visitor + */ + public void arrive(NodeVisitor visitor) + { visitor.arrive( this ); + } + + /** + * Delegates to the argument visitor. + * @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 visitor. + * @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/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Ord= eringExpr.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/ap= ache/jdo/impl/jdoql/tree/OrderingExpr.java?view=3Dauto&rev=3D158176 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Orderi= ngExpr.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Orderi= ngExpr.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,64 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * 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 expre= ssions + * are AscendingOrderingExpression and + * DescendingOrderingExpression. + * + * @author Michael Watzek + */ +public abstract class OrderingExpr extends NodeImpl implements OrderingExp= ression +{ + /** + * The noarg constructor is needed for ANTLR support and deserializati= on. + * The caller must make sure to set the ANTLR tree structure himself + * or, call setChildren optionally. + */ + public OrderingExpr() + {} + + /** + * This constructor is called by specialized nodes. + * It calls setChildren in order to initialize the node's + * child expr. + * @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=3D=3Dnull || + this.children.length<1 ) + return null; + return (Expression) this.children[0]; + } +} Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Par= ameterAccessExpr.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/ap= ache/jdo/impl/jdoql/tree/ParameterAccessExpr.java?view=3Dauto&rev=3D158176 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Parame= terAccessExpr.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Parame= terAccessExpr.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,81 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * 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 deserializati= on. + * The caller must make sure to set the ANTLR tree structure himself + * or, call setChildren 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 setChildren 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 visitor. + * @param visitor the node visitor + */ + public void arrive(NodeVisitor visitor) + { visitor.arrive( this ); + } + + /** + * Delegates to the argument visitor. + * @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/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Par= ameterDecl.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/ap= ache/jdo/impl/jdoql/tree/ParameterDecl.java?view=3Dauto&rev=3D158176 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Parame= terDecl.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Parame= terDecl.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,77 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * 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 ParameterDeclarat= ion +{ + /** + * The noarg constructor is needed for ANTLR support and deserializati= on. + * The caller must make sure to set the ANTLR tree structure himself + * or, call setChildren 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 setChildren 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 visitor. + * @param visitor the node visitor + */ + public void arrive(NodeVisitor visitor) + { visitor.arrive( this ); + } + + /** + * Delegates to the argument visitor. + * @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/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Plu= sExpr.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/ap= ache/jdo/impl/jdoql/tree/PlusExpr.java?view=3Dauto&rev=3D158176 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/PlusEx= pr.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/PlusEx= pr.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,94 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * 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 +. + * + * @author Michael Watzek + */ +public final class PlusExpr extends BinaryExpr implements PlusExpression +{ + /** + * The noarg constructor is needed for ANTLR support and deserializati= on. + * The caller must make sure to set the ANTLR tree structure himself + * or, call setChildren 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 setChildren 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 =3D this.commonOperandType; + } + + /** + * Delegates to the argument visitor. + * @param visitor the node visitor + */ + public void arrive(NodeVisitor visitor) + { visitor.arrive( this ); + } + + /** + * Delegates to the argument visitor. + * @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 visitor. + * @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/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Sho= rtLiteralExpr.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/ap= ache/jdo/impl/jdoql/tree/ShortLiteralExpr.java?view=3Dauto&rev=3D158176 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/ShortL= iteralExpr.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/ShortL= iteralExpr.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,92 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * 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 deserializati= on. + * The caller must make sure to set the ANTLR tree structure himself + * or, call setChildren 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 setChildren 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 visitor. + * @param visitor the node visitor + */ + public void arrive(NodeVisitor visitor) + { visitor.arrive( this ); + } + + /** + * Delegates to the argument visitor. + * @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/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Sta= rtsWithCallExpr.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/ap= ache/jdo/impl/jdoql/tree/StartsWithCallExpr.java?view=3Dauto&rev=3D158176 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Starts= WithCallExpr.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Starts= WithCallExpr.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,119 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * 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 + * String.startsWith. Children of this node are a target + * expression (e.g. a FieldAccessExpression) 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 deserializati= on. + * The caller must make sure to set the ANTLR tree structure himself + * or, call setChildren 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 setChildren 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()!=3Dnull && + !String.class.isAssignableFrom(target.getJavaClass()) ) + throw new JDOQueryException( + msg.msg("EXC_NoStringType", target, this) ); //NOI18N + if( args=3D=3Dnull || + args.length!=3D1 ) + 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 visitor. + * @param visitor the node visitor + */ + public void arrive(NodeVisitor visitor) + { visitor.arrive( this ); + } + + /** + * Delegates to the argument visitor. + * @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 visitor. + * @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/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Sta= ticFieldAccessExpr.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/ap= ache/jdo/impl/jdoql/tree/StaticFieldAccessExpr.java?view=3Dauto&rev=3D158176 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Static= FieldAccessExpr.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Static= FieldAccessExpr.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,166 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * 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 FieldAccessExpr. + * Static Field access expressions have exactly one child, the target expr= ession. + * 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 deserializati= on. + * The caller must make sure to set the ANTLR tree structure himself + * or, call setChildren 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 setChildren 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 express= ion + * @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 =3D 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 =3D 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 o= f this + * expression is denied + */ + public Object getFieldValue(PersistenceManager pm) + { JavaField javaField =3D getFieldInfo(); + return TypeSupport.getFieldValue( getField(), null ); + } + + /** + * Delegates to the argument visitor. + * @param visitor the node visitor + */ + public void arrive(NodeVisitor visitor) + { visitor.arrive( this ); + } + + /** + * Delegates to the argument visitor. + * @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 null, + * 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=3D=3Dnull ) + { ASTToChildren(); + if( this.children=3D=3Dnull || + this.children.length<1 ) + return null; + TypeImpl type =3D (TypeImpl) this.children[0]; + JavaType classType =3D (JavaType) type.getTypeInfo(); + if( classType!=3Dnull ) + this.javaField =3D classType.getJavaField( this.fieldName = ); + } + return this.javaField; + } + + /** */ + private Field getField() + { if( this.field=3D=3Dnull ) + this.field =3D (Field) AccessController.doPrivileged( + new PrivilegedAction() { + public Object run () { + return TypeSupport.getAccessibleField(getFieldInfo(= )); + }}); + return this.field; + } +} + Added: incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Thi= sExpr.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/ap= ache/jdo/impl/jdoql/tree/ThisExpr.java?view=3Dauto&rev=3D158176 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/ThisEx= pr.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/ThisEx= pr.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,76 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * 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 this. + * It does not have any children. + * + * @author Michael Watzek + */ +public final class ThisExpr extends IdentifierExpr implements ThisExpressi= on +{ + /** + * The noarg constructor is needed for ANTLR support and deserializati= on. + * The caller must make sure to set the ANTLR tree structure himself + * or, call setChildren 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 setChildren 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 visitor. + * @param visitor the node visitor + */ + public void arrive(NodeVisitor visitor) + { visitor.arrive( this ); + } + + /** + * Delegates to the argument visitor. + * @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/ri11/src/java/org/apache/jdo/impl/jdoql/tree/Tim= esExpr.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/ri11/src/java/org/ap= ache/jdo/impl/jdoql/tree/TimesExpr.java?view=3Dauto&rev=3D158176 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/TimesE= xpr.java (added) +++ incubator/jdo/trunk/ri11/src/java/org/apache/jdo/impl/jdoql/tree/TimesE= xpr.java Fri Mar 18 17:02:29 2005 @@ -0,0 +1,95 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * 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 *. + * + * @author Michael Watzek + */ +public final class TimesExpr extends BinaryExpr implements TimesExpression +{ + /** + * The noarg constructor is needed for ANTLR support and deserializati= on. + * The caller must make sure to set the ANTLR tree structure himself + * or, call setChildren 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 setChildren 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 =3D this.commonOperandType; + } + + /** + * Delegates to the argument visitor. + * @param visitor the node visitor + */ + public void arrive(NodeVisitor visitor) + { visitor.arrive( this ); + } + + /** + * Delegates to the argument visitor. + * @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 visitor. + * @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 ); + } +}