KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > QConstraints


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.query.*;
24
25 /**
26  *
27  * Array of constraints for queries.
28  *
29  * Necessary to be returned to Query#constraints()
30  *
31  * @exclude
32  */

33 public class QConstraints extends QCon implements Constraints {
34
35     private Constraint[] i_constraints;
36
37     QConstraints(Transaction a_trans, Constraint[] constraints) {
38         super(a_trans);
39         i_constraints = constraints;
40     }
41
42     Constraint join(Constraint a_with, boolean a_and) {
43         synchronized(streamLock()){
44             if (!(a_with instanceof QCon)) {
45                 return null;
46             }
47             // resolving multiple constraints happens in QCon for
48
// a_with, so we simply turn things around
49
return ((QCon) a_with).join1(this, a_and);
50         }
51     }
52     
53     public Constraint[] toArray() {
54         synchronized(streamLock()){
55             return i_constraints;
56         }
57     }
58
59     public Constraint contains() {
60         synchronized(streamLock()){
61             for (int i = 0; i < i_constraints.length; i++) {
62                 i_constraints[i].contains();
63             }
64             return this;
65         }
66     }
67
68     public Constraint equal() {
69         synchronized(streamLock()){
70             for (int i = 0; i < i_constraints.length; i++) {
71                 i_constraints[i].equal();
72             }
73             return this;
74         }
75     }
76
77     public Constraint greater() {
78         synchronized(streamLock()){
79             for (int i = 0; i < i_constraints.length; i++) {
80                 i_constraints[i].greater();
81             }
82             return this;
83         }
84     }
85
86     public Constraint identity() {
87         synchronized(streamLock()){
88             for (int i = 0; i < i_constraints.length; i++) {
89                 i_constraints[i].identity();
90             }
91             return this;
92         }
93     }
94
95     public Constraint not() {
96         synchronized(streamLock()){
97             for (int i = 0; i < i_constraints.length; i++) {
98                 i_constraints[i].not();
99             }
100             return this;
101         }
102     }
103
104     public Constraint like() {
105         synchronized(streamLock()){
106             for (int i = 0; i < i_constraints.length; i++) {
107                 i_constraints[i].like();
108             }
109             return this;
110         }
111     }
112
113     public Constraint startsWith(boolean caseSensitive) {
114         synchronized(streamLock()){
115             for (int i = 0; i < i_constraints.length; i++) {
116                 i_constraints[i].startsWith(caseSensitive);
117             }
118             return this;
119         }
120     }
121
122     public Constraint endsWith(boolean caseSensitive) {
123         synchronized(streamLock()){
124             for (int i = 0; i < i_constraints.length; i++) {
125                 i_constraints[i].endsWith(caseSensitive);
126             }
127             return this;
128         }
129     }
130
131     public Constraint smaller() {
132         synchronized(streamLock()){
133             for (int i = 0; i < i_constraints.length; i++) {
134                 i_constraints[i].smaller();
135             }
136             return this;
137         }
138     }
139
140     public Object JavaDoc getObject() {
141         synchronized(streamLock()){
142             Object JavaDoc[] objects = new Object JavaDoc[i_constraints.length];
143             for (int i = 0; i < i_constraints.length; i++) {
144                 objects[i] = i_constraints[i].getObject();
145             }
146             return objects;
147         }
148     }
149 }
150
Popular Tags