001: //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/ogcwebservices/csw/discovery/SearchResults.java $
002: /*---------------- FILE HEADER ------------------------------------------
003:
004: This file is part of deegree.
005: Copyright (C) 2001-2008 by:
006: EXSE, Department of Geography, University of Bonn
007: http://www.giub.uni-bonn.de/deegree/
008: lat/lon GmbH
009: http://www.lat-lon.de
010:
011: This library is free software; you can redistribute it and/or
012: modify it under the terms of the GNU Lesser General Public
013: License as published by the Free Software Foundation; either
014: version 2.1 of the License, or (at your option) any later version.
015:
016: This library is distributed in the hope that it will be useful,
017: but WITHOUT ANY WARRANTY; without even the implied warranty of
018: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: Lesser General Public License for more details.
020:
021: You should have received a copy of the GNU Lesser General Public
022: License along with this library; if not, write to the Free Software
023: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024:
025: Contact:
026:
027: Andreas Poth
028: lat/lon GmbH
029: Aennchenstr. 19
030: 53115 Bonn
031: Germany
032: E-Mail: poth@lat-lon.de
033:
034: Prof. Dr. Klaus Greve
035: Department of Geography
036: University of Bonn
037: Meckenheimer Allee 166
038: 53115 Bonn
039: Germany
040: E-Mail: greve@giub.uni-bonn.de
041:
042:
043: ---------------------------------------------------------------------------*/
044: package org.deegree.ogcwebservices.csw.discovery;
045:
046: import java.net.URI;
047: import java.net.URISyntaxException;
048: import java.util.Date;
049: import java.util.GregorianCalendar;
050:
051: import org.deegree.ogcwebservices.InvalidParameterValueException;
052: import org.w3c.dom.Node;
053:
054: /**
055: * Class representation of a <csw:SearchResults>-element.
056: *
057: * The SearchResults is a generic container for the actual response to a
058: * GetRecords request. The content of the SearchResults is the set of records
059: * returned by the GetRecords operation. The actual records returned by the
060: * catalogue should substitute for AbstractRecord.
061: *
062: * @author <a href="mailto:poth@lat-lon.de">Andreas Poth </a>
063: * @author <a href="mailto:tfr@users.sourceforge.net">Torsten Friebe </a>
064: * @author <a href="mailto:tfr@users.sourceforge.net">Markus Schneider </a>
065: * @author last edited by: $Author: apoth $
066: *
067: * @version 2.0, $Revision: 9345 $, $Date: 2007-12-27 08:22:25 -0800 (Thu, 27 Dec 2007) $
068: */
069:
070: public class SearchResults {
071:
072: private static final String[] ELEMENT_SETS = { "brief", "summary",
073: "full" };
074:
075: private URI requestId = null;
076:
077: private URI resultSetId = null;
078:
079: private String elementSet = null;
080:
081: private URI recordSchema = null;
082:
083: private int numberOfRecordsReturned = 0;
084:
085: private int numberOfRecordsMatched = 0;
086:
087: private int nextRecord = 0;
088:
089: private Date expires = null;
090:
091: private Node recordsParentNode;
092:
093: /**
094: *
095: * @param requestId
096: * @param resultSetId
097: * @param elementSet
098: * @param recordSchema
099: * @param numberOfRecordsReturned
100: * @param nextRecord
101: * @param recordsParentNode
102: * @throws InvalidParameterValueException
103: */
104: SearchResults(String requestId, String resultSetId,
105: String elementSet, String recordSchema,
106: int numberOfRecordsReturned, int numberOfRecordsMatched,
107: int nextRecord, Node recordsParentNode, String expires)
108: throws InvalidParameterValueException {
109:
110: if (requestId != null) {
111: try {
112: this .requestId = new URI(null, requestId, null);
113: } catch (URISyntaxException e) {
114: throw new InvalidParameterValueException(
115: "Value '"
116: + requestId
117: + "' of Parameter 'requestId' does not denote a valid URI.");
118: }
119: }
120:
121: if (resultSetId != null) {
122: try {
123: this .resultSetId = new URI(null, resultSetId, null);
124: } catch (URISyntaxException e) {
125: throw new InvalidParameterValueException(
126: "Value '"
127: + resultSetId
128: + "' of Parameter 'resultSetId' does not denote a valid URI.");
129: }
130: }
131:
132: if (elementSet != null) {
133: for (int i = 0; i < ELEMENT_SETS.length; i++) {
134: if (ELEMENT_SETS[i].equals(elementSet)) {
135: this .elementSet = elementSet;
136: }
137: }
138: if (this .elementSet == null) {
139: throw new InvalidParameterValueException(
140: "Value '"
141: + elementSet
142: + "' of Parameter 'elementSet' is invalid. Valid parameters"
143: + " are: 'full', 'summary' and 'brief'.");
144: }
145: }
146:
147: if (recordSchema != null) {
148: try {
149: this .recordSchema = new URI(null, recordSchema, null);
150: } catch (URISyntaxException e) {
151: throw new InvalidParameterValueException(
152: "Value '"
153: + recordSchema
154: + "' of Parameter 'recordSchema' does not denote a valid URI.");
155: }
156: }
157:
158: this .numberOfRecordsReturned = numberOfRecordsReturned;
159: this .numberOfRecordsMatched = numberOfRecordsMatched;
160: // TODO
161: this .expires = new GregorianCalendar().getTime();//TimeTools.createCalendar( expires ).getTime();
162: this .nextRecord = nextRecord;
163: this .recordsParentNode = recordsParentNode;
164: }
165:
166: /**
167: *
168: */
169: public URI getRequestId() {
170: return requestId;
171: }
172:
173: /**
174: * A server-generated identifier for the result set. May be used in
175: * subsequent GetRecords operations to further refine the result set. If the
176: * server does not implement this capability then the attribute should be
177: * omitted.
178: */
179: public URI getResultSetId() {
180: return resultSetId;
181: }
182:
183: /**
184: * The element set returned (brief, summary or full). This is null if
185: * getElementNames of <tt>GetRecord</tt>!= null; Optional
186: */
187: public String getElementSet() {
188: return elementSet;
189: }
190:
191: /**
192: * A reference to the type or schema of the records returned. Optional
193: */
194: public URI getRecordSchema() {
195: return recordSchema;
196: }
197:
198: /**
199: * Number of records found by the GetRecords operation
200: */
201: public int getNumberOfRecordsMatched() {
202: return numberOfRecordsMatched;
203: }
204:
205: /**
206: * Number of records actually returned to client. This may not be the entire
207: * result set since some servers may limit the number of records returned to
208: * limit the size of the response package transmitted to the client.
209: * Subsequent queries may be executed to see more of the result set. The
210: * nextRecord attribute will indicate to the client where to begin the next
211: * query
212: */
213: public int getNumberOfRecordsReturned() {
214: return numberOfRecordsReturned;
215: }
216:
217: /**
218: * Start position of next record. A value of 0 means all records have been
219: * returned.
220: */
221: public int getNextRecord() {
222: return nextRecord;
223: }
224:
225: /**
226: * Returns the contents of the <SearchResults>-element.
227: */
228: public Node getRecords() {
229: return recordsParentNode;
230: }
231:
232: /**
233: *
234: */
235: public Date getExpires() {
236: return expires;
237: }
238:
239: }
|