01: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
02:
03: This file is part of the db4o open source object database.
04:
05: db4o is free software; you can redistribute it and/or modify it under
06: the terms of version 2 of the GNU General Public License as published
07: by the Free Software Foundation and as clarified by db4objects' GPL
08: interpretation policy, available at
09: 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.internal.cluster;
22:
23: import java.util.*;
24:
25: import com.db4o.*;
26: import com.db4o.cluster.Cluster;
27: import com.db4o.foundation.*;
28: import com.db4o.internal.query.*;
29: import com.db4o.query.*;
30:
31: /**
32: *
33: * @exclude
34: */
35: public class ClusterQuery implements Query {
36:
37: private final Cluster _cluster;
38: private final Query[] _queries;
39:
40: public ClusterQuery(Cluster cluster, Query[] queries) {
41: _cluster = cluster;
42: _queries = queries;
43: }
44:
45: public Constraint constrain(Object constraint) {
46: synchronized (_cluster) {
47: Constraint[] constraints = new Constraint[_queries.length];
48: for (int i = 0; i < constraints.length; i++) {
49: constraints[i] = _queries[i].constrain(constraint);
50: }
51: return new ClusterConstraint(_cluster, constraints);
52: }
53: }
54:
55: public Constraints constraints() {
56: synchronized (_cluster) {
57: Constraint[] constraints = new Constraint[_queries.length];
58: for (int i = 0; i < constraints.length; i++) {
59: constraints[i] = _queries[i].constraints();
60: }
61: return new ClusterConstraints(_cluster, constraints);
62: }
63: }
64:
65: public Query descend(String fieldName) {
66: synchronized (_cluster) {
67: Query[] queries = new Query[_queries.length];
68: for (int i = 0; i < queries.length; i++) {
69: queries[i] = _queries[i].descend(fieldName);
70: }
71: return new ClusterQuery(_cluster, queries);
72: }
73: }
74:
75: public ObjectSet execute() {
76: synchronized (_cluster) {
77: return new ObjectSetFacade(new ClusterQueryResult(_cluster,
78: _queries));
79: }
80: }
81:
82: public Query orderAscending() {
83: throw new NotSupportedException();
84: }
85:
86: public Query orderDescending() {
87: throw new NotSupportedException();
88: }
89:
90: public Query sortBy(QueryComparator comparator) {
91: // FIXME
92: throw new NotSupportedException();
93: }
94:
95: public Query sortBy(Comparator comparator) {
96: // FIXME
97: throw new NotSupportedException();
98: }
99: }
|