Changeset 2088


Ignore:
Timestamp:
08/14/12 17:22:03 (12 years ago)
Author:
oschonef
Message:
  • add JavaDocs? to public API
  • fix wrong constructor visibility with *Request classes
  • do a better job in hiding some non-public API
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 */
    117package eu.clarin.sru.client;
    218
     
    622
    723
    8 public abstract 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                = "explain";
    26     private static final String OP_SCAN                   = "scan";
    27     private static final String OP_SEARCH_RETRIEVE        = "searchRetrieve";
    28     private static final String VERSION_1_1               = "1.1";
    29     private static final String VERSION_1_2               = "1.2";
    30     private static final String PARAM_EXTENSION_PREFIX    = "x-";
    31     /** for end-point conformance testing only. never use in production */
    32     public static final String X_MALFORMED_VERSION       =
     24abstract 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     =
    3349            "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   =
    3652            "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 {
    4158        EXPLAIN, SCAN, SEARCH_RETRIEVE
    4259    } // enum SRUOperation
    4360
    44     protected class URIBuilder {
     61   
     62    class URIBuilder {
    4563        private final StringBuilder sb;
    4664        private boolean firstParam = true;
     
    5068        }
    5169
    52 
     70       
    5371        public URIBuilder append(String name, String value) {
    5472            if (name == null) {
     
    7593        }
    7694
    77 
     95       
    7896        public URIBuilder append(String name, int value) {
    7997            return append(name, Integer.toString(value));
     
    85103        }
    86104    } // class
     105    /** The URL of the endpoint. */
    87106    protected final String endpointURI;
     107    /** The version to be sued  for this request. */
    88108    protected SRUVersion version;
     109    /** A map of extra request data parameters. */
    89110    protected Map<String, String> extraRequestData;
    90111    private SRUVersion versionPreformed;
     
    99120
    100121
     122    /**
     123     * Get the endpoint URI.
     124     *
     125     * @return the endpoiunt URI
     126     */
    101127    public String getEndpointURI() {
    102128        return endpointURI;
     
    104130
    105131
     132    /**
     133     * Set the version for this request.
     134     *
     135     * @param version a version of <code>null</code> for client default
     136     */
    106137    public void setVersion(SRUVersion version) {
    107138        this.version = version;
     
    109140
    110141
     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     */
    111148    public SRUVersion getVersion() {
    112149        return version;
     
    114151
    115152
    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     */
    121167    public void setExtraRequestData(String name, String value) {
    122168        if (name == null) {
     
    143189
    144190
     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     */
    145205    public String getExtraRequestData(String name) {
    146206        if (name == null) {
     
    150210            throw new IllegalArgumentException("name is an empty string");
    151211        }
    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 + "'");
    154215        }
    155216        if (extraRequestData != null) {
     
    160221
    161222
     223    final SRUVersion getVersionPerformed() {
     224        return versionPreformed;
     225    }
     226
     227   
    162228    final URI makeURI(SRUVersion defaultVersion)
    163229            throws SRUClientException {
     
    246312
    247313
    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;
    253322
    254323} // 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 */
    117package eu.clarin.sru.client;
    218
     
    3147import eu.clarin.sru.client.SRUScanHandler.WhereInList;
    3248
    33 
     49/**
     50 * A class to perform SRU operations.
     51 * <p><em>This class is not thread-safe!</em></p>
     52 */
    3453public class SRUClient {
    3554    private static final String SRU_NS =
     
    5271
    5372
     73    /**
     74     * Constructor.
     75     *
     76     * @param defaultVersion
     77     *            the default version to use for SRU requests; may be overridden
     78     *            by individual requests
     79     */
    5480    public SRUClient(SRUVersion defaultVersion) {
    5581        if (defaultVersion == null) {
     
    6389
    6490
     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     */
    65104    public void registerRecordParser(SRURecordDataParser parser)
    66105            throws SRUClientException {
     
    85124
    86125
     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     */
    87141    public void explain(SRUExplainRequest request, SRUExplainHandler handler)
    88142            throws SRUClientException {
     
    151205
    152206
     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     */
    153222    public void scan(SRUScanRequest request, SRUScanHandler handler)
    154223            throws SRUClientException {
     
    217286
    218287
     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     */
    219303    public void searchRetrieve(SRUSearchRetrieveRequest request,
    220304            SRUSearchRetrieveHandler handler) throws SRUClientException {
     
    611695                        SRURecordPacking packing = parseRecordPacking(reader);
    612696
    613                         logger.debug("schema = {}, packing = {}, requested packing = {}",
     697                        logger.debug("schema = {}, packing = {}, " +
     698                                "requested packing = {}",
    614699                                new Object[] { schema, packing,
    615700                                        request.getRecordPacking() });
     
    617702                        if ((request.getRecordPacking() != null) &&
    618703                                (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());
    623710                            // 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() +
    630716                                            "' record packing");
    631717                        }
     
    664750                                    throw new SRUClientException(
    665751                                            "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.");
    666758                                }
    667759                            } 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 */
    117package eu.clarin.sru.client;
    218
     19/**
     20 * SRU client exception.
     21 */
    322@SuppressWarnings("serial")
    423public class SRUClientException extends Exception {
    524
     25    /**
     26     * Constructor
     27     *
     28     * @param message an error message
     29     */
    630    public SRUClientException(String message) {
    731        super(message);
     
    933
    1034
    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);
    1343    }
     44
    1445} // 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 */
    117package eu.clarin.sru.client;
    218
     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 */
    336public interface SRUDefaultHandler extends SRUExplainHandler, SRUScanHandler,
    437        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 */
    117package eu.clarin.sru.client;
    218
     
    622import javax.xml.stream.XMLStreamReader;
    723
     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 */
    847public class SRUDefaultHandlerAdapter implements SRUDefaultHandler {
    948   
  • 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 */
    117package eu.clarin.sru.client;
    218
     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 */
    328public final class SRUDiagnostic {
    429    private final String uri;
     
    732
    833
     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     */
    946    public SRUDiagnostic(String uri, String details, String message) {
    10         this.uri     = uri;
     47        this.uri = uri;
    1148        this.details = details;
    1249        this.message = message;
     
    1451
    1552
     53    /**
     54     * Get diagnostic's identifying URI.
     55     *
     56     * @return diagnostic code
     57     */
    1658    public String getURI() {
    1759        return uri;
     
    1961
    2062
     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     */
    2169    public String getDetails() {
    2270        return details;
     
    2472
    2573
     74    /**
     75     * Get human readable message.
     76     *
     77     * @return human readable message
     78     */
    2679    public String getMessage() {
    2780        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 */
    117package eu.clarin.sru.client;
    218
     
    622import javax.xml.stream.XMLStreamReader;
    723
     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 */
    831public interface SRUExplainHandler {
    932
     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     */
    1042    public void onDiagnostics(List<SRUDiagnostic> diagnostics)
    1143            throws SRUClientException;
    1244
     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     */
    1358    public void onRequestStatistics(int bytes, long millisTotal,
    1459            long millisNetwork, long millisParsing);
    1560
     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     */
    1674    public void onExtraResponseData(XMLStreamReader reader)
    1775            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 */
    117package eu.clarin.sru.client;
    218
     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 */
    325public final class SRUExplainRequest extends SRUAbstractRequest {
    426    private SRURecordPacking recordPacking;
    527
    628
    7     protected SRUExplainRequest(String baseURI) {
     29    /**
     30     * Constructor.
     31     *
     32     * @param baseURI
     33     *            the baseURI of the endpoint
     34     */
     35    public SRUExplainRequest(String baseURI) {
    836        super(baseURI);
    937    }
    1038
    1139
     40    /**
     41     * Set the requested record packing.
     42     *
     43     * @param recordPacking
     44     *            the requested record packing
     45     * @see SRURecordPacking
     46     */
    1247    public void setRecordPacking(SRURecordPacking recordPacking) {
    1348        if (recordPacking == null) {
     
    1853
    1954
     55    /**
     56     * Get the requested record packing.
     57     *
     58     * @return the requested record packing
     59     * @see SRURecordPacking
     60     */
    2061    public SRURecordPacking getRecordPacking() {
    2162        return recordPacking;
     
    2465
    2566    @Override
    26     protected SRUOperation getOperation() {
     67    SRUOperation getOperation() {
    2768        return SRUOperation.EXPLAIN;
    2869    }
     
    3071
    3172    @Override
    32     protected void addParametersToURI(URIBuilder uriBuilder)
    33             throws SRUClientException {
     73    void addParametersToURI(URIBuilder uriBuilder) throws SRUClientException {
    3474        // recordPacking
    3575        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 */
    117package eu.clarin.sru.client;
    218
     19/**
     20 * Interface for parsed record data.
     21 *
     22 */
    323public interface SRURecordData {
    424
     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     */
    532    public boolean isTransient();
    633
     34
     35    /**
     36     * The record schema for this record.
     37     *
     38     * @return the record schema
     39     */
    740    public String getRecordSchema();
    841
  • 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 */
    117package eu.clarin.sru.client;
    218
     
    420import javax.xml.stream.XMLStreamReader;
    521
     22
     23/**
     24 * A parser to parse record data and create appropriate Java objects.
     25 *
     26 */
    627public interface SRURecordDataParser {
    728
     29    /**
     30     * The record schema this parser is able to process.
     31     *
     32     * @return the record schema this parser is able to process
     33     */
    834    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     */
    1049    public SRURecordData parse(XMLStreamReader reader)
    1150            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 */
    117package eu.clarin.sru.client;
    218
     19/**
     20 * SRU Record packing
     21 */
    322public enum SRURecordPacking {
    4     XML, STRING;
     23    /**
     24     * XML record packing
     25     */
     26    XML {
     27        @Override
     28        String getStringValue() {
     29            return "xml";
     30        }
     31    },
    532
    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() {
    1139            return "string";
    12         default:
    13             return null;
    1440        }
    15     }
     41    };
     42
     43    abstract String getStringValue();
    1644
    1745} // 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 */
    117package eu.clarin.sru.client;
    218
     
    622import javax.xml.stream.XMLStreamReader;
    723
     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 */
    832public interface SRUScanHandler {
     33    /**
     34     * A flag to indicate the position of the term within the complete term
     35     * list.
     36     */
    937    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;
    1157    }
    1258
     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     */
    1369    public void onDiagnostics(List<SRUDiagnostic> diagnostics)
    1470            throws SRUClientException;
    1571
     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     */
    1685    public void onRequestStatistics(int bytes, long millisTotal,
    1786            long millisNetwork, long millisParsing);
    1887
     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     */
    19101    public void onExtraResponseData(XMLStreamReader reader)
    20102            throws XMLStreamException, SRUClientException;
    21103
     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     */
    22112    public void onStartTerms() throws SRUClientException;
    23113
     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     */
    24122    public void onFinishTerms() throws SRUClientException;
    25123
     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     */
    26142    public void onTerm(String value, int numberOfRecords, String displayTerm,
    27143            WhereInList whereInList) throws SRUClientException;
    28144
     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     */
    29158    public void onExtraTermData(String value, XMLStreamReader reader)
    30159            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 */
    117package eu.clarin.sru.client;
    218
     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 */
    330public final class SRUScanRequest extends SRUAbstractRequest {
    431    private String scanClause;
     
    734
    835
    9     protected SRUScanRequest(String baseURI) {
     36    /**
     37     * Constructor.
     38     *
     39     * @param baseURI
     40     *            the baseURI of the endpoint
     41     */
     42    public SRUScanRequest(String baseURI) {
    1043        super(baseURI);
    1144    }
    1245
    1346
     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     */
    1453    public String getScanClause() {
    1554        return scanClause;
     
    1756
    1857
     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     */
    1968    public void setScanClause(String scanClause) {
    2069        if (scanClause == null) {
     
    2877
    2978
     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     */
    3084    public int getResponsePosition() {
    3185        return responsePosition;
     
    3387
    3488
     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     */
    3597    public void setResponsePosition(int responsePosition) {
    3698        if (responsePosition < 0) {
     
    41103
    42104
     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     */
    43110    public int getMaximumTerms() {
    44111        return maximumTerms;
     
    46113
    47114
     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     */
    48123    public void setMaximumTerms(int maximumTerms) {
    49124        if (maximumTerms < 0) {
     
    55130
    56131    @Override
    57     protected SRUOperation getOperation() {
     132    SRUOperation getOperation() {
    58133        return SRUOperation.SCAN;
    59134    }
     
    61136
    62137    @Override
    63     protected void addParametersToURI(URIBuilder uriBuilder)
    64             throws SRUClientException {
     138    void addParametersToURI(URIBuilder uriBuilder) throws SRUClientException {
    65139        // scanClause
    66140        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 */
    117package eu.clarin.sru.client;
    218
     
    622import javax.xml.stream.XMLStreamReader;
    723
     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 */
    832public interface SRUSearchRetrieveHandler {
    933
     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     */
    1043    public void onDiagnostics(List<SRUDiagnostic> diagnostics)
    1144            throws SRUClientException;
    1245
     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     */
    1359    public void onRequestStatistics(int bytes, long millisTotal,
    1460            long millisNetwork, long millisParsing);
    1561
     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     */
    1675    public void onExtraResponseData(XMLStreamReader reader)
    1776            throws XMLStreamException, SRUClientException;
    1877
     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     */
    1992    public void onStartRecords(int numberOfRecords, int resultSetId,
    2093            int resultSetIdleTime) throws SRUClientException;
    2194
     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     */
    22105    public void onFinishRecords(int nextRecordPosition)
    23106            throws SRUClientException;
    24107
     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     */
    25124    public void onRecord(String identifier, int position, SRURecordData data)
    26125            throws SRUClientException;
    27126
     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     */
    28142    public void onSurrogateRecord(String identifier, int position,
    29143            SRUDiagnostic data) throws SRUClientException;
    30144
     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     */
    31161    public void onExtraRecordData(String identifier, int position,
    32162            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 */
    117package eu.clarin.sru.client;
    218
     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 */
    332public final class SRUSearchRetrieveRequest extends SRUAbstractRequest {
    433    private String query;
     
    1039
    1140
    12     protected SRUSearchRetrieveRequest(String baseURI) {
     41    /**
     42     * Constructor.
     43     *
     44     * @param baseURI
     45     *            the baseURI of the endpoint
     46     */
     47    public SRUSearchRetrieveRequest(String baseURI) {
    1348        super(baseURI);
    1449    }
    1550
    1651
     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     */
    1758    public String getQuery() {
    1859        return query;
     
    2061
    2162
     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     */
    2273    public void setQuery(String query) {
    2374        if (query == null) {
     
    3182
    3283
     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     */
    3390    public int getStartRecord() {
    3491        return startRecord;
     
    3693
    3794
     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     */
    38103    public void setStartRecord(int startRecord) {
    39104        if (startRecord < 1) {
     
    44109
    45110
     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     */
    46117    public int getMaximumRecords() {
    47118        return maximumRecords;
     
    49120
    50121
     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     */
    51130    public void setMaximumRecords(int maximumRecords) {
    52131        if (maximumRecords < 0) {
     
    57136
    58137
     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     */
    59144    public String getRecordSchema() {
    60145        return recordSchema;
     
    62147
    63148
     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     */
    64159    public void setRecordSchema(String recordSchema) {
    65160        this.recordSchema = recordSchema;
     
    67162
    68163
     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     */
    69183    public void setRecordPacking(SRURecordPacking recordPacking) {
    70184        if (recordPacking == null) {
     
    75189
    76190
    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     */
    82197    public int getResultSetTTL() {
    83198        return resultSetTTL;
     
    85200
    86201
     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     */
    87210    public void setResultSetTTL(int resultSetTTL) {
    88211        this.resultSetTTL = resultSetTTL;
     
    91214
    92215    @Override
    93     protected SRUOperation getOperation() {
     216    SRUOperation getOperation() {
    94217        return SRUOperation.SEARCH_RETRIEVE;
    95218    }
     
    97220
    98221    @Override
    99     protected void addParametersToURI(URIBuilder uriBuilder)
    100             throws SRUClientException {
     222    void addParametersToURI(URIBuilder uriBuilder) throws SRUClientException {
    101223        // query
    102224        if ((query == null) || query.isEmpty()) {
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUVersion.java

    r1963 r2088  
    11package eu.clarin.sru.client;
    22
     3/**
     4 * SRU version
     5 */
    36public enum SRUVersion {
     7    /**
     8     * SRU/CQL version 1.1
     9     */
    410    VERSION_1_1,
    5     VERSION_1_2
     11
     12    /**
     13     * SRU/CQL version 1.2
     14     */
     15    VERSION_1_2;
    616} // 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 */
    117package eu.clarin.sru.client;
    218
  • 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 */
    117package eu.clarin.sru.client;
    218
     
    2541            }
    2642
     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             */
    2748            SRUDefaultHandlerAdapter handler = new SRUDefaultHandlerAdapter() {
    2849                @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 */
    117package eu.clarin.sru.client;
    218
  • 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 */
    117package eu.clarin.sru.client;
    218
     
    521import javax.xml.stream.XMLStreamReader;
    622
     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 */
    730public final class XmlStreamReaderUtils {
    831    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 */
    117package eu.clarin.sru.fcs;
    218
    319import eu.clarin.sru.client.SRURecordData;
    420
     21
     22/**
     23 * A record parse to parse records conforming to CLARIN FCS specification. The
     24 * parser currently supports the KWIC view.
     25 */
    526public final class ClarinFederatedContentSearchRecordData implements
    627        SRURecordData {
     
    1031    private String right;
    1132
     33
    1234    ClarinFederatedContentSearchRecordData(String pid, String left,
    1335            String keyword, String right) {
    14         this.pid   = pid;
    15         this.left  = left;
    16         this.keyword   = keyword;
     36        this.pid = pid;
     37        this.left = left;
     38        this.keyword = keyword;
    1739        this.right = right;
    1840    }
     41
    1942
    2043    @Override
     
    2346    }
    2447
     48
    2549    @Override
    2650    public String getRecordSchema() {
    2751        return ClarinFederatedContentSearchRecordParser.FCS_NS;
    2852    }
    29    
     53
     54
    3055    public String getPid() {
    3156        return pid;
    3257    }
    3358
     59
    3460    public String getLeft() {
    3561        return left;
    3662    }
    37    
     63
     64
    3865    public String getKeyword() {
    3966        return keyword;
    4067    }
    41    
     68
     69
    4270    public String getRight() {
    4371        return right;
    4472    }
    45    
     73
    4674} // 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 */
    117package eu.clarin.sru.fcs;
    218
     
    1228import eu.clarin.sru.client.XmlStreamReaderUtils;
    1329
     30
     31/**
     32 * A record for CLARIN FCS.
     33 */
    1434public class ClarinFederatedContentSearchRecordParser implements
    1535        SRURecordDataParser {
     
    2141    private static final String DATAVIEW_KWIC = "kwic";
    2242
    23    
     43
    2444    @Override
    2545    public String getRecordSchema() {
     
    2747    }
    2848
    29    
     49
    3050    @Override
    3151    public SRURecordData parse(XMLStreamReader reader)
    3252            throws XMLStreamException, SRUClientException {
    3353        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");
    3556        XmlStreamReaderUtils.consumeStart(reader);
    36        
    37         String left    = null;
     57
     58        String left = null;
    3859        String keyword = null;
    39         String right   = null;
     60        String right = null;
    4061
    4162        boolean first = true;
    4263        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)) {
    4567            first = false;
    46             String type = XmlStreamReaderUtils.readAttributeValue(reader, null, "type");
     68            String type = XmlStreamReaderUtils.readAttributeValue(reader, null,
     69                    "type");
    4770            XmlStreamReaderUtils.consumeStart(reader);
    4871            if ((type == null) || type.isEmpty()) {
     
    5376            if (DATAVIEW_KWIC.equals(type)) {
    5477                if (kwic) {
    55                     throw new SRUClientException("only one KWIC dataview is allowed");
     78                    throw new SRUClientException(
     79                            "only one KWIC dataview is allowed");
    5680                }
    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)) {
    5985                    left = XmlStreamReaderUtils.readString(reader, false);
    6086                    XmlStreamReaderUtils.readEnd(reader, FCS_KWIC_NS, "c");
    6187                }
    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)) {
    6492                    right = XmlStreamReaderUtils.readString(reader, false);
    6593                    XmlStreamReaderUtils.readEnd(reader, FCS_KWIC_NS, "c");
Note: See TracChangeset for help on using the changeset viewer.