KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > josql > QueryResults


1 /*
2  * Copyright 2004-2005 Gary Bentley
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may
5  * not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */

15 package org.josql;
16
17 import java.util.List JavaDoc;
18 import java.util.ArrayList JavaDoc;
19 import java.util.Map JavaDoc;
20 import java.util.HashMap JavaDoc;
21 import java.util.LinkedHashMap JavaDoc;
22
23 /**
24  * This class holds all the "result" information about the execution of a particular
25  * Query. It should be noted that this class holds no reference to the Query object
26  * so that a query can be executed, the results "processed" in some way and then the
27  * results can be cleaned up by the GC.
28  * <p>
29  * Last Modified By: $Author: barrygently $<br />
30  * Last Modified On: $Date: 2005/04/28 05:48:59 $<br />
31  * Current Revision: $Revision: 1.2 $<br />
32  * <p>
33  * @see org.josql.Query#execute(List)
34  */

35 public class QueryResults
36 {
37
38     // Execution data.
39
Map JavaDoc saveValues = new HashMap JavaDoc ();
40     Map JavaDoc timings = null;
41     List JavaDoc results = null;
42     List JavaDoc whereResults = null;
43     List JavaDoc havingResults = null;
44     Map JavaDoc groupByResults = null;
45
46     Map JavaDoc groupBySaveValues = null;
47
48     public QueryResults ()
49     {
50
51     }
52
53     public Map JavaDoc getGroupBySaveValues (List JavaDoc k)
54     {
55
56     if (this.groupBySaveValues == null)
57     {
58
59         return null;
60
61     }
62
63     return (Map JavaDoc) this.groupBySaveValues.get (k);
64
65     }
66
67     /**
68      * Get the save values.
69      *
70      * @return The save values.
71      */

72     public Map JavaDoc getSaveValues ()
73     {
74
75     return this.saveValues;
76
77     }
78
79     /**
80      * Get a particular save value for the passed in key.
81      *
82      * @param id The key of the save value.
83      * @return The value it maps to.
84      */

85     public Object JavaDoc getSaveValue (Object JavaDoc id)
86     {
87
88     if (this.saveValues == null)
89     {
90
91         return null;
92
93     }
94
95     if (id instanceof String JavaDoc)
96     {
97
98         id = ((String JavaDoc) id).toLowerCase ();
99
100     }
101
102     return this.saveValues.get (id);
103
104     }
105
106     /**
107      * Get the results of executing the query, this is the "final" results, i.e.
108      * of executing ALL of the query.
109      *
110      * @return The results.
111      */

112     public List JavaDoc getResults ()
113     {
114
115     return this.results;
116
117     }
118
119     /**
120      * Get the timing information, is a Map of string to double values.
121      *
122      * @return The timings.
123      */

124     public Map JavaDoc getTimings ()
125     {
126
127     return this.timings;
128
129     }
130
131     /**
132      * Get the group by results.
133      *
134      * @return The group by results.
135      */

136     public Map JavaDoc getGroupByResults ()
137     {
138
139     return this.groupByResults;
140
141     }
142
143     /**
144      * Get the having results.
145      *
146      * @return The having results.
147      */

148     public List JavaDoc getHavingResults ()
149     {
150
151     return this.havingResults;
152
153     }
154
155     /**
156      * Get the where results.
157      *
158      * @return The where results.
159      */

160     public List JavaDoc getWhereResults ()
161     {
162
163     return this.whereResults;
164
165     }
166
167 }
168
Popular Tags