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.1 2007-08-24 22:17:42 ewestfal Exp $
029 */
030 public class QueryImpl implements Query, Serializable
031 {
032 static final long serialVersionUID = 7117766237756132776L;
033 private org.apache.ojb.broker.query.Query ojbQuery = null;
034 private int limitCount = -1;
035 private PersistenceBroker broker;
036
037 /**
038 * Constructor for QueryImpl.
039 */
040 public QueryImpl(PersistenceBroker broker)
041 {
042 super();
043 this.broker = broker;
044 }
045
046 /**
047 * wrapping constructor. needed only as long we
048 * don't support the soda constraint stuff.
049 */
050 public QueryImpl(org.apache.ojb.broker.query.Query query)
051 {
052 super();
053 ojbQuery = query;
054 }
055
056
057 /*
058 * @see Query#constrain(Object)
059 */
060 public Constraint constrain(Object example)
061 {
062 return null;
063 }
064
065 /*
066 * @see Query#execute()
067 */
068 public ObjectSet execute()
069 {
070 // in future versions soda queries will be translated
071 // into org.apache.ojb.broker.query.Query objects and placed
072 // into the ojbQuery member variable.
073
074 if (ojbQuery != null)
075 {
076 return new ObjectSetImpl(broker, ojbQuery, limitCount);
077 }
078 else throw new OJBRuntimeException("internal ojbQuery not filled. Can't execute this query yet!");
079 }
080
081 /*
082 * @see Query#descendant(String)
083 */
084 public Query descendant(String path)
085 {
086 return this;
087 }
088
089 /*
090 * @see Query#parent(String)
091 */
092 public Query parent(String path)
093 {
094 return this;
095 }
096
097 /*
098 * @see Query#limitSize(int)
099 */
100 public Query limitSize(int count)
101 {
102 limitCount = count;
103 return this;
104 }
105
106 /*
107 * @see Query#orderAscending()
108 */
109 public Query orderAscending()
110 {
111 return this;
112 }
113
114 /*
115 * @see Query#orderDescending()
116 */
117 public Query orderDescending()
118 {
119 return this;
120 }
121
122
123 /**
124 * Sets the ojbQuery, needed only as long we
125 * don't support the soda constraint stuff.
126 * @param ojbQuery The ojbQuery to set
127 */
128 public void setOjbQuery(org.apache.ojb.broker.query.Query ojbQuery)
129 {
130 this.ojbQuery = ojbQuery;
131 }
132
133 }