001: /***************************************************************
002: * This file is part of the [fleXive](R) project.
003: *
004: * Copyright (c) 1999-2008
005: * UCS - unique computing solutions gmbh (http://www.ucs.at)
006: * All rights reserved
007: *
008: * The [fleXive](R) project is free software; you can redistribute
009: * it and/or modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation;
011: * either version 2 of the License, or (at your option) any
012: * later version.
013: *
014: * The GNU General Public License can be found at
015: * http://www.gnu.org/copyleft/gpl.html.
016: * A copy is found in the textfile GPL.txt and important notices to the
017: * license from the author are found in LICENSE.txt distributed with
018: * these libraries.
019: *
020: * This library is distributed in the hope that it will be useful,
021: * but WITHOUT ANY WARRANTY; without even the implied warranty of
022: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
023: * GNU General Public License for more details.
024: *
025: * For further information about UCS - unique computing solutions gmbh,
026: * please see the company website: http://www.ucs.at
027: *
028: * For further information about [fleXive](R), please see the
029: * project website: http://www.flexive.org
030: *
031: *
032: * This copyright notice MUST APPEAR in all copies of the file!
033: ***************************************************************/package com.flexive.shared.search;
034:
035: import com.flexive.shared.content.FxPK;
036:
037: import java.util.List;
038: import java.util.Map;
039:
040: /**
041: * FxSQL result set
042: *
043: * @author Gregor Schober (gregor.schober@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
044: */
045: public interface FxResultSet {
046:
047: /**
048: * Returns the time this resultset was created at.
049: *
050: * @return the creation time of the resultset
051: */
052: public long getCreationTime();
053:
054: /**
055: * Returns the start index specified with the search.
056: *
057: * @return the start index specified with the search
058: */
059: public int getStartIndex();
060:
061: /**
062: * Returns the maximum rows parameter specified with the search.
063: *
064: * @return the maximum rows parameter specified with the search
065: */
066: public int getMaxFetchRows();
067:
068: /**
069: * Returns the column names.
070: *
071: * @return the column names.
072: */
073: public String[] getColumnNames();
074:
075: /**
076: * Returns all rows.
077: *
078: * @return the rows
079: */
080: public List<Object[]> getRows();
081:
082: /**
083: * Get the designated column's name.
084: *
085: * @return the column name at the given position
086: * @param pos the first column is 1, the second is 2, ...
087: * @throws ArrayIndexOutOfBoundsException if the given position is not valid
088: */
089: public String getColumnName(int pos)
090: throws ArrayIndexOutOfBoundsException;
091:
092: /**
093: * Get the index for the given column. Returns -1 if the column name
094: * does not exist in the result set.
095: *
096: * @param name the column name
097: * @return the index for the given column name, 1-based
098: */
099: public int getColumnIndex(String name);
100:
101: /**
102: * Returns a map returning the column index using the lowercase column name as a key.
103: *
104: * @return a map returning the column index using the lowercase column name as a key.
105: */
106: public Map<String, Integer> getColumnIndexMap();
107:
108: /**
109: * Returns the number of columns in this FxResultSet object.
110: *
111: * @return the number of columns
112: */
113: public int getColumnCount();
114:
115: /**
116: * Returns the number of rows in this FxResultSet object.
117: *
118: * @return the number of rows
119: */
120: public int getRowCount();
121:
122: /**
123: * Returns the total row count.
124: * <p />
125: * The total row count is the number of entries found by the search, even if they are not contained
126: * in this resultset becaus of the specified start and end index.
127: *
128: * @return the total row count
129: */
130: public int getTotalRowCount();
131:
132: /**
133: * Returns true if the found entry set was truncted.
134: *
135: * @return true if the result was truncated
136: */
137: public boolean isTruncated();
138:
139: /**
140: * Retrieves the value of the designated column in the current row of this FxResultSet object as a
141: * Object.
142: *
143: * @param rowIndex - the first row is 1, the second is 2, ...
144: * @param columnIndex - the first column is 1, the second is 2, ...
145: * @return the column value; if the value is SQL NULL, the value returned is null
146: * @throws ArrayIndexOutOfBoundsException if the given row/column combination is out of range
147: */
148: public Object getObject(int rowIndex, int columnIndex)
149: throws ArrayIndexOutOfBoundsException;
150:
151: /**
152: * Retrieves the value of the designated column in the current row of this FxResultSet object as a
153: * String.
154: *
155: * @param rowIndex - the first row is 1, the second is 2, ...
156: * @param columnIndex - the first column is 1, the second is 2, ...
157: * @return the column value; if the value is SQL NULL, the value returned is null
158: * @throws ArrayIndexOutOfBoundsException if the given row/column combination is out of range
159: */
160: public String getString(int rowIndex, int columnIndex)
161: throws ArrayIndexOutOfBoundsException;
162:
163: /**
164: * Returns the time that was spent parsing the statement.
165: *
166: * @return the time that was spent parsing the statement
167: */
168: public int getParserExecutionTime();
169:
170: /**
171: * Returns the time needed to find all matching records in the database.
172: *
173: * @return the time needed to find all matching records in the database
174: */
175: public int getDbSearchTime();
176:
177: /**
178: * Returns the time needed to find fetch the matching records from the database.
179: *
180: * @return the time needed to find fetch the matching records from the database
181: */
182: public int getFetchTime();
183:
184: /**
185: * Returns the total time spent for the search.
186: * <p />
187: * This time includes the parse time, search time, fetch time and additional
188: * programm logic time.
189: *
190: * @return the total time spent for the search
191: */
192: public int getTotalTime();
193:
194: /**
195: * Returns the location for which the query was executed.
196: *
197: * @return the location for which the query was executed.
198: */
199: public ResultLocation getLocation();
200:
201: /**
202: * Returns the view type for which the query was executed.
203: *
204: * @return the view type for which the query was executed.
205: */
206: public ResultViewType getViewType();
207:
208: /**
209: * Returns a list of all content types that are part of the resultset.
210: * <p />
211: * Items filtered by the parameter CTYPE are also taken into account.
212: *
213: * @return a list of all content types that are part of the resultset
214: */
215: public List<FxFoundType> getContentTypes();
216:
217: /**
218: * Return a result row iterator for this result set.
219: *
220: * @return a result row iterator for this result set.
221: */
222: public Iterable<FxResultRow> getResultRows();
223:
224: /**
225: * Return a result row wrapper for the given row number.
226: *
227: * @param index the row number
228: * @return a result row wrapper for the given row number.
229: */
230: public FxResultRow getResultRow(int index);
231:
232: /**
233: * If the query created a new briefcase, its ID can be retrieved with this method.
234: *
235: * @return the ID of the created briefcase, or -1 if no briefcase was created
236: */
237: public long getCreatedBriefcaseId();
238:
239: /**
240: * Projects a single column to a list.
241: *
242: * @param columnIndex the 1-basedcolumn index
243: * @return all column values collected in a list
244: */
245: <T> List<T> collectColumn(int columnIndex);
246: }
|