001: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
002:
003: This file is part of the db4o open source object database.
004:
005: db4o is free software; you can redistribute it and/or modify it under
006: the terms of version 2 of the GNU General Public License as published
007: by the Free Software Foundation and as clarified by db4objects' GPL
008: interpretation policy, available at
009: http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
010: Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
011: Suite 350, San Mateo, CA 94403, USA.
012:
013: db4o is distributed in the hope that it will be useful, but WITHOUT ANY
014: WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: for more details.
017:
018: You should have received a copy of the GNU General Public License along
019: with this program; if not, write to the Free Software Foundation, Inc.,
020: 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
021: package com.db4o.internal.query.processor;
022:
023: import com.db4o.internal.*;
024: import com.db4o.query.*;
025:
026: /**
027: *
028: * Array of constraints for queries.
029: *
030: * Necessary to be returned to Query#constraints()
031: *
032: * @exclude
033: */
034: public class QConstraints extends QCon implements Constraints {
035:
036: private Constraint[] i_constraints;
037:
038: QConstraints(Transaction a_trans, Constraint[] constraints) {
039: super (a_trans);
040: i_constraints = constraints;
041: }
042:
043: Constraint join(Constraint a_with, boolean a_and) {
044: synchronized (streamLock()) {
045: if (!(a_with instanceof QCon)) {
046: return null;
047: }
048: // resolving multiple constraints happens in QCon for
049: // a_with, so we simply turn things around
050: return ((QCon) a_with).join1(this , a_and);
051: }
052: }
053:
054: public Constraint[] toArray() {
055: synchronized (streamLock()) {
056: return i_constraints;
057: }
058: }
059:
060: public Constraint contains() {
061: synchronized (streamLock()) {
062: for (int i = 0; i < i_constraints.length; i++) {
063: i_constraints[i].contains();
064: }
065: return this ;
066: }
067: }
068:
069: public Constraint equal() {
070: synchronized (streamLock()) {
071: for (int i = 0; i < i_constraints.length; i++) {
072: i_constraints[i].equal();
073: }
074: return this ;
075: }
076: }
077:
078: public Constraint greater() {
079: synchronized (streamLock()) {
080: for (int i = 0; i < i_constraints.length; i++) {
081: i_constraints[i].greater();
082: }
083: return this ;
084: }
085: }
086:
087: public Constraint identity() {
088: synchronized (streamLock()) {
089: for (int i = 0; i < i_constraints.length; i++) {
090: i_constraints[i].identity();
091: }
092: return this ;
093: }
094: }
095:
096: public Constraint not() {
097: synchronized (streamLock()) {
098: for (int i = 0; i < i_constraints.length; i++) {
099: i_constraints[i].not();
100: }
101: return this ;
102: }
103: }
104:
105: public Constraint like() {
106: synchronized (streamLock()) {
107: for (int i = 0; i < i_constraints.length; i++) {
108: i_constraints[i].like();
109: }
110: return this ;
111: }
112: }
113:
114: public Constraint startsWith(boolean caseSensitive) {
115: synchronized (streamLock()) {
116: for (int i = 0; i < i_constraints.length; i++) {
117: i_constraints[i].startsWith(caseSensitive);
118: }
119: return this ;
120: }
121: }
122:
123: public Constraint endsWith(boolean caseSensitive) {
124: synchronized (streamLock()) {
125: for (int i = 0; i < i_constraints.length; i++) {
126: i_constraints[i].endsWith(caseSensitive);
127: }
128: return this ;
129: }
130: }
131:
132: public Constraint smaller() {
133: synchronized (streamLock()) {
134: for (int i = 0; i < i_constraints.length; i++) {
135: i_constraints[i].smaller();
136: }
137: return this ;
138: }
139: }
140:
141: public Object getObject() {
142: synchronized (streamLock()) {
143: Object[] objects = new Object[i_constraints.length];
144: for (int i = 0; i < i_constraints.length; i++) {
145: objects[i] = i_constraints[i].getObject();
146: }
147: return objects;
148: }
149: }
150: }
|