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.io.Serializable;
038: import java.util.*;
039:
040: /**
041: * An empty FxResultSet to be used when an exception is thrown but a result set is still needed
042: * to render a user interface.
043: *
044: * @author Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
045: */
046: public final class FxEmptyResultSet implements FxResultSet,
047: Serializable {
048:
049: private static final long serialVersionUID = 6935555064499770563L;
050: public final static FxPK EMPTY_PK = FxPK.createNewPK();
051: private long creationTime;
052:
053: /**
054: * {@inheritDoc}
055: */
056: public FxEmptyResultSet() {
057: creationTime = System.currentTimeMillis();
058: }
059:
060: /**
061: * {@inheritDoc}
062: */
063: public long getCreationTime() {
064: return creationTime;
065: }
066:
067: /**
068: * {@inheritDoc}
069: */
070: public int getStartIndex() {
071: return 0;
072: }
073:
074: /**
075: * {@inheritDoc}
076: */
077: public int getMaxFetchRows() {
078: return 0;
079: }
080:
081: /**
082: * {@inheritDoc}
083: */
084: public String[] getColumnNames() {
085: return new String[0];
086: }
087:
088: /**
089: * {@inheritDoc}
090: */
091: public List<Object[]> getRows() {
092: return new ArrayList<Object[]>(0);
093: }
094:
095: /**
096: * {@inheritDoc}
097: */
098: public String getColumnName(int pos)
099: throws ArrayIndexOutOfBoundsException {
100: return "";
101: }
102:
103: /**
104: * {@inheritDoc}
105: */
106: public int getColumnIndex(String name) {
107: return 0;
108: }
109:
110: /**
111: * {@inheritDoc}
112: */
113: public Map<String, Integer> getColumnIndexMap() {
114: return new HashMap<String, Integer>(0);
115: }
116:
117: /**
118: * {@inheritDoc}
119: */
120: public int getColumnCount() {
121: return 0;
122: }
123:
124: /**
125: * {@inheritDoc}
126: */
127: public int getRowCount() {
128: return 0;
129: }
130:
131: /**
132: * {@inheritDoc}
133: */
134: public int getTotalRowCount() {
135: return 0;
136: }
137:
138: /**
139: * {@inheritDoc}
140: */
141: public boolean isTruncated() {
142: return false;
143: }
144:
145: /**
146: * {@inheritDoc}
147: */
148: public Object getObject(int rowIndex, int columnIndex)
149: throws ArrayIndexOutOfBoundsException {
150: return null;
151: }
152:
153: /**
154: * {@inheritDoc}
155: */
156: public String getString(int rowIndex, int columnIndex)
157: throws ArrayIndexOutOfBoundsException {
158: return "";
159: }
160:
161: /**
162: * {@inheritDoc}
163: */
164: public int getParserExecutionTime() {
165: return 0;
166: }
167:
168: /**
169: * {@inheritDoc}
170: */
171: public int getDbSearchTime() {
172: return 0;
173: }
174:
175: /**
176: * {@inheritDoc}
177: */
178: public int getFetchTime() {
179: return 0;
180: }
181:
182: /**
183: * {@inheritDoc}
184: */
185: public int getTotalTime() {
186: return 0;
187: }
188:
189: /**
190: * {@inheritDoc}
191: */
192: public ResultLocation getLocation() {
193: return AdminResultLocations.DEFAULT;
194: }
195:
196: /**
197: * {@inheritDoc}
198: */
199: public ResultViewType getViewType() {
200: return ResultViewType.LIST;
201: }
202:
203: /**
204: * {@inheritDoc}
205: */
206: public List<FxFoundType> getContentTypes() {
207: return new ArrayList<FxFoundType>(0);
208: }
209:
210: /**
211: * Dummy interator
212: */
213: private class RowIterator implements Iterator<FxResultRow> {
214: int index = 0;
215:
216: /**
217: * {@inheritDoc}
218: */
219: public boolean hasNext() {
220: return false;
221: }
222:
223: /**
224: * {@inheritDoc}
225: */
226: public FxResultRow next() {
227: return new FxResultRow(FxEmptyResultSet.this , 0);
228: }
229:
230: /**
231: * {@inheritDoc}
232: */
233: public void remove() {
234: throw new UnsupportedOperationException(
235: "Removing rows not supported");
236: }
237: }
238:
239: /**
240: * {@inheritDoc}
241: */
242: public Iterable<FxResultRow> getResultRows() {
243: return new Iterable<FxResultRow>() {
244: public Iterator<FxResultRow> iterator() {
245: return new RowIterator();
246: }
247: };
248: }
249:
250: /**
251: * {@inheritDoc}
252: */
253: public FxResultRow getResultRow(int index) {
254: return new FxResultRow(this , index);
255: }
256:
257: /**
258: * {@inheritDoc}
259: */
260: public long getCreatedBriefcaseId() {
261: return -1;
262: }
263:
264: /**
265: * {@inheritDoc}
266: */
267: public <T> List<T> collectColumn(int columnIndex) {
268: return new ArrayList<T>(0);
269: }
270: }
|