Changeset 7190


Ignore:
Timestamp:
10/11/18 11:35:43 (6 years ago)
Author:
Oliver Schonefeld
Message:
  • add convenience methods to SRUAbstractResponse: getDiagosticsCount() getExtraResponseDatacount()
  • add convenience methods to SRUScanResponse: TermsCount?()
  • add convenience methods to SRUSearchRetrieveResponse: getRecordsCount()
  • fix NPE in SRUAbstractResponse::getExtraResponseData(Class)
Location:
SRUClient/trunk/src/main/java/eu/clarin/sru/client
Files:
3 edited

Legend:

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

    r7077 r7190  
    125125
    126126    /**
     127     * Get the number of diagnostics in the response.
     128     *
     129     * <p>
     130     * NB: Surrogate diagnostics are not covered by this.
     131     * </p>
     132     *
     133     * @return the number of diagnostics or <code>0</code> is none
     134     */
     135    public int getDiagnosticsCount() {
     136        return (diagnostics != null) ? diagnostics.size() : 0;
     137    }
     138
     139
     140    /**
    127141     * Get the extra response data for this result.
    128142     *
     
    137151
    138152    /**
    139      * Check, if this response has any extra response data attached to it.
     153     * Check, if this response has any extra response data attached to the
     154     * response.
    140155     *
    141156     * @return <code>true</code> if extra response is attached,
     
    147162
    148163
     164    /**
     165     * Return the number of extra response data records attached to the
     166     * response.
     167     *
     168     * @return the number of records, or <code>0</code> is none
     169     */
     170    public int getExtraResponseDataCount() {
     171        return (extraResponseData != null) ? extraResponseData.size() : 0;
     172    }
     173   
     174   
    149175    /**
    150176     * Get the extra response data of a specific class for this result.
     
    155181     *            the type of {@link SRUExtraResponseData} to check for
    156182     *
    157      * @return a {@link SRUExtraResponseData} instances for the
     183     * @return a list of {@link SRUExtraResponseData} instances for the
    158184     *         extra response data from the SRU response or <code>null</code> if
    159185     *         none are available
     
    165191        }
    166192        List<V> result = null;
    167         for (SRUExtraResponseData i : extraResponseData) {
    168             if (clazz.isInstance(i)) {
    169                 if (result == null) {
    170                     result = new ArrayList<V>();
     193        if (extraResponseData != null) {
     194            for (SRUExtraResponseData i : extraResponseData) {
     195                if (clazz.isInstance(i)) {
     196                    if (result == null) {
     197                        result = new ArrayList<V>();
     198                    }
     199                    result.add(clazz.cast(i));
    171200                }
    172                 result.add(clazz.cast(i));
    173201            }
    174202        }
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUScanResponse.java

    r6938 r7190  
    6767    }
    6868
     69
     70    /**
     71     * Get the number of terms returned by the request.
     72     *
     73     * @return the number of terms or <code>0</code> if none
     74     */
     75    public int getTermsCount() {
     76        return (terms != null) ? terms.size() : 0;
     77    }
     78
    6979} // class SRUScanResponse
  • SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUSearchRetrieveResponse.java

    r6938 r7190  
    111111
    112112    /**
     113     * Get the number of records returned by the request.
     114     *
     115     * @return number of records or <code>0</code> if none
     116     */
     117    public int getRecordsCount() {
     118        return (records != null) ? records.size() : 0;
     119    }
     120
     121
     122    /**
    113123     * Get the next record position.
    114124     *
Note: See TracChangeset for help on using the changeset viewer.