Changeset 2131


Ignore:
Timestamp:
08/22/12 09:29:58 (12 years ago)
Author:
oschonef
Message:
  • re-factoring (2/2)
    • extract SRUClient interface
    • remove isStrictMode()/setStrictMode() methods

HEADS UP:

  • Instantiate SRUSimpleClient instead of SRUClient for the non-threaded SRU client.
Location:
SRUClient/trunk/src
Files:
1 added
2 edited

Legend:

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

    r2130 r2131  
    4848
    4949/**
    50  * A class to perform SRU operations.
     50 * A non-threaded SRU client.
    5151 * <p>This class is <em>not</em> thread-safe!</p>
    5252 */
    53 public class SRUSimpleClient {
     53public class SRUSimpleClient implements SRUClient {
    5454    /** constant record data schema parser to match any schema */
    5555    public static final String RECORD_DATA_PARSER_SCHEMA_ANY = "*";
     
    8080     * use the default SRU version.
    8181     *
    82      * @see #SRUClient(SRUVersion, boolean)
     82     * @see #SRUSimpleClient(SRUVersion, boolean)
    8383     * @see #DEFAULT_SRU_VERSION
    8484     */
     
    9494     *            the default version to use for SRU requests; may be overridden
    9595     *            by individual requests
    96      * @see #SRUClient(SRUVersion, boolean)
     96     * @see #SRUSimpleClient(SRUVersion, boolean)
    9797     */
    9898    public SRUSimpleClient(SRUVersion defaultVersion) {
     
    126126
    127127
    128     /**
    129      * Get the SRU protocol conformance mode of the client.
    130      *
    131      * @return <code>true</code> if the client operation in strict mode,
    132      *         <code>false</code> otherwise
    133      */
    134     public boolean isStrictMode() {
    135         return strictMode;
    136     }
    137 
    138 
    139     /**
    140      * Set the SRU protocol conformance mode of the client.
    141      *
    142      * @param strictMode
    143      *            <code>true</code> if the client should operate in strict mode,
    144      *            <code>false</code> if the client should be more tolerant
    145      */
    146     public void setStrictMode(boolean strictMode) {
    147         this.strictMode = strictMode;
    148     }
    149 
    150     /**
    151      * Register a record data parser.
    152      *
    153      * @param parser
    154      *            a parser instance
    155      * @throws SRUClientException
    156      *             if a parser handing the same record schema is already
    157      *             registered
    158      * @throws NullPointerException
    159      *             if any required argument is <code>null</code>
    160      * @throws IllegalArgumentException
    161      *             if the supplied parser is invalid
    162      */
     128    @Override
    163129    public void registerRecordParser(SRURecordDataParser parser)
    164130            throws SRUClientException {
     
    184150
    185151
    186     /**
    187      * Perform a <em>explain</em> operation.
    188      *
    189      * @param request
    190      *            an instance of a {@link SRUExplainRequest} object
    191      * @param handler
    192      *            an instance of {@link SRUExplainHandler} to receive callbacks
    193      *            when processing the result of this request
    194      * @throws SRUClientException
    195      *             if an unrecoverable error occurred
    196      * @throws NullPointerException
    197      *             if any required argument is <code>null</code>
    198      * @see SRUExplainRequest
    199      * @see SRUExplainHandler
    200      */
     152    @Override
    201153    public void explain(SRUExplainRequest request, SRUExplainHandler handler)
    202154            throws SRUClientException {
     
    265217
    266218
    267     /**
    268      * Perform a <em>scan</em> operation.
    269      *
    270      * @param request
    271      *            an instance of a {@link SRUScanRequest} object
    272      * @param handler
    273      *            an instance of {@link SRUScanHandler} to receive callbacks
    274      *            when processing the result of this request
    275      * @throws SRUClientException
    276      *             if an unrecoverable error occurred
    277      * @throws NullPointerException
    278      *             if any required argument is <code>null</code>
    279      * @see SRUScanRequest
    280      * @see SRUScanHandler
    281      */
     219    @Override
    282220    public void scan(SRUScanRequest request, SRUScanHandler handler)
    283221            throws SRUClientException {
     
    346284
    347285
    348     /**
    349      * Perform a <em>searchRetreive</em> operation.
    350      *
    351      * @param request
    352      *            an instance of a {@link SRUSearchRetrieveRequest} object
    353      * @param handler
    354      *            an instance of {@link SRUSearchRetrieveHandler} to receive
    355      *            callbacks when processing the result of this request
    356      * @throws SRUClientException
    357      *             if an unrecoverable error occurred
    358      * @throws NullPointerException
    359      *             if any required argument is <code>null</code>
    360      * @see SRUSearchRetrieveRequest
    361      * @see SRUSearchRetrieveHandler
    362      */
     286    @Override
    363287    public void searchRetrieve(SRUSearchRetrieveRequest request,
    364288            SRUSearchRetrieveHandler handler) throws SRUClientException {
  • SRUClient/trunk/src/test/java/eu/clarin/sru/client/TestClient.java

    r2130 r2131  
    3333        if (args.length > 0) {
    3434            logger.info("initializing client ...");
    35             SRUSimpleClient client = new SRUSimpleClient(SRUVersion.VERSION_1_2);
     35            SRUClient client = new SRUSimpleClient(SRUVersion.VERSION_1_2);
    3636            try {
    3737                client.registerRecordParser(new ClarinFederatedContentSearchRecordParser());
Note: See TracChangeset for help on using the changeset viewer.