Changeset 2464 for SRUClient/trunk


Ignore:
Timestamp:
01/15/13 11:03:03 (11 years ago)
Author:
oschonef
Message:
  • update to match latest FCS spec
  • some re-factoring
  • update copyright (1/2)
Location:
SRUClient/trunk/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/ClarinFCSRecordData.java

    r2305 r2464  
    11/**
    2  * This software is copyright (c) 2011 by
     2 * This software is copyright (c) 2012-2013 by
    33 *  - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de)
    44 * This is free software. You can redistribute it
     
    2323
    2424/**
    25  * A record data implementation for CLARIN FCS.
     25 * A record data implementation for CLARIN-FCS.
    2626 */
    2727public final class ClarinFCSRecordData implements
    2828        SRURecordData {
    2929    /**
    30      * The record schema for CLARIN FCS records.
     30     * The record schema for CLARIN-FCS records.
    3131     */
    3232    public static final String RECORD_SCHEMA = "http://clarin.eu/fcs/1.0";
     
    5353
    5454    /**
    55      * Get the CLARIN FCS record resource.
     55     * Get the CLARIN-FCS record resource.
    5656     *
    5757     * @return a {@link Resource} object
  • SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/ClarinFCSRecordParser.java

    r2402 r2464  
    11/**
    2  * This software is copyright (c) 2011-2012 by
     2 * This software is copyright (c) 2012-2013 by
    33 *  - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de)
    44 * This is free software. You can redistribute it
     
    3131
    3232/**
    33  * A record parse to parse records conforming to CLARIN FCS specification.
     33 * A record parse to parse records conforming to CLARIN-FCS specification.
    3434 */
    3535public class ClarinFCSRecordParser implements SRURecordDataParser {
     
    8989            String pid = XmlStreamReaderUtils.readAttributeValue(reader, null, "pid");
    9090            String ref = XmlStreamReaderUtils.readAttributeValue(reader, null, "ref");
    91             String type = XmlStreamReaderUtils.readAttributeValue(reader, null, "mime-type");
    92             if ((type == null) || type.isEmpty()) {
    93                 logger.debug("element <DataView> does not carry attribute " +
    94                         "'mime-type'; trying attribute 'type' instead");
    95                 type = XmlStreamReaderUtils.readAttributeValue(reader, null, "type");
    96                 if (type != null) {
    97                     logger.warn("attribute 'type' is deprecated for element " +
    98                             "<DataView>; please use 'mime-type' attribute");
    99                 }
    100             }
     91            String type = XmlStreamReaderUtils.readAttributeValue(reader, null, "type");
    10192            if ((type == null) || type.isEmpty()) {
    10293                throw new SRUClientException("element <DataView> needs a "
    103                         + "non-empty 'mime-type' (or 'type') attribute");
     94                        + "non-empty 'type' attribute");
    10495            }
    10596
  • SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/DataView.java

    r2394 r2464  
    11/**
    2  * This software is copyright (c) 2011-2012 by
     2 * This software is copyright (c) 2012-2013 by
    33 *  - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de)
    44 * This is free software. You can redistribute it
     
    1818
    1919/**
    20  * Base class for DataView implementations according to the CLARIN FCS record
     20 * Base class for DataView implementations according to the CLARIN-FCS record
    2121 * schema.
    2222 */
    2323public abstract class DataView {
    24     private final String mimetype;
     24    private final String type;
    2525    private final String pid;
    2626    private final String ref;
     
    3030     * Constructor.
    3131     *
    32      * @param mimetype
    33      *            the MIME type of this dataview
     32     * @param type
     33     *            the MIME type of this DataView
    3434     * @param pid
    3535     *            a persistent identifier or <code>null</code>
     
    4040     *
    4141     */
    42     protected DataView(String mimetype, String pid, String ref) {
    43         if (mimetype == null) {
    44             throw new NullPointerException("mimetype == null");
     42    protected DataView(String type, String pid, String ref) {
     43        if (type == null) {
     44            throw new NullPointerException("type == null");
    4545        }
    46         this.mimetype = mimetype;
    47         this.pid = ((pid != null) && !pid.isEmpty()) ? pid : null;
    48         this.ref = ((ref != null) && !ref.isEmpty()) ? ref : null;
     46        this.type = type;
     47        this.pid  = ((pid != null) && !pid.isEmpty()) ? pid : null;
     48        this.ref  = ((ref != null) && !ref.isEmpty()) ? ref : null;
    4949    }
    5050
     
    5656     */
    5757    public String getMimeType() {
    58         return mimetype;
     58        return type;
    5959    }
    6060
     
    6363     * Convenience method to check if this DataView is of a certain MIME type.
    6464     *
    65      * @param mimetype
     65     * @param type
    6666     *            the MIME type to test against
    6767     * @return <code>true</code> if the DataView is in the supplied MIME type,
     
    7070     *             if any required arguments are not supplied
    7171     */
    72     public boolean isMimeType(String mimetype) {
    73         if (mimetype == null) {
     72    public boolean isMimeType(String type) {
     73        if (type == null) {
    7474            throw new NullPointerException("mimetype == null");
    7575        }
    76         return (this.mimetype.equals(mimetype));
     76        return (this.type.equals(type));
    7777    }
    7878
  • SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/DataViewGenericDOM.java

    r2394 r2464  
    11/**
    2  * This software is copyright (c) 2011-2012 by
     2 * This software is copyright (c) 2012-2013 by
    33 *  - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de)
    44 * This is free software. You can redistribute it
     
    2020
    2121
     22/**
     23 * A generic DataView implementation that stores the content as a DOM document.
     24 */
    2225public class DataViewGenericDOM extends DataView {
    2326    private final Document document;
    2427
    2528
    26     protected DataViewGenericDOM(String mimetype, String pid, String ref,
     29    protected DataViewGenericDOM(String type, String pid, String ref,
    2730            Document document) {
    28         super(mimetype, pid, ref);
     31        super(type, pid, ref);
    2932        this.document = document;
    3033    }
    3134
    3235
     36    /**
     37     * Get the DataView content.
     38     *
     39     * @return the DataView content as DOM document.
     40     */
    3341    public Document getDocument() {
    3442        return document;
  • SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/DataViewGenericString.java

    r2402 r2464  
    11/**
    2  * This software is copyright (c) 2011-2012 by
     2 * This software is copyright (c) 2012-2013 by
    33 *  - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de)
    44 * This is free software. You can redistribute it
     
    1717package eu.clarin.sru.fcs;
    1818
     19/**
     20 * A generic DataView implementation that stores the content as a String.
     21 */
    1922public class DataViewGenericString extends DataView {
    2023    private final String content;
    2124
    2225
    23     protected DataViewGenericString(String mimetype, String pid, String ref,
     26    protected DataViewGenericString(String type, String pid, String ref,
    2427            String content) {
    25         super(mimetype, pid, ref);
     28        super(type, pid, ref);
    2629        this.content = content;
    2730    }
    2831
    2932
     33    /**
     34     * Get DataView content.
     35     *
     36     * @return the DataView content as String.
     37     */
    3038    public String getContent() {
    3139        return content;
  • SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/DataViewKWIC.java

    r2394 r2464  
    11/**
    2  * This software is copyright (c) 2011-2012 by
     2 * This software is copyright (c) 2012-2013 by
    33 *  - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de)
    44 * This is free software. You can redistribute it
     
    1818
    1919/**
    20  * A CLARIN FCS KWIC DataView.
     20 * A CLARIN-FCS KWIC DataView.
    2121 */
    2222public final class DataViewKWIC extends DataView {
    2323    /**
    24      * The MIME type for CLARIN FCS KWIC dataviews.
     24     * The MIME type for CLARIN-FCS KWIC data views.
    2525     */
    26     public static final String MIMETYPE = "application/x-clarin-fcs-kwic+xml";
     26    public static final String TYPE = "application/x-clarin-fcs-kwic+xml";
    2727    private final String left;
    2828    private final String keyword;
     
    4646    DataViewKWIC(String pid, String ref, String left, String keyword,
    4747            String right) {
    48         super(MIMETYPE, pid, ref);
     48        super(TYPE, pid, ref);
    4949        this.left    = (left    != null) ? left    : "";
    5050        this.keyword = (keyword != null) ? keyword : "";
  • SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/DataViewParser.java

    r2394 r2464  
    11/**
    2  * This software is copyright (c) 2011-2012 by
     2 * This software is copyright (c) 2012-2013 by
    33 *  - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de)
    44 * This is free software. You can redistribute it
     
    2525/**
    2626 * Base class for implementing parsers for parsing a specific DataView in a
    27  * CLARIN FCS record.
     27 * CLARIN-FCS record.
    2828 * <p>If multiple record parsers support a certain type, the one
    2929 * with the highest priority is selected.</p>
  • SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/DataViewParserGenericDOM.java

    r2401 r2464  
    11/**
    2  * This software is copyright (c) 2011-2012 by
     2 * This software is copyright (c) 2012-2013 by
    33 *  - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de)
    44 * This is free software. You can redistribute it
  • SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/DataViewParserGenericString.java

    r2402 r2464  
    11/**
    2  * This software is copyright (c) 2011-2012 by
     2 * This software is copyright (c) 2012-2013 by
    33 *  - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de)
    44 * This is free software. You can redistribute it
  • SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/DataViewParserKWIC.java

    r2394 r2464  
    11/**
    2  * This software is copyright (c) 2011-2012 by
     2 * This software is copyright (c) 2012-2013 by
    33 *  - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de)
    44 * This is free software. You can redistribute it
     
    3434    @Override
    3535    public boolean acceptType(String type) {
    36         return DataViewKWIC.MIMETYPE.equals(type) ||
     36        return DataViewKWIC.TYPE.equals(type) ||
    3737                KWIC_LEGACY_TYPE.equals(type);
    3838    }
     
    4747            String ref) throws XMLStreamException, SRUClientException {
    4848        if (KWIC_LEGACY_TYPE.equals(type)) {
    49             logger.warn("type '" + KWIC_LEGACY_TYPE + "' is deprecteded for a KWIC <DataView>, please use '" + DataViewKWIC.MIMETYPE + "' instead");
     49            logger.warn("type '" + KWIC_LEGACY_TYPE + "' is deprecteded for a KWIC <DataView>, please use '" + DataViewKWIC.TYPE + "' instead");
    5050        }
    5151        String left = null;
  • SRUClient/trunk/src/main/java/eu/clarin/sru/fcs/Resource.java

    r2394 r2464  
    11/**
    2  * This software is copyright (c) 2011-2012 by
     2 * This software is copyright (c) 2012-2013 by
    33 *  - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de)
    44 * This is free software. You can redistribute it
     
    2121
    2222/**
    23  * A CLARIN FCS resource
     23 * A CLARIN-FCS resource
    2424 */
    2525public class Resource {
    2626    /**
    27      * A CLARIN FCS resource fragment
     27     * A CLARIN-FCS resource fragment
    2828     */
    2929    public final static class ResourceFragment {
     
    6868        /**
    6969         * Convenience method to check if this resource fragment has any
    70          * dataviews.
     70         * data views.
    7171         *
    72          * @return <code>true</code> if this resource fragment has dataviews,
     72         * @return <code>true</code> if this resource fragment has data views,
    7373         *         <code>false</code> otherwise
    7474         */
     
    7979
    8080        /**
    81          * Get the list of dataview objects for this this resource fragment.
     81         * Get the list of data view objects for this this resource fragment.
    8282         *
    8383         * @return a list of {@link DataView} objects or <code>null</code>,
  • SRUClient/trunk/src/test/java/eu/clarin/sru/client/TestUtils.java

    r2402 r2464  
    185185                            s,
    186186                            view.getContent() });
    187             } else if (dataview.isMimeType(DataViewKWIC.MIMETYPE)) {
     187            } else if (dataview.isMimeType(DataViewKWIC.TYPE)) {
    188188                final DataViewKWIC kw = (DataViewKWIC) dataview;
    189189                logger.info("{}DataView: {} / {} / {}",
Note: See TracChangeset for help on using the changeset viewer.