| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| QueryImpl |
|
| 1.3;1.3 |
| 1 | package org.apache.ojb.soda; | |
| 2 | ||
| 3 | /* Copyright 2002-2005 The Apache Software Foundation | |
| 4 | * | |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 6 | * you may not use this file except in compliance with the License. | |
| 7 | * You may obtain a copy of the License at | |
| 8 | * | |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 10 | * | |
| 11 | * Unless required by applicable law or agreed to in writing, software | |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 14 | * See the License for the specific language governing permissions and | |
| 15 | * limitations under the License. | |
| 16 | */ | |
| 17 | ||
| 18 | import java.io.Serializable; | |
| 19 | ||
| 20 | import org.odbms.Constraint; | |
| 21 | import org.odbms.ObjectSet; | |
| 22 | import org.odbms.Query; | |
| 23 | import org.apache.ojb.broker.OJBRuntimeException; | |
| 24 | import org.apache.ojb.broker.PersistenceBroker; | |
| 25 | ||
| 26 | /** | |
| 27 | * @author Thomas Mahler | |
| 28 | * @version $Id: QueryImpl.java,v 1.1 2007-08-24 22:17:42 ewestfal Exp $ | |
| 29 | */ | |
| 30 | public class QueryImpl implements Query, Serializable | |
| 31 | { | |
| 32 | static final long serialVersionUID = 7117766237756132776L; | |
| 33 | private org.apache.ojb.broker.query.Query ojbQuery = null; | |
| 34 | private int limitCount = -1; | |
| 35 | private PersistenceBroker broker; | |
| 36 | ||
| 37 | /** | |
| 38 | * Constructor for QueryImpl. | |
| 39 | */ | |
| 40 | public QueryImpl(PersistenceBroker broker) | |
| 41 | { | |
| 42 | super(); | |
| 43 | this.broker = broker; | |
| 44 | } | |
| 45 | ||
| 46 | /** | |
| 47 | * wrapping constructor. needed only as long we | |
| 48 | * don't support the soda constraint stuff. | |
| 49 | */ | |
| 50 | public QueryImpl(org.apache.ojb.broker.query.Query query) | |
| 51 | { | |
| 52 | super(); | |
| 53 | ojbQuery = query; | |
| 54 | } | |
| 55 | ||
| 56 | ||
| 57 | /* | |
| 58 | * @see Query#constrain(Object) | |
| 59 | */ | |
| 60 | public Constraint constrain(Object example) | |
| 61 | { | |
| 62 | return null; | |
| 63 | } | |
| 64 | ||
| 65 | /* | |
| 66 | * @see Query#execute() | |
| 67 | */ | |
| 68 | public ObjectSet execute() | |
| 69 | { | |
| 70 | // in future versions soda queries will be translated | |
| 71 | // into org.apache.ojb.broker.query.Query objects and placed | |
| 72 | // into the ojbQuery member variable. | |
| 73 | ||
| 74 | if (ojbQuery != null) | |
| 75 | { | |
| 76 | return new ObjectSetImpl(broker, ojbQuery, limitCount); | |
| 77 | } | |
| 78 | else throw new OJBRuntimeException("internal ojbQuery not filled. Can't execute this query yet!"); | |
| 79 | } | |
| 80 | ||
| 81 | /* | |
| 82 | * @see Query#descendant(String) | |
| 83 | */ | |
| 84 | public Query descendant(String path) | |
| 85 | { | |
| 86 | return this; | |
| 87 | } | |
| 88 | ||
| 89 | /* | |
| 90 | * @see Query#parent(String) | |
| 91 | */ | |
| 92 | public Query parent(String path) | |
| 93 | { | |
| 94 | return this; | |
| 95 | } | |
| 96 | ||
| 97 | /* | |
| 98 | * @see Query#limitSize(int) | |
| 99 | */ | |
| 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 | } |