Changeset 5804 for SRUClient


Ignore:
Timestamp:
11/12/14 14:33:09 (10 years ago)
Author:
Oliver Schonefeld
Message:
  • some javadoc and other miscellaneous stuff
Location:
SRUClient/trunk/src
Files:
9 edited

Legend:

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

    r5750 r5804  
    392392    /**
    393393     * <em>Note: this method is not a part of public API.</em>
    394      * @return a constant for this
     394     * @return a operation constant for this request
    395395     */
    396396    abstract SRUOperation getOperation();
     
    400400            throws SRUClientException;
    401401
    402 } // class AbstractSRURequest
     402} // class SRUAbstractRequest
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUClient.java

    r5797 r5804  
    434434                 */
    435435                throw new SRUClientException(
    436                         "internal error; 'records' are null or empty");
     436                        "internal error; 'records' is null or empty");
    437437            }
    438438        }
     
    451451            SRUClient.this.timeParsing = millisProcessing;
    452452        }
    453 
    454453    } // inner class Handler
    455454
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUGenericExtraResponseData.java

    r5797 r5804  
    3232
    3333
     34    /**
     35     * Constructor.
     36     *
     37     * @param name
     38     *            the root element of this extra response data fragment
     39     * @param fragment
     40     *            the extra response data fragment as {@link DocumentFragment}
     41     */
    3442    SRUGenericExtraResponseData(QName name, DocumentFragment fragment) {
    3543        if (name == null) {
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/fcs/ClarinFCSClientBuilder.java

    r5798 r5804  
    235235
    236236    /**
    237      * Register a Data View parser.
     237     * Register an extra response data parser.
    238238     *
    239239     * @param parser
     
    241241     * @return this {@link ClarinFCSClientBuilder} instance
    242242     * @throws IllegalArgumentException
    243      *             if an error occurred while registering the data view parser
     243     *             if an error occurred while registering the extra response
     244     *             data parser
    244245     * @see SRUExtraResponseDataParser
    245246     */
    246     public ClarinFCSClientBuilder registerExtraResponseDatar(SRUExtraResponseDataParser parser) {
     247    public ClarinFCSClientBuilder registerExtraResponseDataParser(
     248            SRUExtraResponseDataParser parser) {
    247249        if (parser == null) {
    248250            throw new NullPointerException("parser == null");
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/fcs/ClarinFCSEndpointDescription.java

    r5798 r5804  
    5252
    5353
     54    /**
     55     * Get the version of this endpoint description.
     56     *
     57     * @return the version of the endpoint description
     58     */
    5459    public int getVersion() {
    5560        return version;
     
    5762
    5863
     64    /**
     65     * Get the list of capabilities supported by this endpoint. The list
     66     * contains the appropriate URIs defined by the CLARIN-FCS specification to
     67     * indicate support for certain capabilities.
     68     *
     69     * @return the list of capabilities supported by this endpoint
     70     */
    5971    public List<URI> getCapabilities() {
    6072        return capabilites;
     
    6274
    6375
     76    /**
     77     * Get the list of data views supported by this endpoint.
     78     *
     79     * @return the list of data views supported by this endpoint
     80     */
    6481    public List<DataView> getSupportedDataViews() {
    6582        return supportedDataViews;
     
    6784
    6885
     86    /**
     87     * Get the list of top-level resources of this endpoint.
     88     *
     89     * @return the list of top-level resources of this endpoint
     90     */
    6991    public List<ResourceInfo> getResources() {
    7092        return resources;
     
    7294
    7395
    74     public static class DataView implements Serializable {
     96    /**
     97     * This class implements a description of a data view supported by the endpoint.
     98     */
     99    public static final class DataView implements Serializable {
    75100        private static final long serialVersionUID = -5628565233032672627L;
    76101
     
    94119
    95120
     121        /**
     122         * Constructor. <em>Internal use only!</em>
     123         */
    96124        DataView(String identifier, String mimeType,
    97125                DeliveryPolicy deliveryPolicy) {
     
    164192
    165193
    166     public static class ResourceInfo implements Serializable {
     194    /**
     195     * This class implements a description of a resource available at an
     196     * endpoint.
     197     */
     198    public static final class ResourceInfo implements Serializable {
    167199        private static final long serialVersionUID = 1046130188435071544L;
    168200        private final String pid;
     
    175207
    176208
     209        /**
     210         * Constructor. <em>Internal use only!</em>
     211         */
    177212        ResourceInfo(String pid, Map<String, String> title,
    178213                Map<String, String> description, String landingPageURI,
     
    311346
    312347        /**
     348         * Check, if this resource supports a certain language.
     349         *
     350         * @param language
     351         *            a language encoded as a ISO-632-3 three letter language
     352         *            code
     353         * @return <code>true</code> if the language is supported by this
     354         *         resource, <code>false</code> otherwise
     355         */
     356        public boolean supportsLanguage(String language) {
     357            if (language == null) {
     358                throw new NullPointerException("language == null");
     359            }
     360            for (String l : languages) {
     361                if (language.equals(l)) {
     362                    return true;
     363                }
     364            }
     365            return false;
     366        }
     367
     368
     369        /**
    313370         * Get the direct sub-ordinate resources of this resource.
    314371         *
    315          * @return a list of resources or <code>null</code> if this resource has no
    316          *         sub-ordinate resources
     372         * @return a list of resources or <code>null</code> if this resource has
     373         *         no sub-ordinate resources
    317374         */
    318375        public List<ResourceInfo> getSubResources() {
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/fcs/ClarinFCSEndpointDescriptionParser.java

    r5798 r5804  
    4646public class ClarinFCSEndpointDescriptionParser implements
    4747        SRUExtraResponseDataParser {
     48    /**
     49     * constant for infinite resource enumeration parsing depth
     50     */
    4851    public static final int INFINITE_MAX_DEPTH = -1;
     52    /**
     53     * constant for default parsing resource enumeration parsing depth
     54     */
    4955    public static final int DEFAULT_MAX_DEPTH  = INFINITE_MAX_DEPTH;
    5056    private static final Logger logger =
     
    6470
    6571
     72    /**
     73     * Constructor. By default, the parser will parse the endpoint resource
     74     * enumeration to an infinite depth.
     75     */
    6676    public ClarinFCSEndpointDescriptionParser() {
    6777        this(DEFAULT_MAX_DEPTH);
     
    6979
    7080
     81    /**
     82     * Constructor.
     83     *
     84     * @param maxDepth
     85     *            maximum depth for parsing the endpoint resource enumeration.
     86     * @throws IllegalArgumentException
     87     *             if an argument is illegal
     88     */
    7189    public ClarinFCSEndpointDescriptionParser(int maxDepth) {
    7290        if (maxDepth < -1) {
     
    187205        // Resources
    188206        final List<ResourceInfo> resources =
    189                 parseResources(reader, 0, supportedDataViews);
     207                parseResources(reader, 0, maxDepth, supportedDataViews);
    190208
    191209        // skip over extensions
     
    208226
    209227
    210     private List<ResourceInfo> parseResources(XMLStreamReader reader, int depth,
    211             List<DataView> supportedDataviews) throws XMLStreamException {
     228    /**
     229     * Get the maximum resource enumeration parsing depth. The first level is
     230     * indicate by the value <code>0</code>.
     231     *
     232     * @return the default resource parsing depth or <code>-1</code> for
     233     *         infinite.
     234     */
     235    public int getMaximumResourcePArsingDepth() {
     236        return maxDepth;
     237    }
     238
     239
     240    private static List<ResourceInfo> parseResources(XMLStreamReader reader,
     241            int depth, int maxDepth, List<DataView> supportedDataviews)
     242            throws XMLStreamException {
    212243        List<ResourceInfo> resources = null;
    213244
     
    285316
    286317            List<ResourceInfo> subResources = null;
    287             if (XmlStreamReaderUtils.peekStart(reader, ED_NS_URI, "Resources")) {
     318            if (XmlStreamReaderUtils.peekStart(reader,
     319                    ED_NS_URI, "Resources")) {
    288320                final int nextDepth = depth + 1;
    289                 if ((maxDepth == INFINITE_MAX_DEPTH) || (nextDepth < maxDepth)) {
     321                if ((maxDepth == INFINITE_MAX_DEPTH) ||
     322                        (nextDepth < maxDepth)) {
    290323                    subResources = parseResources(reader, nextDepth,
    291                             supportedDataviews);
     324                            maxDepth, supportedDataviews);
    292325                } else {
    293326                    XmlStreamReaderUtils.skipTag(reader, ED_NS_URI,
  • SRUClient/trunk/src/test/java/eu/clarin/sru/client/TestClient.java

    r5799 r5804  
    3737                    .unknownDataViewAsString()
    3838                    .enableLegacySupport()
    39                     .registerExtraResponseDatar(
     39                    .registerExtraResponseDataParser(
    4040                            new ClarinFCSEndpointDescriptionParser())
    4141                    .buildClient();
  • SRUClient/trunk/src/test/java/eu/clarin/sru/client/TestThreadedClient.java

    r5750 r5804  
    2424
    2525import eu.clarin.sru.client.fcs.ClarinFCSClientBuilder;
     26import eu.clarin.sru.client.fcs.ClarinFCSEndpointDescriptionParser;
    2627
    2728@Deprecated
     
    3637            SRUThreadedClient client = new ClarinFCSClientBuilder()
    3738                    .addDefaultDataViewParsers()
     39                    .unknownDataViewAsString()
     40                    .enableLegacySupport()
     41                    .registerExtraResponseDataParser(
     42                            new ClarinFCSEndpointDescriptionParser())
    3843                    .buildThreadedClient();
    3944
  • SRUClient/trunk/src/test/java/eu/clarin/sru/client/TestThreadedClientCallback.java

    r5750 r5804  
    2323
    2424import eu.clarin.sru.client.fcs.ClarinFCSClientBuilder;
     25import eu.clarin.sru.client.fcs.ClarinFCSEndpointDescriptionParser;
    2526
    2627
     
    3536            SRUThreadedClient client = new ClarinFCSClientBuilder()
    3637                    .addDefaultDataViewParsers()
     38                    .unknownDataViewAsString()
     39                    .enableLegacySupport()
     40                    .registerExtraResponseDataParser(
     41                            new ClarinFCSEndpointDescriptionParser())
    3742                    .buildThreadedClient();
    3843
Note: See TracChangeset for help on using the changeset viewer.