001: /*
002: * Copyright 2004-2007 Gary Bentley
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License"); you may
005: * not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: * http://www.apache.org/licenses/LICENSE-2.0
008: *
009: * Unless required by applicable law or agreed to in writing, software
010: * distributed under the License is distributed on an "AS IS" BASIS,
011: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012: * See the License for the specific language governing permissions and
013: * limitations under the License.
014: */
015: package org.josql;
016:
017: import java.util.List;
018: import java.util.Map;
019: import java.util.HashMap;
020:
021: /**
022: * This class holds all the "result" information about the execution of a particular
023: * Query. It should be noted that this class holds no reference to the Query object
024: * so that a query can be executed, the results "processed" in some way and then the
025: * results can be cleaned up by the GC.
026: * <p>
027: * @see org.josql.Query#execute(List)
028: */
029: public class QueryResults {
030:
031: // Execution data.
032: Map saveValues = new HashMap();
033: Map timings = null;
034: List results = null;
035: List whereResults = null;
036: List havingResults = null;
037: Map groupByResults = null;
038:
039: Map groupBySaveValues = null;
040:
041: public QueryResults() {
042:
043: }
044:
045: public Map getGroupBySaveValues(List k) {
046:
047: if (this .groupBySaveValues == null) {
048:
049: return null;
050:
051: }
052:
053: return (Map) this .groupBySaveValues.get(k);
054:
055: }
056:
057: /**
058: * Get the save values.
059: *
060: * @return The save values.
061: */
062: public Map getSaveValues() {
063:
064: return this .saveValues;
065:
066: }
067:
068: /**
069: * Get a particular save value for the passed in key.
070: *
071: * @param id The key of the save value.
072: * @return The value it maps to.
073: */
074: public Object getSaveValue(Object id) {
075:
076: if (this .saveValues == null) {
077:
078: return null;
079:
080: }
081:
082: if (id instanceof String) {
083:
084: id = ((String) id).toLowerCase();
085:
086: }
087:
088: return this .saveValues.get(id);
089:
090: }
091:
092: /**
093: * Get the results of executing the query, this is the "final" results, i.e.
094: * of executing ALL of the query.
095: *
096: * @return The results.
097: */
098: public List getResults() {
099:
100: return this .results;
101:
102: }
103:
104: /**
105: * Get the timing information, is a Map of string to double values.
106: *
107: * @return The timings.
108: */
109: public Map getTimings() {
110:
111: return this .timings;
112:
113: }
114:
115: /**
116: * Get the group by results.
117: *
118: * @return The group by results.
119: */
120: public Map getGroupByResults() {
121:
122: return this .groupByResults;
123:
124: }
125:
126: /**
127: * Get the having results.
128: *
129: * @return The having results.
130: */
131: public List getHavingResults() {
132:
133: return this .havingResults;
134:
135: }
136:
137: /**
138: * Get the where results.
139: *
140: * @return The where results.
141: */
142: public List getWhereResults() {
143:
144: return this.whereResults;
145:
146: }
147:
148: }
|