source: SRUClient/trunk/src/main/java/eu/clarin/sru/client/SRUAbstractResponse.java @ 2168

Last change on this file since 2168 was 2168, checked in by oschonef, 12 years ago
  • update copyright
  • add missing copyright statements
  • Property svn:eol-style set to native
File size: 2.6 KB
Line 
1/**
2 * This software is copyright (c) 2011-2012 by
3 *  - Institut fuer Deutsche Sprache (http://www.ids-mannheim.de)
4 * This is free software. You can redistribute it
5 * and/or modify it under the terms described in
6 * the GNU General Public License v3 of which you
7 * should have received a copy. Otherwise you can download
8 * it from
9 *
10 *   http://www.gnu.org/licenses/gpl-3.0.txt
11 *
12 * @copyright Institut fuer Deutsche Sprache (http://www.ids-mannheim.de)
13 *
14 * @license http://www.gnu.org/licenses/gpl-3.0.txt
15 *  GNU General Public License v3
16 */
17package eu.clarin.sru.client;
18
19import java.util.Collections;
20import java.util.List;
21
22import org.w3c.dom.Document;
23
24
25
26/**
27 * Abstract base class for SRU responses.
28 *
29 * @see SRUExplainResponse
30 * @see SRUScanResponse
31 * @see SRUSearchRetrieveResponse
32 */
33class SRUAbstractResponse<T> {
34    private final T request;
35    private final List<SRUDiagnostic> diagnostics;
36    private final Document extraResponseData;
37
38
39    /**
40     * Constructor.
41     *
42     * @param diagnostics
43     *            a list of diagnostics associated to this result or
44     *            <code>null</code> if none.
45     * @param extraResponseData
46     *            extra response data for this result or <code>null</code> if
47     *            none.
48     */
49    protected SRUAbstractResponse(T request, List<SRUDiagnostic> diagnostics,
50            Document extraResponseData) {
51        this.request = request;
52        this.diagnostics = ((diagnostics != null) && !diagnostics.isEmpty())
53                ? Collections.unmodifiableList(diagnostics) : null;
54        this.extraResponseData = extraResponseData;
55    }
56
57
58    /**
59     * Get the request that produced this response.
60     *
61     * @return the request
62     */
63    public T getRequest() {
64        return request;
65    }
66
67
68    /**
69     * Get the diagnostics for this response.
70     *
71     * @return diagnostics for this response or <code>null</code> if none
72     */
73    public List<SRUDiagnostic> getDiagnostics() {
74        return diagnostics;
75    }
76
77
78    /**
79     * Check, if the response contains any diagnostics.
80     *
81     * <p>
82     * NB: Surrogate diagnostics are not covered by this.
83     * </p>
84     *
85     * @return <code>true</code> if response contains any diagnostic,
86     *         <code>false</code> otherwise
87     */
88    public boolean hasDiagnostics() {
89        return diagnostics != null;
90    }
91
92
93    /**
94     * Get the extra response data for this result.
95     *
96     * @return a {@link Document} node for the extra response data or
97     *         <code>null</code> if none
98     */
99    public Document getExtraResponseData() {
100        return extraResponseData;
101    }
102
103} // class SRUAbstractResponse
Note: See TracBrowser for help on using the repository browser.