001: package org.apache.ojb.soda;
002:
003: /* Copyright 2002-2005 The Apache Software Foundation
004: *
005: * Licensed under the Apache License, Version 2.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: import java.io.Serializable;
019:
020: import org.odbms.Constraint;
021: import org.odbms.ObjectSet;
022: import org.odbms.Query;
023: import org.apache.ojb.broker.OJBRuntimeException;
024: import org.apache.ojb.broker.PersistenceBroker;
025:
026: /**
027: * @author Thomas Mahler
028: * @version $Id: QueryImpl.java,v 1.7.2.1 2005/12/21 22:30:46 tomdz Exp $
029: */
030: public class QueryImpl implements Query, Serializable {
031: static final long serialVersionUID = 7117766237756132776L;
032: private org.apache.ojb.broker.query.Query ojbQuery = null;
033: private int limitCount = -1;
034: private PersistenceBroker broker;
035:
036: /**
037: * Constructor for QueryImpl.
038: */
039: public QueryImpl(PersistenceBroker broker) {
040: super ();
041: this .broker = broker;
042: }
043:
044: /**
045: * wrapping constructor. needed only as long we
046: * don't support the soda constraint stuff.
047: */
048: public QueryImpl(org.apache.ojb.broker.query.Query query) {
049: super ();
050: ojbQuery = query;
051: }
052:
053: /*
054: * @see Query#constrain(Object)
055: */
056: public Constraint constrain(Object example) {
057: return null;
058: }
059:
060: /*
061: * @see Query#execute()
062: */
063: public ObjectSet execute() {
064: // in future versions soda queries will be translated
065: // into org.apache.ojb.broker.query.Query objects and placed
066: // into the ojbQuery member variable.
067:
068: if (ojbQuery != null) {
069: return new ObjectSetImpl(broker, ojbQuery, limitCount);
070: } else
071: throw new OJBRuntimeException(
072: "internal ojbQuery not filled. Can't execute this query yet!");
073: }
074:
075: /*
076: * @see Query#descendant(String)
077: */
078: public Query descendant(String path) {
079: return this ;
080: }
081:
082: /*
083: * @see Query#parent(String)
084: */
085: public Query parent(String path) {
086: return this ;
087: }
088:
089: /*
090: * @see Query#limitSize(int)
091: */
092: public Query limitSize(int count) {
093: limitCount = count;
094: return this ;
095: }
096:
097: /*
098: * @see Query#orderAscending()
099: */
100: public Query orderAscending() {
101: return this ;
102: }
103:
104: /*
105: * @see Query#orderDescending()
106: */
107: public Query orderDescending() {
108: return this ;
109: }
110:
111: /**
112: * Sets the ojbQuery, needed only as long we
113: * don't support the soda constraint stuff.
114: * @param ojbQuery The ojbQuery to set
115: */
116: public void setOjbQuery(org.apache.ojb.broker.query.Query ojbQuery) {
117: this.ojbQuery = ojbQuery;
118: }
119:
120: }
|