KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > exp > parser > ASTFalse


1 /*****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  ****************************************************************/

19 package org.apache.cayenne.exp.parser;
20
21 import java.io.PrintWriter JavaDoc;
22
23 import org.apache.cayenne.exp.Expression;
24
25 /**
26  * Boolean false expression element
27  *
28  * Notice that there is one ASTTrue and one ASTFalse instead of a ASTBoolean with a
29  * Boolean value. The main reason for doing this is that a common ASTBoolean will have
30  * operand count of 1 and that will default to a prepared statmenet like " where ? and
31  * (...)", but we only need " where true and (...)".
32  *
33  * @see ASTTrue
34  * @author halset
35  * @since 3.0
36  */

37 public class ASTFalse extends ConditionNode {
38
39     /**
40      * Constructor used by expression parser. Do not invoke directly.
41      */

42     ASTFalse(int id) {
43         super(id);
44     }
45
46     public ASTFalse() {
47         super(ExpressionParserTreeConstants.JJTFALSE);
48     }
49
50     protected Object JavaDoc evaluateNode(Object JavaDoc o) throws Exception JavaDoc {
51         return Boolean.FALSE;
52     }
53
54     protected String JavaDoc getExpressionOperator(int index) {
55         throw new UnsupportedOperationException JavaDoc("No operator for '"
56                 + ExpressionParserTreeConstants.jjtNodeName[id]
57                 + "'");
58     }
59
60     public Expression shallowCopy() {
61         return new ASTFalse(id);
62     }
63
64     public int getType() {
65         return Expression.FALSE;
66     }
67     
68     public void encodeAsString(PrintWriter JavaDoc pw) {
69         pw.print("false");
70     }
71
72 }
73
Popular Tags