Changeset 2946 for SRUClient


Ignore:
Timestamp:
05/28/13 13:39:34 (11 years ago)
Author:
oschonef
Message:
  • (revert) remove version argument from SRURecordDataParser parse() method
  • re-factor and specialize SRUExplainRecordDataParser
Location:
SRUClient/trunk/src/main/java/eu/clarin/sru/client
Files:
4 edited

Legend:

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

    r2940 r2946  
    3535 * @see <a href="http://zeerex.z3950.org/dtd/">The ZeeRex DTD</a>
    3636 */
    37 public class SRUExplainRecordDataParser implements SRURecordDataParser {
    38     static final String ZEEREX_NS       = SRUExplainRecordData.RECORD_SCHEMA;
    39     static final String ZEEREX_NS_QUIRK = "http://explain.z3950.org/dtd/2.1/";
     37class SRUExplainRecordDataParser {
     38    private static final String ZEEREX_NS       =
     39            SRUExplainRecordData.RECORD_SCHEMA;
     40    private static final String ZEEREX_NS_QUIRK =
     41            "http://explain.z3950.org/dtd/2.1/";
    4042    private static final String VERSION_1_1     = "1.1";
    4143    private static final String VERSION_1_2     = "1.2";
     
    4547            LoggerFactory.getLogger(SRUExplainRecordDataParser.class);
    4648
    47     @Override
    48     public String getRecordSchema() {
    49         return SRUExplainRecordData.RECORD_SCHEMA;
    50     }
    51 
    52 
    53     @Override
    54     public SRURecordData parse(final XMLStreamReader reader, SRUVersion version)
    55             throws XMLStreamException, SRUClientException {
    56         logger.debug("parsing explain record data for version {}", version);
     49
     50    public SRURecordData parse(XMLStreamReader reader,
     51            SRUVersion version, String recordSchema) throws XMLStreamException,
     52            SRUClientException {
     53        // sanity check, if we are dealing with the expected record schema
     54        if (!(ZEEREX_NS.equals(recordSchema) ||
     55                ZEEREX_NS_QUIRK.equals(recordSchema))) {
     56            throw new SRUClientException("record schema '" + recordSchema +
     57                    "' not supported in explain response record data");
     58        }
     59
     60        logger.debug("parsing explain record data (version={} schema={})",
     61                version, recordSchema);
    5762
    5863        // explain
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRURecordDataParser.java

    r2936 r2946  
    3939     * @param reader
    4040     *            a {@link XMLStreamReader} to parse the record data
    41      * @param version
    42      *            the {@link SRUVersion} that was used to encode the record
    4341     * @return the parsed record
    4442     * @throws XMLStreamException
     
    4846     * @see SRURecordData
    4947     */
    50     public SRURecordData parse(XMLStreamReader reader, SRUVersion version)
     48    public SRURecordData parse(XMLStreamReader reader)
    5149            throws XMLStreamException, SRUClientException;
    5250
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUSimpleClient.java

    r2945 r2946  
    496496
    497497        // FIXME: ship explain record data for now
    498 //        doParseExplainResponse(reader, request, handler, true);
    499         doParseExplainResponse(reader, request, handler, false);
     498        doParseExplainResponse(reader, request, handler, true);
     499//        doParseExplainResponse(reader, request, handler, false);
    500500    }
    501501
     
    556556                }
    557557
    558                 /*
    559                  * Hard-coded record schema identifiers for explain
    560                  */
    561                 if (!(SRUExplainRecordDataParser.ZEEREX_NS.equals(schema) ||
    562                       SRUExplainRecordDataParser.ZEEREX_NS_QUIRK.equals(schema))) {
    563                     throw new SRUClientException("record schema '" + schema +
    564                             "' not supported in explain response");
    565                 }
    566 
    567558                try {
    568559                    proxy.reset(recordReader);
    569                     recordData = explainRecordParser.parse(proxy, version);
     560                    /*
     561                     * Try to parse explain record data with explain record
     562                     * parser. It will throw an exception, if it cannot handle
     563                     * the data.
     564                     */
     565                    recordData =
     566                            explainRecordParser.parse(proxy, version, schema);
    570567                } catch (XMLStreamException e) {
    571568                    throw new SRUClientException(
     
    10241021                                    try {
    10251022                                        proxy.reset(recordReader);
    1026                                         recordData =
    1027                                                 parser.parse(proxy, version);
     1023                                        recordData = parser.parse(proxy);
    10281024                                    } catch (XMLStreamException e) {
    10291025                                        throw new SRUClientException(
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/fcs/ClarinFCSRecordParser.java

    r2936 r2946  
    2727import eu.clarin.sru.client.SRURecordData;
    2828import eu.clarin.sru.client.SRURecordDataParser;
    29 import eu.clarin.sru.client.SRUVersion;
    3029import eu.clarin.sru.client.XmlStreamReaderUtils;
    3130
     
    5453
    5554    @Override
    56     public SRURecordData parse(XMLStreamReader reader, SRUVersion version)
     55    public SRURecordData parse(XMLStreamReader reader)
    5756            throws XMLStreamException, SRUClientException {
    5857        logger.debug("parsing CLARIN-FCS record");
Note: See TracChangeset for help on using the changeset viewer.