KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > QE


1 /* Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com
2
3 This file is part of the db4o open source object database.
4
5 db4o is free software; you can redistribute it and/or modify it under
6 the terms of version 2 of the GNU General Public License as published
7 by the Free Software Foundation and as clarified by db4objects' GPL
8 interpretation policy, available at
9 http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
10 Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
11 Suite 350, San Mateo, CA 94403, USA.
12
13 db4o is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

21 package com.db4o;
22
23 import com.db4o.types.Unversioned;
24
25 /**
26  * Query Evaluator - Represents such things as >, >=, <, <=, EQUAL, LIKE, etc.
27  *
28  * @exclude
29  */

30 public class QE implements Unversioned {
31     
32     static final QE DEFAULT = new QE();
33     
34     public static final int NULLS = 0;
35     public static final int SMALLER = 1;
36     public static final int EQUAL = 2;
37     public static final int GREATER = 3;
38     
39     QE add(QE evaluator){
40         return evaluator;
41     }
42     
43     public boolean identity(){
44         return false;
45     }
46
47     boolean isDefault(){
48         return true;
49     }
50
51     boolean evaluate(QConObject a_constraint, QCandidate a_candidate, Object JavaDoc a_value){
52         if(a_value == null){
53             return a_constraint.getComparator(a_candidate) instanceof Null;
54         }
55         return a_constraint.getComparator(a_candidate).isEqual(a_value);
56     }
57     
58     public boolean equals(Object JavaDoc obj){
59         return obj.getClass() == this.getClass();
60     }
61     
62     // overridden in QENot
63
boolean not(boolean res){
64         return res;
65     }
66     
67     /**
68      * Specifies which part of the index to take.
69      * Array elements:
70      * [0] - smaller
71      * [1] - equal
72      * [2] - greater
73      * [3] - nulls
74      *
75      *
76      * @param bits
77      */

78     public void indexBitMap(boolean[] bits){
79         bits[QE.EQUAL] = true;
80     }
81     
82     public boolean supportsIndex(){
83         return true;
84     }
85     
86 }
87
Popular Tags