Changeset 6912 for SRUClient


Ignore:
Timestamp:
01/18/16 15:11:20 (8 years ago)
Author:
Oliver Schonefeld
Message:
  • change method setQuery in SRUSearchRetrieveRequest to require a queryType-
  • fix some JavaDoc?
Location:
SRUClient/trunk/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUAbstractRequest.java

    r6903 r6912  
    417417                        break;
    418418                    default:
    419                         throw new SRUClientException("unsupported version: " +
    420                                 versionRequested);
     419                        throw new SRUClientException("internal error: " +
     420                                "unsupported value for version (" +
     421                                versionRequested + ")");
    421422                    } // switch
    422423                } else {
     
    439440                break;
    440441            default:
    441                 throw new SRUClientException("unsupported version: " +
    442                         versionRequested);
     442                throw new SRUClientException("internal error: " +
     443                        "unsupported value for version (" +
     444                        versionRequested + ")");
    443445            }
    444446
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUClient.java

    r5804 r6912  
    8585     *            the configuration to be used for this client.
    8686     * @throws NullPointerException
    87      *             if argument <code>config</code> is <node>null</code>
     87     *             if argument <code>config</code> is <code>null</code>
    8888     * @throws IllegalArgumentException
    8989     *             if an error occurred while registering record data parsers
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUExtraResponseDataParser.java

    r5797 r6912  
    3131     * Check, if the current element can be handled by this parser.
    3232     *
     33     * @param name
     34     *            the name of the element to be examined
     35     *
    3336     * @return <code>true</code> if the element can be handled by this parser;
    3437     *         <code>false</code> otherwise
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUSearchRetrieveRequest.java

    r6903 r6912  
    2020
    2121/**
    22  * An object for performing a <em>explain</em> operation.
     22 * An object for performing a <em>searchRetrieve</em> operation.
    2323 * <p>
    2424 * The following argument arguments are mandatory:
     
    2626 * <ul>
    2727 * <li><em>query</em></li>
     28 * <li><em>queryType</em>, if using query language other than CQL (only SRU 2.0)</li>
    2829 * </ul>
    2930 *
     
    9091
    9192    /**
    92      * (SRU 2.0) Set the value of the <em>queryType</em> argument for this
    93      * request.
     93     * Get the value of the <em>query</em> argument for this request.
     94     *
     95     * @return the value for the <em>query</em> argument or <code>null</code> of
     96     *         none was set
     97     */
     98    public String getQuery() {
     99        return query;
     100    }
     101
     102
     103    /**
     104     * Set the value of the <em>queryType</em> (SRU 2.0) and the <em>query</em>
     105     * argument for this request.
     106     * <p>
     107     * For SRU 1.1 and SRU 1.2 requests use the following:</p>
     108     * <pre>
     109     * {@code
     110     * String cql_query = ...
     111     * SRUSearchRetrieveRequest req =
     112     *      new SRUSearchRetrieveRequest("http://endpoint.example.org");
     113     * req.setQuery(SRUClientConstants.QUERY_TYPE_CQL, cql_query);
     114     * }
     115     * </pre>
    94116     *
    95117     * @param queryType
    96118     *            the value for the <em>queryType</em> argument
     119     * @param query
     120     *            the value for the <em>query</em> argument
    97121     * @throws NullPointerException
    98122     *             if any required argument is <code>null</code>
    99123     * @throws IllegalArgumentException
    100124     *             if any argument is invalid
    101      */
    102     public void setQueryType(String queryType) {
     125     * @see SRUClientConstants#QUERY_TYPE_CQL
     126     */
     127    public void setQuery(String queryType, String query) {
     128        if (query == null) {
     129            throw new NullPointerException("query == null");
     130        }
     131        if (query.isEmpty()) {
     132            throw new IllegalArgumentException("query is an empty string");
     133        }
    103134        if (queryType == null) {
    104135            throw new NullPointerException("queryType == null");
     
    117148            }
    118149        }
     150
    119151        this.queryType = queryType;
    120     }
    121 
    122 
    123     /**
    124      * Get the value of the <em>query</em> argument for this request.
    125      *
    126      * @return the value for the <em>query</em> argument or <code>null</code> of
    127      *         none was set
    128      */
    129     public String getQuery() {
    130         return query;
    131     }
    132 
    133 
    134     /**
    135      * Set the value of the <em>query</em> argument for this request.
    136      *
    137      * @param query
    138      *            the value for the <em>query</em> argument
    139      * @throws NullPointerException
    140      *             if any required argument is <code>null</code>
    141      * @throws IllegalArgumentException
    142      *             if any argument is invalid
    143      */
    144     public void setQuery(String query) {
    145         if (query == null) {
    146             throw new NullPointerException("query == null");
    147         }
    148         if (query.isEmpty()) {
    149             throw new IllegalArgumentException("query is an empty string");
    150         }
    151152        this.query = query;
    152153    }
     
    275276     * Set the <em>recordPacking</em> (SRU 2.0) parameter of this request.
    276277     *
    277      * @param getRecordXmlEscaping
    278      *            the requested record XML escaping
     278     * @param recordPacking
     279     *            the requested recordPacking mode
    279280     * @see SRURecordXmlEscaping
    280281     */
     
    423424                    break;
    424425                default:
    425                     throw new SRUClientException(
    426                             "unsupported record XML escpaing: " + recordXmlEscaping);
     426                    throw new SRUClientException("internal error: invalid " +
     427                            "recordXmlEscaping (" + recordXmlEscaping + ")");
    427428                } // switch
    428429            }
     
    443444         */
    444445        if ((version == SRUVersion.VERSION_2_0) && (recordPacking != null)) {
    445             String s = null;
    446446            switch (recordPacking) {
    447447            case PACKED:
    448                 s = "packed";
     448                uriHelper.append(PARAM_RECORD_PACKING, RECORD_PACKING_PACKED);
    449449                break;
    450450            case UNPACKED:
    451                 s = "unpacked";
     451                uriHelper.append(PARAM_RECORD_PACKING, RECORD_PACKING_UNPACKED);
    452452                break;
    453             }
    454             uriHelper.append(PARAM_RECORD_PACKING, s);
     453            default:
     454                throw new SRUClientException("internal error: invalid value " +
     455                        "for recordPacking (" + recordPacking + ")");
     456            }
    455457        }
    456458
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUSimpleClient.java

    r6903 r6912  
    9898     *            the configuration to be used for this client.
    9999     * @throws NullPointerException
    100      *             if argument <code>config</code> is <node>null</code>
     100     *             if argument <code>config</code> is <code>null</code>
    101101     * @throws IllegalArgumentException
    102102     *             if an error occurred while registering record data parsers
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUThreadedClient.java

    r5750 r6912  
    3434 * <p>
    3535 * This client is reusable and thread-safe: the application may reuse a
    36  * client object and may shared it between multiple threads. <br />
     36 * client object and may shared it between multiple threads.
     37 * </p>
     38 * <p>
    3739 * NB: The registered {@link SRURecordDataParser} need to be thread-safe
    3840 * </p>
     
    5355     *            the configuration to be used for this client.
    5456     * @throws NullPointerException
    55      *             if argument <code>config</code> is <node>null</code>
     57     *             if argument <code>config</code> is <code>null</code>
    5658     * @throws IllegalArgumentException
    5759     *             if an error occurred while registering record data parsers
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/fcs/ClarinFCSClientBuilder.java

    r5804 r6912  
    5050    /**
    5151     * Constructor.
     52     *
     53     * @param unknownAsDom
     54     *            if <code>true</code> unknown data views are parsed into a DOM
     55     *
    5256     */
    5357    public ClarinFCSClientBuilder(boolean unknownAsDom) {
  • SRUClient/trunk/src/test/java/eu/clarin/sru/client/TestUtils.java

    r6903 r6912  
    6262        }
    6363        SRUSearchRetrieveRequest request = new SRUSearchRetrieveRequest(baseURI);
    64         request.setQuery(query);
     64        request.setQuery(SRUClientConstants.QUERY_TYPE_CQL, query);
    6565//        request.setRecordSchema(ClarinFCSRecordData.LEGACY_RECORD_SCHEMA);
    6666        request.setMaximumRecords(5);
Note: See TracChangeset for help on using the changeset viewer.