Changeset 2088
- Timestamp:
- 08/14/12 17:22:03 (12 years ago)
- Location:
- SRUClient/trunk/src/main/java/eu/clarin/sru
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUAbstractRequest.java
r2047 r2088 1 /** 2 * This software is copyright (c) 2011 by 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 * This is free software. You can redistribute it 5 * and/or modify it under the terms described in 6 * the GNU General Public License v3 of which you 7 * should have received a copy. Otherwise you can download 8 * it from 9 * 10 * http://www.gnu.org/licenses/gpl-3.0.txt 11 * 12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 13 * 14 * @license http://www.gnu.org/licenses/gpl-3.0.txt 15 * GNU General Public License v3 16 */ 1 17 package eu.clarin.sru.client; 2 18 … … 6 22 7 23 8 publicabstract class SRUAbstractRequest {9 protected static final String PARAM_OPERATION= "operation";10 protected static final String PARAM_VERSION= "version";11 protected static final String PARAM_RECORD_PACKING= "recordPacking";12 protected static final String PARAM_STYLESHEET= "stylesheet";13 protected static final String PARAM_QUERY= "query";14 protected static final String PARAM_START_RECORD= "startRecord";15 protected static final String PARAM_MAXIMUM_RECORDS= "maximumRecords";16 protected static final String PARAM_RECORD_SCHEMA= "recordSchema";17 protected static final String PARAM_RECORD_X_PATH= "recordXPath";18 protected static final String PARAM_RESULT_SET_TTL= "resultSetTTL";19 protected static final String PARAM_SORT_KEYS= "sortKeys";20 protected static final String PARAM_SCAN_CLAUSE= "scanClause";21 protected static final String PARAM_RESPONSE_POSITION= "responsePosition";22 protected static final String PARAM_MAXIMUM_TERMS= "maximumTerms";23 protected static final String RECORD_PACKING_XML= "xml";24 protected static final String RECORD_PACKING_STRING= "string";25 private static final String OP_EXPLAIN 26 private static final String OP_SCAN 27 private static final String OP_SEARCH_RETRIEVE 28 private static final String VERSION_1_1 29 private static final String VERSION_1_2 30 private static final String PARAM_EXTENSION_PREFIX 31 /** for end-point conformance testing only. never use in production */32 public static final String X_MALFORMED_VERSION 24 abstract class SRUAbstractRequest { 25 static final String PARAM_OPERATION = "operation"; 26 static final String PARAM_VERSION = "version"; 27 static final String PARAM_RECORD_PACKING = "recordPacking"; 28 static final String PARAM_STYLESHEET = "stylesheet"; 29 static final String PARAM_QUERY = "query"; 30 static final String PARAM_START_RECORD = "startRecord"; 31 static final String PARAM_MAXIMUM_RECORDS = "maximumRecords"; 32 static final String PARAM_RECORD_SCHEMA = "recordSchema"; 33 static final String PARAM_RECORD_X_PATH = "recordXPath"; 34 static final String PARAM_RESULT_SET_TTL = "resultSetTTL"; 35 static final String PARAM_SORT_KEYS = "sortKeys"; 36 static final String PARAM_SCAN_CLAUSE = "scanClause"; 37 static final String PARAM_RESPONSE_POSITION = "responsePosition"; 38 static final String PARAM_MAXIMUM_TERMS = "maximumTerms"; 39 static final String RECORD_PACKING_XML = "xml"; 40 static final String RECORD_PACKING_STRING = "string"; 41 private static final String OP_EXPLAIN = "explain"; 42 private static final String OP_SCAN = "scan"; 43 private static final String OP_SEARCH_RETRIEVE = "searchRetrieve"; 44 private static final String VERSION_1_1 = "1.1"; 45 private static final String VERSION_1_2 = "1.2"; 46 private static final String PARAM_EXTENSION_PREFIX = "x-"; 47 /** for end-point conformance testing only. never use in production. */ 48 public static final String X_MALFORMED_VERSION = 33 49 "x-malformed-version"; 34 /** for end-point conformance testing only. never use in production */35 public static final String X_MALFORMED_OPERATION 50 /** for end-point conformance testing only. never use in production. */ 51 public static final String X_MALFORMED_OPERATION = 36 52 "x-maformed-operation"; 37 /** for end-point conformance testing only. never use in production */ 38 public static final String MALFORMED_OMIT = "omit"; 39 40 protected enum SRUOperation { 53 /** for end-point conformance testing only. never use in production. */ 54 public static final String MALFORMED_OMIT = "omit"; 55 56 57 enum SRUOperation { 41 58 EXPLAIN, SCAN, SEARCH_RETRIEVE 42 59 } // enum SRUOperation 43 60 44 protected class URIBuilder { 61 62 class URIBuilder { 45 63 private final StringBuilder sb; 46 64 private boolean firstParam = true; … … 50 68 } 51 69 52 70 53 71 public URIBuilder append(String name, String value) { 54 72 if (name == null) { … … 75 93 } 76 94 77 95 78 96 public URIBuilder append(String name, int value) { 79 97 return append(name, Integer.toString(value)); … … 85 103 } 86 104 } // class 105 /** The URL of the endpoint. */ 87 106 protected final String endpointURI; 107 /** The version to be sued for this request. */ 88 108 protected SRUVersion version; 109 /** A map of extra request data parameters. */ 89 110 protected Map<String, String> extraRequestData; 90 111 private SRUVersion versionPreformed; … … 99 120 100 121 122 /** 123 * Get the endpoint URI. 124 * 125 * @return the endpoiunt URI 126 */ 101 127 public String getEndpointURI() { 102 128 return endpointURI; … … 104 130 105 131 132 /** 133 * Set the version for this request. 134 * 135 * @param version a version of <code>null</code> for client default 136 */ 106 137 public void setVersion(SRUVersion version) { 107 138 this.version = version; … … 109 140 110 141 142 /** 143 * Get the version for this request. 144 * 145 * @return version for this request or <code>null</code> of client default 146 * is used 147 */ 111 148 public SRUVersion getVersion() { 112 149 return version; … … 114 151 115 152 116 public SRUVersion getVersionPerformed() { 117 return versionPreformed; 118 } 119 120 153 /** 154 * Set an extra request parameter for this request. 155 * 156 * @param name 157 * the name for the extra request data parameter 158 * @param value 159 * the value for the extra request data parameter 160 * @throws NullPointerException 161 * if any required argument is <code>null</code> 162 * @throws IllegalArgumentException 163 * if any argument is invalid 164 * @see <a href="http://www.loc.gov/standards/sru/specs/extra-data.html">SRU 165 * Extra Data / Extensions</a> 166 */ 121 167 public void setExtraRequestData(String name, String value) { 122 168 if (name == null) { … … 143 189 144 190 191 /** 192 * Set the value of extra request parameter for this request. 193 * 194 * @param name 195 * the name for the extra request data parameter 196 * @return the value for the extra request data parameter or 197 * <code>null</code> if parameter was not set 198 * @throws NullPointerException 199 * if any required argument is <code>null</code> 200 * @throws IllegalArgumentException 201 * if any argument is invalid 202 * @see <a href="http://www.loc.gov/standards/sru/specs/extra-data.html">SRU 203 * Extra Data / Extensions</a> 204 */ 145 205 public String getExtraRequestData(String name) { 146 206 if (name == null) { … … 150 210 throw new IllegalArgumentException("name is an empty string"); 151 211 } 152 if (!name.startsWith("x-")) { 153 throw new IllegalArgumentException("name must start with 'x-'"); 212 if (!name.startsWith(PARAM_EXTENSION_PREFIX)) { 213 throw new IllegalArgumentException("name must start with '" + 214 PARAM_EXTENSION_PREFIX + "'"); 154 215 } 155 216 if (extraRequestData != null) { … … 160 221 161 222 223 final SRUVersion getVersionPerformed() { 224 return versionPreformed; 225 } 226 227 162 228 final URI makeURI(SRUVersion defaultVersion) 163 229 throws SRUClientException { … … 246 312 247 313 248 protected abstract SRUOperation getOperation(); 249 250 251 protected abstract void addParametersToURI(URIBuilder uri) 252 throws SRUClientException; 314 /** 315 * <em>Note: this method is not a part of public API.</em> 316 * @return a constant for this 317 */ 318 abstract SRUOperation getOperation(); 319 320 321 abstract void addParametersToURI(URIBuilder uri) throws SRUClientException; 253 322 254 323 } // class AbstractSRURequest -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUClient.java
r2024 r2088 1 /** 2 * This software is copyright (c) 2011 by 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 * This is free software. You can redistribute it 5 * and/or modify it under the terms described in 6 * the GNU General Public License v3 of which you 7 * should have received a copy. Otherwise you can download 8 * it from 9 * 10 * http://www.gnu.org/licenses/gpl-3.0.txt 11 * 12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 13 * 14 * @license http://www.gnu.org/licenses/gpl-3.0.txt 15 * GNU General Public License v3 16 */ 1 17 package eu.clarin.sru.client; 2 18 … … 31 47 import eu.clarin.sru.client.SRUScanHandler.WhereInList; 32 48 33 49 /** 50 * A class to perform SRU operations. 51 * <p><em>This class is not thread-safe!</em></p> 52 */ 34 53 public class SRUClient { 35 54 private static final String SRU_NS = … … 52 71 53 72 73 /** 74 * Constructor. 75 * 76 * @param defaultVersion 77 * the default version to use for SRU requests; may be overridden 78 * by individual requests 79 */ 54 80 public SRUClient(SRUVersion defaultVersion) { 55 81 if (defaultVersion == null) { … … 63 89 64 90 91 /** 92 * Register a record data parser. 93 * 94 * @param parser 95 * a parser instance 96 * @throws SRUClientException 97 * if a parser handing the same record schema is already 98 * registered 99 * @throws NullPointerException 100 * if any required argument is <code>null</code> 101 * @throws IllegalArgumentException 102 * if the supplied parser is invalid 103 */ 65 104 public void registerRecordParser(SRURecordDataParser parser) 66 105 throws SRUClientException { … … 85 124 86 125 126 /** 127 * Perform a <em>explain</em> operation. 128 * 129 * @param request 130 * an instance of a {@link SRUExplainRequest} object 131 * @param handler 132 * an instance of {@link SRUExplainHandler} to receive callbacks 133 * when processing the result of this request 134 * @throws SRUClientException 135 * if an unrecoverable error occurred 136 * @throws NullPointerException 137 * if any required argument is <code>null</code> 138 * @see SRUExplainRequest 139 * @see SRUExplainHandler 140 */ 87 141 public void explain(SRUExplainRequest request, SRUExplainHandler handler) 88 142 throws SRUClientException { … … 151 205 152 206 207 /** 208 * Perform a <em>scan</em> operation. 209 * 210 * @param request 211 * an instance of a {@link SRUScanRequest} object 212 * @param handler 213 * an instance of {@link SRUScanHandler} to receive callbacks 214 * when processing the result of this request 215 * @throws SRUClientException 216 * if an unrecoverable error occurred 217 * @throws NullPointerException 218 * if any required argument is <code>null</code> 219 * @see SRUScanRequest 220 * @see SRUScanHandler 221 */ 153 222 public void scan(SRUScanRequest request, SRUScanHandler handler) 154 223 throws SRUClientException { … … 217 286 218 287 288 /** 289 * Perform a <em>searchRetreive</em> operation. 290 * 291 * @param request 292 * an instance of a {@link SRUSearchRetrieveRequest} object 293 * @param handler 294 * an instance of {@link SRUSearchRetrieveHandler} to receive 295 * callbacks when processing the result of this request 296 * @throws SRUClientException 297 * if an unrecoverable error occurred 298 * @throws NullPointerException 299 * if any required argument is <code>null</code> 300 * @see SRUSearchRetrieveRequest 301 * @see SRUSearchRetrieveHandler 302 */ 219 303 public void searchRetrieve(SRUSearchRetrieveRequest request, 220 304 SRUSearchRetrieveHandler handler) throws SRUClientException { … … 611 695 SRURecordPacking packing = parseRecordPacking(reader); 612 696 613 logger.debug("schema = {}, packing = {}, requested packing = {}", 697 logger.debug("schema = {}, packing = {}, " + 698 "requested packing = {}", 614 699 new Object[] { schema, packing, 615 700 request.getRecordPacking() }); … … 617 702 if ((request.getRecordPacking() != null) && 618 703 (packing != request.getRecordPacking())) { 619 logger.warn("requested '{}' record packing, but server responded with '{}' record packing", 620 request.getRecordPacking() 621 .toProtocolString(), packing 622 .toProtocolString()); 704 final SRURecordPacking p = 705 request.getRecordPacking(); 706 logger.warn("requested '{}' record packing, but " + 707 "server responded with '{}' record packing", 708 p.getStringValue(), 709 packing.getStringValue()); 623 710 // XXX: only throw if client is pedantic? 624 throw new SRUClientException( 625 "requested '" + 626 request.getRecordPacking() 627 .toProtocolString() + 628 "' record packing, but server responded with '" + 629 packing.toProtocolString() + 711 throw new SRUClientException("requested '" + 712 p.getStringValue() + 713 "' record packing, but server " + 714 "responded with '" + 715 packing.getStringValue() + 630 716 "' record packing"); 631 717 } … … 664 750 throw new SRUClientException( 665 751 "error parsing record", e); 752 } 753 if (recordData == null) { 754 // FIXME: handle this better? maybe throw? 755 logger.warn("parse did not correctly " 756 + "parse the record, will skip " 757 + "handler callback."); 666 758 } 667 759 } else { -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUClientException.java
r1963 r2088 1 /** 2 * This software is copyright (c) 2011 by 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 * This is free software. You can redistribute it 5 * and/or modify it under the terms described in 6 * the GNU General Public License v3 of which you 7 * should have received a copy. Otherwise you can download 8 * it from 9 * 10 * http://www.gnu.org/licenses/gpl-3.0.txt 11 * 12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 13 * 14 * @license http://www.gnu.org/licenses/gpl-3.0.txt 15 * GNU General Public License v3 16 */ 1 17 package eu.clarin.sru.client; 2 18 19 /** 20 * SRU client exception. 21 */ 3 22 @SuppressWarnings("serial") 4 23 public class SRUClientException extends Exception { 5 24 25 /** 26 * Constructor 27 * 28 * @param message an error message 29 */ 6 30 public SRUClientException(String message) { 7 31 super(message); … … 9 33 10 34 11 public SRUClientException(String message, Throwable t) { 12 super(message, t); 35 /** 36 * Constructor 37 * 38 * @param message an error message 39 * @param cause the cause of the error 40 */ 41 public SRUClientException(String message, Throwable cause) { 42 super(message, cause); 13 43 } 44 14 45 } // class SRUClientException -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUDefaultHandler.java
r1963 r2088 1 /** 2 * This software is copyright (c) 2011 by 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 * This is free software. You can redistribute it 5 * and/or modify it under the terms described in 6 * the GNU General Public License v3 of which you 7 * should have received a copy. Otherwise you can download 8 * it from 9 * 10 * http://www.gnu.org/licenses/gpl-3.0.txt 11 * 12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 13 * 14 * @license http://www.gnu.org/licenses/gpl-3.0.txt 15 * GNU General Public License v3 16 */ 1 17 package eu.clarin.sru.client; 2 18 19 /** 20 * A handler implementing all interfaces for all three response handler types. 21 * 22 * <p> 23 * This class is available as a convenience base class for SRU applications: it 24 * implements teh three response handler interfaces: 25 * </p> 26 * <ul> 27 * <li>{@link SRUExplainHandler}</li> 28 * <li>{@link SRUScanHandler}</li> 29 * <li>{@link SRUSearchRetrieveHandler}</li> 30 * </ul> 31 * 32 * @see SRUExplainHandler 33 * @see SRUScanHandler 34 * @see SRUSearchRetrieveHandler 35 */ 3 36 public interface SRUDefaultHandler extends SRUExplainHandler, SRUScanHandler, 4 37 SRUSearchRetrieveHandler { -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUDefaultHandlerAdapter.java
r2083 r2088 1 /** 2 * This software is copyright (c) 2011 by 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 * This is free software. You can redistribute it 5 * and/or modify it under the terms described in 6 * the GNU General Public License v3 of which you 7 * should have received a copy. Otherwise you can download 8 * it from 9 * 10 * http://www.gnu.org/licenses/gpl-3.0.txt 11 * 12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 13 * 14 * @license http://www.gnu.org/licenses/gpl-3.0.txt 15 * GNU General Public License v3 16 */ 1 17 package eu.clarin.sru.client; 2 18 … … 6 22 import javax.xml.stream.XMLStreamReader; 7 23 24 25 /** 26 * Default base class for SRU client response handlers. 27 * <p> 28 * This class is available as a convenience base class for SRU client 29 * applications: it provides default implementations for all of the callbacks in 30 * the three request handler handler classes: 31 * </p> 32 * <ul> 33 * <li>{@link SRUExplainHandler}</li> 34 * <li>{@link SRUScanHandler}</li> 35 * <li>{@link SRUSearchRetrieveHandler}</li> 36 * </ul> 37 * <p> 38 * Application writers can extend this class when they need to implement only 39 * part of an interface; parser writers can instantiate this class to provide 40 * default handlers when the application has not supplied its own. 41 * </p> 42 * 43 * @see SRUExplainHandler 44 * @see SRUScanHandler 45 * @see SRUSearchRetrieveHandler 46 */ 8 47 public class SRUDefaultHandlerAdapter implements SRUDefaultHandler { 9 48 -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUDiagnostic.java
r1969 r2088 1 /** 2 * This software is copyright (c) 2011 by 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 * This is free software. You can redistribute it 5 * and/or modify it under the terms described in 6 * the GNU General Public License v3 of which you 7 * should have received a copy. Otherwise you can download 8 * it from 9 * 10 * http://www.gnu.org/licenses/gpl-3.0.txt 11 * 12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 13 * 14 * @license http://www.gnu.org/licenses/gpl-3.0.txt 15 * GNU General Public License v3 16 */ 1 17 package eu.clarin.sru.client; 2 18 19 /** 20 * Class to hold a SRU diagnostic. 21 * 22 * @see <a href="http://www.loc.gov/standards/sru/specs/diagnostics.html">SRU 23 * Diagnostics</a> 24 * @see <a 25 * href="http://www.loc.gov/standards/sru/resources/diagnostics-list.html">SRU 26 * Diagnostics List</a> 27 */ 3 28 public final class SRUDiagnostic { 4 29 private final String uri; … … 7 32 8 33 34 /** 35 * Constructor. 36 * 37 * @param uri 38 * the URI identifying the diagnostic 39 * @param details 40 * supplementary information available, often in a format 41 * specified by the diagnostic or <code>null</code> 42 * @param message 43 * human readable message to display to the end user or 44 * <code>null</code> 45 */ 9 46 public SRUDiagnostic(String uri, String details, String message) { 10 this.uri 47 this.uri = uri; 11 48 this.details = details; 12 49 this.message = message; … … 14 51 15 52 53 /** 54 * Get diagnostic's identifying URI. 55 * 56 * @return diagnostic code 57 */ 16 58 public String getURI() { 17 59 return uri; … … 19 61 20 62 63 /** 64 * Get supplementary information for this diagnostic. The format for this 65 * value is often specified by the diagnostic code. 66 * 67 * @return supplementary information 68 */ 21 69 public String getDetails() { 22 70 return details; … … 24 72 25 73 74 /** 75 * Get human readable message. 76 * 77 * @return human readable message 78 */ 26 79 public String getMessage() { 27 80 return message; -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUExplainHandler.java
r2021 r2088 1 /** 2 * This software is copyright (c) 2011 by 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 * This is free software. You can redistribute it 5 * and/or modify it under the terms described in 6 * the GNU General Public License v3 of which you 7 * should have received a copy. Otherwise you can download 8 * it from 9 * 10 * http://www.gnu.org/licenses/gpl-3.0.txt 11 * 12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 13 * 14 * @license http://www.gnu.org/licenses/gpl-3.0.txt 15 * GNU General Public License v3 16 */ 1 17 package eu.clarin.sru.client; 2 18 … … 6 22 import javax.xml.stream.XMLStreamReader; 7 23 24 25 /** 26 * Receive notifications to the response of a <em>explain</em> request. 27 * 28 * @see SRUExplainRequest 29 * @see <a href="http://www.loc.gov/standards/sru/specs/explain.html">SRU Explain Operation</a> 30 */ 8 31 public interface SRUExplainHandler { 9 32 33 /** 34 * Receive notification of diagnostics. 35 * 36 * @param diagnostics 37 * a list of {@link SRUDiagnostic} 38 * @throws SRUClientException 39 * any SRU exception, possibly wrapping another exception 40 * @see SRUDiagnostic 41 */ 10 42 public void onDiagnostics(List<SRUDiagnostic> diagnostics) 11 43 throws SRUClientException; 12 44 45 46 /** 47 * Receive notification of request statistics. 48 * 49 * @param bytes 50 * the size of the response in bytes 51 * @param millisTotal 52 * the total time spend processing the request 53 * @param millisNetwork 54 * the time spend performing network operations 55 * @param millisParsing 56 * the time spend parsing the response 57 */ 13 58 public void onRequestStatistics(int bytes, long millisTotal, 14 59 long millisNetwork, long millisParsing); 15 60 61 62 /** 63 * Receive notification of extra response data. 64 * 65 * @param reader 66 * a {@link XMLStreamReader} to parse the extra response data 67 * @throws XMLStreamException 68 * an error occurred while parsing the response 69 * @throws SRUClientException 70 * any SRU exception, possibly wrapping another exception 71 * @see <a href="http://www.loc.gov/standards/sru/specs/extra-data.html">SRU 72 * Extra Data / Extensions</a> 73 */ 16 74 public void onExtraResponseData(XMLStreamReader reader) 17 75 throws XMLStreamException, SRUClientException; -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUExplainRequest.java
r2024 r2088 1 /** 2 * This software is copyright (c) 2011 by 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 * This is free software. You can redistribute it 5 * and/or modify it under the terms described in 6 * the GNU General Public License v3 of which you 7 * should have received a copy. Otherwise you can download 8 * it from 9 * 10 * http://www.gnu.org/licenses/gpl-3.0.txt 11 * 12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 13 * 14 * @license http://www.gnu.org/licenses/gpl-3.0.txt 15 * GNU General Public License v3 16 */ 1 17 package eu.clarin.sru.client; 2 18 19 /** 20 * An object for performing a <em>explain</em> operation. 21 * 22 * @see SRUExplainHandler 23 * @see <a href="http://www.loc.gov/standards/sru/specs/explain.html">SRU Explain Operation</a> 24 */ 3 25 public final class SRUExplainRequest extends SRUAbstractRequest { 4 26 private SRURecordPacking recordPacking; 5 27 6 28 7 protected SRUExplainRequest(String baseURI) { 29 /** 30 * Constructor. 31 * 32 * @param baseURI 33 * the baseURI of the endpoint 34 */ 35 public SRUExplainRequest(String baseURI) { 8 36 super(baseURI); 9 37 } 10 38 11 39 40 /** 41 * Set the requested record packing. 42 * 43 * @param recordPacking 44 * the requested record packing 45 * @see SRURecordPacking 46 */ 12 47 public void setRecordPacking(SRURecordPacking recordPacking) { 13 48 if (recordPacking == null) { … … 18 53 19 54 55 /** 56 * Get the requested record packing. 57 * 58 * @return the requested record packing 59 * @see SRURecordPacking 60 */ 20 61 public SRURecordPacking getRecordPacking() { 21 62 return recordPacking; … … 24 65 25 66 @Override 26 protectedSRUOperation getOperation() {67 SRUOperation getOperation() { 27 68 return SRUOperation.EXPLAIN; 28 69 } … … 30 71 31 72 @Override 32 protected void addParametersToURI(URIBuilder uriBuilder) 33 throws SRUClientException { 73 void addParametersToURI(URIBuilder uriBuilder) throws SRUClientException { 34 74 // recordPacking 35 75 if (recordPacking != null) { -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRURecordData.java
r1969 r2088 1 /** 2 * This software is copyright (c) 2011 by 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 * This is free software. You can redistribute it 5 * and/or modify it under the terms described in 6 * the GNU General Public License v3 of which you 7 * should have received a copy. Otherwise you can download 8 * it from 9 * 10 * http://www.gnu.org/licenses/gpl-3.0.txt 11 * 12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 13 * 14 * @license http://www.gnu.org/licenses/gpl-3.0.txt 15 * GNU General Public License v3 16 */ 1 17 package eu.clarin.sru.client; 2 18 19 /** 20 * Interface for parsed record data. 21 * 22 */ 3 23 public interface SRURecordData { 4 24 25 /** 26 * This record is transient. If you want to store the data to process it 27 * later, you need to create a copy of the data. 28 * 29 * @return <code>true</code>, if record is transient, 30 * <code>false<code> otherwis 31 */ 5 32 public boolean isTransient(); 6 33 34 35 /** 36 * The record schema for this record. 37 * 38 * @return the record schema 39 */ 7 40 public String getRecordSchema(); 8 41 -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRURecordDataParser.java
r1975 r2088 1 /** 2 * This software is copyright (c) 2011 by 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 * This is free software. You can redistribute it 5 * and/or modify it under the terms described in 6 * the GNU General Public License v3 of which you 7 * should have received a copy. Otherwise you can download 8 * it from 9 * 10 * http://www.gnu.org/licenses/gpl-3.0.txt 11 * 12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 13 * 14 * @license http://www.gnu.org/licenses/gpl-3.0.txt 15 * GNU General Public License v3 16 */ 1 17 package eu.clarin.sru.client; 2 18 … … 4 20 import javax.xml.stream.XMLStreamReader; 5 21 22 23 /** 24 * A parser to parse record data and create appropriate Java objects. 25 * 26 */ 6 27 public interface SRURecordDataParser { 7 28 29 /** 30 * The record schema this parser is able to process. 31 * 32 * @return the record schema this parser is able to process 33 */ 8 34 public String getRecordSchema(); 9 35 36 37 /** 38 * Parse a record data into a Java object. 39 * 40 * @param reader 41 * a {@link XMLStreamReader} to parse the record data 42 * @return the parsed record 43 * @throws XMLStreamException 44 * an error occurred while parsing the response 45 * @throws SRUClientException 46 * any SRU exception, possibly wrapping another exception 47 * @see SRURecordData 48 */ 10 49 public SRURecordData parse(XMLStreamReader reader) 11 50 throws XMLStreamException, SRUClientException; -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRURecordPacking.java
r1985 r2088 1 /** 2 * This software is copyright (c) 2011 by 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 * This is free software. You can redistribute it 5 * and/or modify it under the terms described in 6 * the GNU General Public License v3 of which you 7 * should have received a copy. Otherwise you can download 8 * it from 9 * 10 * http://www.gnu.org/licenses/gpl-3.0.txt 11 * 12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 13 * 14 * @license http://www.gnu.org/licenses/gpl-3.0.txt 15 * GNU General Public License v3 16 */ 1 17 package eu.clarin.sru.client; 2 18 19 /** 20 * SRU Record packing 21 */ 3 22 public enum SRURecordPacking { 4 XML, STRING; 23 /** 24 * XML record packing 25 */ 26 XML { 27 @Override 28 String getStringValue() { 29 return "xml"; 30 } 31 }, 5 32 6 public String toProtocolString() { 7 switch (this) { 8 case XML: 9 return "xml"; 10 case STRING: 33 /** 34 * String record packing 35 */ 36 STRING { 37 @Override 38 String getStringValue() { 11 39 return "string"; 12 default:13 return null;14 40 } 15 } 41 }; 42 43 abstract String getStringValue(); 16 44 17 45 } // enum SRURecordPacking -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUScanHandler.java
r2021 r2088 1 /** 2 * This software is copyright (c) 2011 by 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 * This is free software. You can redistribute it 5 * and/or modify it under the terms described in 6 * the GNU General Public License v3 of which you 7 * should have received a copy. Otherwise you can download 8 * it from 9 * 10 * http://www.gnu.org/licenses/gpl-3.0.txt 11 * 12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 13 * 14 * @license http://www.gnu.org/licenses/gpl-3.0.txt 15 * GNU General Public License v3 16 */ 1 17 package eu.clarin.sru.client; 2 18 … … 6 22 import javax.xml.stream.XMLStreamReader; 7 23 24 25 /** 26 * Receive notifications to the response of a <em>scan</em> request. 27 * 28 * @see SRUScanRequest 29 * @see <a href="http://www.loc.gov/standards/sru/specs/scan.html">SRU 30 * Scan Operation</a> 31 */ 8 32 public interface SRUScanHandler { 33 /** 34 * A flag to indicate the position of the term within the complete term 35 * list. 36 */ 9 37 public enum WhereInList { 10 FIRST, LAST, ONLY, INNER; 38 /** 39 * The first term (<em>first</em>) 40 */ 41 FIRST, 42 43 /** 44 * The last term (<em>last</em>) 45 */ 46 LAST, 47 48 /** 49 * The only term (<em>only</em>) 50 */ 51 ONLY, 52 53 /** 54 * Any other term (<em>inner</em>) 55 */ 56 INNER; 11 57 } 12 58 59 60 /** 61 * Receive notification of diagnostics. 62 * 63 * @param diagnostics 64 * a list of {@link SRUDiagnostic} 65 * @throws SRUClientException 66 * any SRU exception, possibly wrapping another exception 67 * @see SRUDiagnostic 68 */ 13 69 public void onDiagnostics(List<SRUDiagnostic> diagnostics) 14 70 throws SRUClientException; 15 71 72 73 /** 74 * Receive notification of request statistics. 75 * 76 * @param bytes 77 * the size of the response in bytes 78 * @param millisTotal 79 * the total time spend processing the request 80 * @param millisNetwork 81 * the time spend performing network operations 82 * @param millisParsing 83 * the time spend parsing the response 84 */ 16 85 public void onRequestStatistics(int bytes, long millisTotal, 17 86 long millisNetwork, long millisParsing); 18 87 88 89 /** 90 * Receive notification of extra response data. 91 * 92 * @param reader 93 * a {@link XMLStreamReader} to parse the extra response data 94 * @throws XMLStreamException 95 * an error occurred while parsing the response 96 * @throws SRUClientException 97 * any SRU exception, possibly wrapping another exception 98 * @see <a href="http://www.loc.gov/standards/sru/specs/extra-data.html">SRU 99 * Extra Data / Extensions</a> 100 */ 19 101 public void onExtraResponseData(XMLStreamReader reader) 20 102 throws XMLStreamException, SRUClientException; 21 103 104 105 /** 106 * Receive notifications of the start of the enumeration of terms in the 107 * response. 108 * 109 * @throws SRUClientException 110 * any SRU exception, possibly wrapping another exception 111 */ 22 112 public void onStartTerms() throws SRUClientException; 23 113 114 115 /** 116 * Receive notifications of the end of the enumeration of terms in the 117 * response. 118 * 119 * @throws SRUClientException 120 * any SRU exception, possibly wrapping another exception 121 */ 24 122 public void onFinishTerms() throws SRUClientException; 25 123 124 125 /** 126 * Receive notification of a term. 127 * 128 * @param value 129 * the term (exactly) as it appears in the index 130 * @param numberOfRecords 131 * the number of records for the current term which would be 132 * matched 133 * @param displayTerm 134 * a string for the current term to display to the end user in 135 * place of the term itself or <code>null</code> if not available 136 * @param whereInList 137 * a flag to indicate the position of the term within the 138 * complete term list or <code>null</code> of not available 139 * @throws SRUClientException 140 * any SRU exception, possibly wrapping another exception 141 */ 26 142 public void onTerm(String value, int numberOfRecords, String displayTerm, 27 143 WhereInList whereInList) throws SRUClientException; 28 144 145 146 /** 147 * Receive notification of extra term data. 148 * 149 * @param value 150 * the term (exactly) as it appears in the index 151 * @param reader 152 * a {@link XMLStreamReader} to parse the extra term data 153 * @throws XMLStreamException 154 * an error occurred while parsing the response 155 * @throws SRUClientException 156 * any SRU exception, possibly wrapping another exception 157 */ 29 158 public void onExtraTermData(String value, XMLStreamReader reader) 30 159 throws XMLStreamException, SRUClientException; -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUScanRequest.java
r2047 r2088 1 /** 2 * This software is copyright (c) 2011 by 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 * This is free software. You can redistribute it 5 * and/or modify it under the terms described in 6 * the GNU General Public License v3 of which you 7 * should have received a copy. Otherwise you can download 8 * it from 9 * 10 * http://www.gnu.org/licenses/gpl-3.0.txt 11 * 12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 13 * 14 * @license http://www.gnu.org/licenses/gpl-3.0.txt 15 * GNU General Public License v3 16 */ 1 17 package eu.clarin.sru.client; 2 18 19 /** 20 * An object for performing a <em>explain</em> operation. 21 * <p>The following argument arguments are mandatory:</p> 22 * <ul> 23 * <li><em>scanClause</em></li> 24 * </ul> 25 * 26 * @see SRUScanHandler 27 * @see <a href="http://www.loc.gov/standards/sru/specs/scan.html">SRU Scan 28 * Operation</a> 29 */ 3 30 public final class SRUScanRequest extends SRUAbstractRequest { 4 31 private String scanClause; … … 7 34 8 35 9 protected SRUScanRequest(String baseURI) { 36 /** 37 * Constructor. 38 * 39 * @param baseURI 40 * the baseURI of the endpoint 41 */ 42 public SRUScanRequest(String baseURI) { 10 43 super(baseURI); 11 44 } 12 45 13 46 47 /** 48 * Get the value of the <em>scanClause</em> argument for this request. 49 * 50 * @return the value for the <em>scanClause</em> argument or 51 * <code>null</code> of none was set 52 */ 14 53 public String getScanClause() { 15 54 return scanClause; … … 17 56 18 57 58 /** 59 * Set the value of the <em>scanClause</em> argument for this request. 60 * 61 * @param scanClause 62 * the value for the <em>scanClause</em> argument 63 * @throws NullPointerException 64 * if any required argument is <code>null</code> 65 * @throws IllegalArgumentException 66 * if any argument is invalid 67 */ 19 68 public void setScanClause(String scanClause) { 20 69 if (scanClause == null) { … … 28 77 29 78 79 /** 80 * Get the value of the <em>responsePosition</em> argument for this request. 81 * 82 * @return the value for the <em>responsePosition</em> argument 83 */ 30 84 public int getResponsePosition() { 31 85 return responsePosition; … … 33 87 34 88 89 /** 90 * Set the value of the <em>responsePosition</em> argument for this request. 91 * 92 * @param responsePosition 93 * the value for the <em>responsePosition</em> argument 94 * @throws IllegalArgumentException 95 * if any argument is invalid 96 */ 35 97 public void setResponsePosition(int responsePosition) { 36 98 if (responsePosition < 0) { … … 41 103 42 104 105 /** 106 * Get the value of the <em>maximumTerms</em> argument for this request. 107 * 108 * @return the value for the <em>maximumTerms</em> argument 109 */ 43 110 public int getMaximumTerms() { 44 111 return maximumTerms; … … 46 113 47 114 115 /** 116 * Set the value of the <em>maximumTerms</em> argument for this request. 117 * 118 * @param maximumTerms 119 * the value for the <em>maximumTerms</em> argument 120 * @throws IllegalArgumentException 121 * if any argument is invalid 122 */ 48 123 public void setMaximumTerms(int maximumTerms) { 49 124 if (maximumTerms < 0) { … … 55 130 56 131 @Override 57 protectedSRUOperation getOperation() {132 SRUOperation getOperation() { 58 133 return SRUOperation.SCAN; 59 134 } … … 61 136 62 137 @Override 63 protected void addParametersToURI(URIBuilder uriBuilder) 64 throws SRUClientException { 138 void addParametersToURI(URIBuilder uriBuilder) throws SRUClientException { 65 139 // scanClause 66 140 if ((scanClause == null) || scanClause.isEmpty()) { -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUSearchRetrieveHandler.java
r2083 r2088 1 /** 2 * This software is copyright (c) 2011 by 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 * This is free software. You can redistribute it 5 * and/or modify it under the terms described in 6 * the GNU General Public License v3 of which you 7 * should have received a copy. Otherwise you can download 8 * it from 9 * 10 * http://www.gnu.org/licenses/gpl-3.0.txt 11 * 12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 13 * 14 * @license http://www.gnu.org/licenses/gpl-3.0.txt 15 * GNU General Public License v3 16 */ 1 17 package eu.clarin.sru.client; 2 18 … … 6 22 import javax.xml.stream.XMLStreamReader; 7 23 24 25 /** 26 * Receive notifications to the response of a <em>searchRetrieve</em> request. 27 * 28 * @see SRUSearchRetrieveRequest 29 * @see <a href="http://www.loc.gov/standards/sru/specs/search-retrieve.html"> 30 * SRU SearchRetrieve Operation</a> 31 */ 8 32 public interface SRUSearchRetrieveHandler { 9 33 34 /** 35 * Receive notification of diagnostics. 36 * 37 * @param diagnostics 38 * a list of {@link SRUDiagnostic} 39 * @throws SRUClientException 40 * any SRU exception, possibly wrapping another exception 41 * @see SRUDiagnostic 42 */ 10 43 public void onDiagnostics(List<SRUDiagnostic> diagnostics) 11 44 throws SRUClientException; 12 45 46 47 /** 48 * Receive notification of request statistics. 49 * 50 * @param bytes 51 * the size of the response in bytes 52 * @param millisTotal 53 * the total time spend processing the request 54 * @param millisNetwork 55 * the time spend performing network operations 56 * @param millisParsing 57 * the time spend parsing the response 58 */ 13 59 public void onRequestStatistics(int bytes, long millisTotal, 14 60 long millisNetwork, long millisParsing); 15 61 62 63 /** 64 * Receive notification of extra response data. 65 * 66 * @param reader 67 * a {@link XMLStreamReader} to parse the extra response data 68 * @throws XMLStreamException 69 * an error occurred while parsing the response 70 * @throws SRUClientException 71 * any SRU exception, possibly wrapping another exception 72 * @see <a href="http://www.loc.gov/standards/sru/specs/extra-data.html">SRU 73 * Extra Data / Extensions</a> 74 */ 16 75 public void onExtraResponseData(XMLStreamReader reader) 17 76 throws XMLStreamException, SRUClientException; 18 77 78 79 /** 80 * Receive notifications of the start of the enumeration of records in the 81 * response. 82 * 83 * @param numberOfRecords 84 * the number of records or <code>-1</code> if not available 85 * @param resultSetId 86 * the result set id or <code>-1</code> if not available 87 * @param resultSetIdleTime 88 * the result set idle time or <code>-1</code> if not available 89 * @throws SRUClientException 90 * any SRU exception, possibly wrapping another exception 91 */ 19 92 public void onStartRecords(int numberOfRecords, int resultSetId, 20 93 int resultSetIdleTime) throws SRUClientException; 21 94 95 96 /** 97 * Receive notifications of the end of the enumeration of records in the 98 * response. 99 * 100 * @param nextRecordPosition 101 * the next record position or <code>-1</code> if not available 102 * @throws SRUClientException 103 * any SRU exception, possibly wrapping another exception 104 */ 22 105 public void onFinishRecords(int nextRecordPosition) 23 106 throws SRUClientException; 24 107 108 109 /** 110 * Receive notification of a record in the result set. 111 * 112 * @param identifier 113 * identifier of the record or <code>null</code> if not available 114 * @param position 115 * position of the record in the result set ot <code>-1</code> if 116 * not available 117 * @param data 118 * the parsed record data 119 * @throws SRUClientException 120 * any SRU exception, possibly wrapping another exception 121 * @see SRURecordData 122 * @see SRURecordDataParser 123 */ 25 124 public void onRecord(String identifier, int position, SRURecordData data) 26 125 throws SRUClientException; 27 126 127 128 /** 129 * Receive notification of a surrogate record in the result set. 130 * 131 * @param identifier 132 * identifier of the record or <code>null</code> if not available 133 * @param position 134 * position of the record in the result set ot <code>-1</code> if 135 * not available 136 * @param data 137 * the surrogate record data, i.e. a diagnostic 138 * @throws SRUClientException 139 * any SRU exception, possibly wrapping another exception 140 * @see SRUDiagnostic 141 */ 28 142 public void onSurrogateRecord(String identifier, int position, 29 143 SRUDiagnostic data) throws SRUClientException; 30 144 145 146 /** 147 * Receive notification of extra record data. 148 * 149 * @param identifier 150 * identifier of the record or <code>null</code> if not available 151 * @param position 152 * position of the record in the result set ot <code>-1</code> if 153 * not available 154 * @param reader 155 * a {@link XMLStreamReader} to parse the extra term data 156 * @throws XMLStreamException 157 * an error occurred while parsing the response 158 * @throws SRUClientException 159 * any SRU exception, possibly wrapping another exception 160 */ 31 161 public void onExtraRecordData(String identifier, int position, 32 162 XMLStreamReader reader) throws XMLStreamException, -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUSearchRetrieveRequest.java
r2047 r2088 1 /** 2 * This software is copyright (c) 2011 by 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 * This is free software. You can redistribute it 5 * and/or modify it under the terms described in 6 * the GNU General Public License v3 of which you 7 * should have received a copy. Otherwise you can download 8 * it from 9 * 10 * http://www.gnu.org/licenses/gpl-3.0.txt 11 * 12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 13 * 14 * @license http://www.gnu.org/licenses/gpl-3.0.txt 15 * GNU General Public License v3 16 */ 1 17 package eu.clarin.sru.client; 2 18 19 /** 20 * An object for performing a <em>explain</em> operation. 21 * <p> 22 * The following argument arguments are mandatory: 23 * </p> 24 * <ul> 25 * <li><em>query</em></li> 26 * </ul> 27 * 28 * @see SRUSearchRetrieveHandler 29 * @see <a href="http://www.loc.gov/standards/sru/specs/search-retrieve.html"> 30 * SRU SearchRetrieve Operation</a> 31 */ 3 32 public final class SRUSearchRetrieveRequest extends SRUAbstractRequest { 4 33 private String query; … … 10 39 11 40 12 protected SRUSearchRetrieveRequest(String baseURI) { 41 /** 42 * Constructor. 43 * 44 * @param baseURI 45 * the baseURI of the endpoint 46 */ 47 public SRUSearchRetrieveRequest(String baseURI) { 13 48 super(baseURI); 14 49 } 15 50 16 51 52 /** 53 * Get the value of the <em>query</em> argument for this request. 54 * 55 * @return the value for the <em>query</em> argument or <code>null</code> of 56 * none was set 57 */ 17 58 public String getQuery() { 18 59 return query; … … 20 61 21 62 63 /** 64 * Set the value of the <em>query</em> argument for this request. 65 * 66 * @param query 67 * the value for the <em>query</em> argument 68 * @throws NullPointerException 69 * if any required argument is <code>null</code> 70 * @throws IllegalArgumentException 71 * if any argument is invalid 72 */ 22 73 public void setQuery(String query) { 23 74 if (query == null) { … … 31 82 32 83 84 /** 85 * Get the value of the <em>startRecord</em> argument for this request. 86 * 87 * @return the value for the <em>startRecord</em> argument or 88 * <code>-1</code> of none was set 89 */ 33 90 public int getStartRecord() { 34 91 return startRecord; … … 36 93 37 94 95 /** 96 * Set the value of the <em>startRecord</em> argument for this request. 97 * 98 * @param startRecord 99 * the value for the <em>startRecord</em> argument 100 * @throws IllegalArgumentException 101 * if any argument is invalid 102 */ 38 103 public void setStartRecord(int startRecord) { 39 104 if (startRecord < 1) { … … 44 109 45 110 111 /** 112 * Get the value of the <em>maximumRecords</em> argument for this request. 113 * 114 * @return the value for the <em>maximumRecords</em> argument or 115 * <code>-1</code> of none was set 116 */ 46 117 public int getMaximumRecords() { 47 118 return maximumRecords; … … 49 120 50 121 122 /** 123 * Set the value of the <em>maximumRecords</em> argument for this request. 124 * 125 * @param maximumRecords 126 * the value for the <em>maximumRecords</em> argument 127 * @throws IllegalArgumentException 128 * if any argument is invalid 129 */ 51 130 public void setMaximumRecords(int maximumRecords) { 52 131 if (maximumRecords < 0) { … … 57 136 58 137 138 /** 139 * Get the value of the <em>recordSchema</em> argument for this request. 140 * 141 * @return the value for the <em>recordSchema</em> argument or 142 * <code>null</code> of none was set 143 */ 59 144 public String getRecordSchema() { 60 145 return recordSchema; … … 62 147 63 148 149 /** 150 * Set the value of the <em>recordSchema</em> argument for this request. 151 * 152 * @param recordSchema 153 * the value for the <em>recordSchema</em> argument 154 * @throws NullPointerException 155 * if any required argument is <code>null</code> 156 * @throws IllegalArgumentException 157 * if any argument is invalid 158 */ 64 159 public void setRecordSchema(String recordSchema) { 65 160 this.recordSchema = recordSchema; … … 67 162 68 163 164 /** 165 * Get the value of the <em>recordSchema</em> argument for this request. 166 * 167 * @return the value for the <em>recordSchema</em> argument or 168 * <code>null</code> of none was set 169 */ 170 public SRURecordPacking getRecordPacking() { 171 return recordPacking; 172 } 173 174 175 /** 176 * Set the value of the <em>recordPacking</em> argument for this request. 177 * 178 * @param recordPacking 179 * the value for the <em>recordPacking</em> argument 180 * @throws NullPointerException 181 * if any required argument is <code>null</code> 182 */ 69 183 public void setRecordPacking(SRURecordPacking recordPacking) { 70 184 if (recordPacking == null) { … … 75 189 76 190 77 public SRURecordPacking getRecordPacking() { 78 return recordPacking; 79 } 80 81 191 /** 192 * Get the value of the <em>resultSetTTL</em> argument for this request. 193 * 194 * @return the value for the <em>resultSetTTL</em> argument or 195 * <code>-1</code> of none was set 196 */ 82 197 public int getResultSetTTL() { 83 198 return resultSetTTL; … … 85 200 86 201 202 /** 203 * Set the value of the <em>resultSetTTL</em> argument for this request. 204 * 205 * @param resultSetTTL 206 * the value for the <em>resultSetTTL</em> argument 207 * @throws IllegalArgumentException 208 * if any argument is invalid 209 */ 87 210 public void setResultSetTTL(int resultSetTTL) { 88 211 this.resultSetTTL = resultSetTTL; … … 91 214 92 215 @Override 93 protectedSRUOperation getOperation() {216 SRUOperation getOperation() { 94 217 return SRUOperation.SEARCH_RETRIEVE; 95 218 } … … 97 220 98 221 @Override 99 protected void addParametersToURI(URIBuilder uriBuilder) 100 throws SRUClientException { 222 void addParametersToURI(URIBuilder uriBuilder) throws SRUClientException { 101 223 // query 102 224 if ((query == null) || query.isEmpty()) { -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUVersion.java
r1963 r2088 1 1 package eu.clarin.sru.client; 2 2 3 /** 4 * SRU version 5 */ 3 6 public enum SRUVersion { 7 /** 8 * SRU/CQL version 1.1 9 */ 4 10 VERSION_1_1, 5 VERSION_1_2 11 12 /** 13 * SRU/CQL version 1.2 14 */ 15 VERSION_1_2; 6 16 } // enum SRUVersion -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUXMLStreamReader.java
r2024 r2088 1 /** 2 * This software is copyright (c) 2011 by 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 * This is free software. You can redistribute it 5 * and/or modify it under the terms described in 6 * the GNU General Public License v3 of which you 7 * should have received a copy. Otherwise you can download 8 * it from 9 * 10 * http://www.gnu.org/licenses/gpl-3.0.txt 11 * 12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 13 * 14 * @license http://www.gnu.org/licenses/gpl-3.0.txt 15 * GNU General Public License v3 16 */ 1 17 package eu.clarin.sru.client; 2 18 -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/TestClient.java
r2083 r2088 1 /** 2 * This software is copyright (c) 2011 by 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 * This is free software. You can redistribute it 5 * and/or modify it under the terms described in 6 * the GNU General Public License v3 of which you 7 * should have received a copy. Otherwise you can download 8 * it from 9 * 10 * http://www.gnu.org/licenses/gpl-3.0.txt 11 * 12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 13 * 14 * @license http://www.gnu.org/licenses/gpl-3.0.txt 15 * GNU General Public License v3 16 */ 1 17 package eu.clarin.sru.client; 2 18 … … 25 41 } 26 42 43 /* 44 * just use one dump handler for each request. 45 * A real application should be smarter here and use the 46 * appropriate handler 47 */ 27 48 SRUDefaultHandlerAdapter handler = new SRUDefaultHandlerAdapter() { 28 49 @Override -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/XmlStreamReaderProxy.java
r1963 r2088 1 /** 2 * This software is copyright (c) 2011 by 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 * This is free software. You can redistribute it 5 * and/or modify it under the terms described in 6 * the GNU General Public License v3 of which you 7 * should have received a copy. Otherwise you can download 8 * it from 9 * 10 * http://www.gnu.org/licenses/gpl-3.0.txt 11 * 12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 13 * 14 * @license http://www.gnu.org/licenses/gpl-3.0.txt 15 * GNU General Public License v3 16 */ 1 17 package eu.clarin.sru.client; 2 18 -
SRUClient/trunk/src/main/java/eu/clarin/sru/client/XmlStreamReaderUtils.java
r1969 r2088 1 /** 2 * This software is copyright (c) 2011 by 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 * This is free software. You can redistribute it 5 * and/or modify it under the terms described in 6 * the GNU General Public License v3 of which you 7 * should have received a copy. Otherwise you can download 8 * it from 9 * 10 * http://www.gnu.org/licenses/gpl-3.0.txt 11 * 12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 13 * 14 * @license http://www.gnu.org/licenses/gpl-3.0.txt 15 * GNU General Public License v3 16 */ 1 17 package eu.clarin.sru.client; 2 18 … … 5 21 import javax.xml.stream.XMLStreamReader; 6 22 23 24 /** 25 * Helper class for dealing with {@link XMLStreamReader}. 26 * <p> 27 * <em>Note: this class is semi-public API and may be change or removed in the future.</em> 28 * </p> 29 */ 7 30 public final class XmlStreamReaderUtils { 8 31 private XmlStreamReaderUtils() { -
SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/ClarinFederatedContentSearchRecordData.java
r1969 r2088 1 /** 2 * This software is copyright (c) 2011 by 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 * This is free software. You can redistribute it 5 * and/or modify it under the terms described in 6 * the GNU General Public License v3 of which you 7 * should have received a copy. Otherwise you can download 8 * it from 9 * 10 * http://www.gnu.org/licenses/gpl-3.0.txt 11 * 12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 13 * 14 * @license http://www.gnu.org/licenses/gpl-3.0.txt 15 * GNU General Public License v3 16 */ 1 17 package eu.clarin.sru.fcs; 2 18 3 19 import eu.clarin.sru.client.SRURecordData; 4 20 21 22 /** 23 * A record parse to parse records conforming to CLARIN FCS specification. The 24 * parser currently supports the KWIC view. 25 */ 5 26 public final class ClarinFederatedContentSearchRecordData implements 6 27 SRURecordData { … … 10 31 private String right; 11 32 33 12 34 ClarinFederatedContentSearchRecordData(String pid, String left, 13 35 String keyword, String right) { 14 this.pid 15 this.left 16 this.keyword 36 this.pid = pid; 37 this.left = left; 38 this.keyword = keyword; 17 39 this.right = right; 18 40 } 41 19 42 20 43 @Override … … 23 46 } 24 47 48 25 49 @Override 26 50 public String getRecordSchema() { 27 51 return ClarinFederatedContentSearchRecordParser.FCS_NS; 28 52 } 29 53 54 30 55 public String getPid() { 31 56 return pid; 32 57 } 33 58 59 34 60 public String getLeft() { 35 61 return left; 36 62 } 37 63 64 38 65 public String getKeyword() { 39 66 return keyword; 40 67 } 41 68 69 42 70 public String getRight() { 43 71 return right; 44 72 } 45 73 46 74 } // class ClarinFederatedContentSearchRecordData -
SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/ClarinFederatedContentSearchRecordParser.java
r1977 r2088 1 /** 2 * This software is copyright (c) 2011 by 3 * - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 4 * This is free software. You can redistribute it 5 * and/or modify it under the terms described in 6 * the GNU General Public License v3 of which you 7 * should have received a copy. Otherwise you can download 8 * it from 9 * 10 * http://www.gnu.org/licenses/gpl-3.0.txt 11 * 12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) 13 * 14 * @license http://www.gnu.org/licenses/gpl-3.0.txt 15 * GNU General Public License v3 16 */ 1 17 package eu.clarin.sru.fcs; 2 18 … … 12 28 import eu.clarin.sru.client.XmlStreamReaderUtils; 13 29 30 31 /** 32 * A record for CLARIN FCS. 33 */ 14 34 public class ClarinFederatedContentSearchRecordParser implements 15 35 SRURecordDataParser { … … 21 41 private static final String DATAVIEW_KWIC = "kwic"; 22 42 23 43 24 44 @Override 25 45 public String getRecordSchema() { … … 27 47 } 28 48 29 49 30 50 @Override 31 51 public SRURecordData parse(XMLStreamReader reader) 32 52 throws XMLStreamException, SRUClientException { 33 53 XmlStreamReaderUtils.readStart(reader, FCS_NS, "Resource", true, true); 34 String pid = XmlStreamReaderUtils.readAttributeValue(reader, null, "pid"); 54 String pid = XmlStreamReaderUtils.readAttributeValue(reader, null, 55 "pid"); 35 56 XmlStreamReaderUtils.consumeStart(reader); 36 37 String left 57 58 String left = null; 38 59 String keyword = null; 39 String right 60 String right = null; 40 61 41 62 boolean first = true; 42 63 boolean kwic = false; 43 44 while (XmlStreamReaderUtils.readStart(reader, FCS_NS, "DataView", first, true)) { 64 65 while (XmlStreamReaderUtils.readStart(reader, FCS_NS, "DataView", 66 first, true)) { 45 67 first = false; 46 String type = XmlStreamReaderUtils.readAttributeValue(reader, null, "type"); 68 String type = XmlStreamReaderUtils.readAttributeValue(reader, null, 69 "type"); 47 70 XmlStreamReaderUtils.consumeStart(reader); 48 71 if ((type == null) || type.isEmpty()) { … … 53 76 if (DATAVIEW_KWIC.equals(type)) { 54 77 if (kwic) { 55 throw new SRUClientException("only one KWIC dataview is allowed"); 78 throw new SRUClientException( 79 "only one KWIC dataview is allowed"); 56 80 } 57 XmlStreamReaderUtils.readStart(reader, FCS_KWIC_NS, "kwic", true); 58 if (XmlStreamReaderUtils.readStart(reader, FCS_KWIC_NS, "c", false)) { 81 XmlStreamReaderUtils.readStart(reader, FCS_KWIC_NS, "kwic", 82 true); 83 if (XmlStreamReaderUtils.readStart(reader, FCS_KWIC_NS, "c", 84 false)) { 59 85 left = XmlStreamReaderUtils.readString(reader, false); 60 86 XmlStreamReaderUtils.readEnd(reader, FCS_KWIC_NS, "c"); 61 87 } 62 keyword = XmlStreamReaderUtils.readContent(reader, FCS_KWIC_NS, "kw", true); 63 if (XmlStreamReaderUtils.readStart(reader, FCS_KWIC_NS, "c", false)) { 88 keyword = XmlStreamReaderUtils.readContent(reader, FCS_KWIC_NS, 89 "kw", true); 90 if (XmlStreamReaderUtils.readStart(reader, FCS_KWIC_NS, "c", 91 false)) { 64 92 right = XmlStreamReaderUtils.readString(reader, false); 65 93 XmlStreamReaderUtils.readEnd(reader, FCS_KWIC_NS, "c");
Note: See TracChangeset
for help on using the changeset viewer.