Changeset 2997 for SRUClient


Ignore:
Timestamp:
06/05/13 15:00:13 (11 years ago)
Author:
oschonef
Message:
  • add proper interface for enabling or disabling parsing of the explain record data (aka ZeeRex? record)
Location:
SRUClient/trunk/src
Files:
3 edited

Legend:

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

    r2959 r2997  
    2727public class SRUExplainRequest extends SRUAbstractRequest {
    2828    private SRURecordPacking recordPacking;
    29 
     29    private boolean parseRecordDataEnabled = false;
    3030
    3131    /**
     
    7777
    7878
     79    /**
     80     * Enable or disable parsing of explain record data (ZeeRex record) of the
     81     * explain response.
     82     *
     83     * @param enabled
     84     *            <code>true</code> enabled parsing, <code>false</code> disables
     85     *            parsing
     86     */
     87    public void setParseRecordDataEnabled(boolean enabled) {
     88        this.parseRecordDataEnabled = enabled;
     89    }
     90   
     91
     92    /**
     93     * Check, whether the record data of a explain response (ZeeRex record)
     94     * shall be parsed or not.
     95     *
     96     * @return <code>true</code> if parsing is enabled, <code>false</code>
     97     *         otherwise
     98     */
     99    public boolean isParseRecordDataEnabled() {
     100        return parseRecordDataEnabled;
     101    }
     102
     103
    79104    @Override
    80105    SRUOperation getOperation() {
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUSimpleClient.java

    r2990 r2997  
    8585    private final SRUExplainRecordDataParser explainRecordParser =
    8686            new SRUExplainRecordDataParser();
    87     // FIXME: temporary hack
    88     public static final String X_PARSE_ZEEREX_RECORD_DATA =
    89             "x-parse-zeerex-record-data";
    9087
    9188    /**
     
    497494        logger.debug("parsing 'explain' response (mode = {})",
    498495                (request.isStrictMode() ? "strict" : "non-strict"));
    499 
    500         // FIXME: temporary hack
    501         boolean parseRecordData =
    502                 (request.getExtraRequestData(X_PARSE_ZEEREX_RECORD_DATA) != null);
    503         doParseExplainResponse(reader, request, handler, parseRecordData);
     496        /*
     497         * Eventually, SRUClient should always parse explain record data.
     498         * However, for now, make caller explicitly ask for it.
     499         */
     500        final boolean parse = request.isParseRecordDataEnabled();
     501        if (!parse) {
     502            logger.debug("parsing of explain record data skipped");
     503        }
     504        doParseExplainResponse(reader, request, handler, parse);
    504505    }
    505506
  • SRUClient/trunk/src/test/java/eu/clarin/sru/client/TestUtils.java

    r2995 r2997  
    4040        SRUExplainRequest request = new SRUExplainRequest(baseURI);
    4141        request.setExtraRequestData("x-indent-response", "4");
    42         request.setExtraRequestData(SRUSimpleClient.X_PARSE_ZEEREX_RECORD_DATA, "true");
     42        request.setParseRecordDataEnabled(true);
    4343        return request;
    4444    }
     
    4949        request.setScanClause("fcs.resource = root");
    5050        request.setExtraRequestData("x-clarin-resource-info", "true");
     51        request.setExtraRequestData("x-indent-response", "4");
    5152        return request;
    5253    }
     
    6263        request.setMaximumRecords(5);
    6364        request.setRecordPacking(SRURecordPacking.XML);
    64 //        request.setExtraRequestData("x-indent-response", "4");
     65        request.setExtraRequestData("x-indent-response", "4");
    6566        return request;
    6667    }
Note: See TracChangeset for help on using the changeset viewer.