1 | /** |
---|
2 | * This software is copyright (c) 2011 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 | */ |
---|
17 | package eu.clarin.sru.client; |
---|
18 | |
---|
19 | import java.util.List; |
---|
20 | |
---|
21 | import javax.xml.stream.XMLStreamException; |
---|
22 | import javax.xml.stream.XMLStreamReader; |
---|
23 | |
---|
24 | |
---|
25 | /** |
---|
26 | * Receive notifications to the response of a <em>scan</em> request. |
---|
27 | * |
---|
28 | * @see SRUScanRequest |
---|
29 | * @see <a href="http://www.loc.gov/standards/sru/specs/scan.html">SRU |
---|
30 | * Scan Operation</a> |
---|
31 | */ |
---|
32 | public interface SRUScanHandler { |
---|
33 | /** |
---|
34 | * A flag to indicate the position of the term within the complete term |
---|
35 | * list. |
---|
36 | */ |
---|
37 | public enum WhereInList { |
---|
38 | /** |
---|
39 | * The first term (<em>first</em>) |
---|
40 | */ |
---|
41 | FIRST, |
---|
42 | |
---|
43 | /** |
---|
44 | * The last term (<em>last</em>) |
---|
45 | */ |
---|
46 | LAST, |
---|
47 | |
---|
48 | /** |
---|
49 | * The only term (<em>only</em>) |
---|
50 | */ |
---|
51 | ONLY, |
---|
52 | |
---|
53 | /** |
---|
54 | * Any other term (<em>inner</em>) |
---|
55 | */ |
---|
56 | INNER; |
---|
57 | } |
---|
58 | |
---|
59 | |
---|
60 | /** |
---|
61 | * Receive notification of diagnostics. |
---|
62 | * |
---|
63 | * @param diagnostics |
---|
64 | * a list of {@link SRUDiagnostic} |
---|
65 | * @throws SRUClientException |
---|
66 | * any SRU exception, possibly wrapping another exception |
---|
67 | * @see SRUDiagnostic |
---|
68 | */ |
---|
69 | public void onDiagnostics(List<SRUDiagnostic> diagnostics) |
---|
70 | throws SRUClientException; |
---|
71 | |
---|
72 | |
---|
73 | /** |
---|
74 | * Receive notification of request statistics. |
---|
75 | * |
---|
76 | * @param bytes |
---|
77 | * the size of the response in bytes |
---|
78 | * @param millisTotal |
---|
79 | * the total time spend processing the request |
---|
80 | * @param millisNetwork |
---|
81 | * the time spend performing network operations |
---|
82 | * @param millisParsing |
---|
83 | * the time spend parsing the response |
---|
84 | */ |
---|
85 | public void onRequestStatistics(int bytes, long millisTotal, |
---|
86 | long millisNetwork, long millisParsing); |
---|
87 | |
---|
88 | |
---|
89 | /** |
---|
90 | * Receive notification of extra response data. |
---|
91 | * |
---|
92 | * @param reader |
---|
93 | * a {@link XMLStreamReader} to parse the extra response data |
---|
94 | * @throws XMLStreamException |
---|
95 | * an error occurred while parsing the response |
---|
96 | * @throws SRUClientException |
---|
97 | * any SRU exception, possibly wrapping another exception |
---|
98 | * @see <a href="http://www.loc.gov/standards/sru/specs/extra-data.html">SRU |
---|
99 | * Extra Data / Extensions</a> |
---|
100 | */ |
---|
101 | public void onExtraResponseData(XMLStreamReader reader) |
---|
102 | throws XMLStreamException, SRUClientException; |
---|
103 | |
---|
104 | |
---|
105 | /** |
---|
106 | * Receive notifications of the start of the enumeration of terms in the |
---|
107 | * response. |
---|
108 | * |
---|
109 | * @throws SRUClientException |
---|
110 | * any SRU exception, possibly wrapping another exception |
---|
111 | */ |
---|
112 | public void onStartTerms() throws SRUClientException; |
---|
113 | |
---|
114 | |
---|
115 | /** |
---|
116 | * Receive notifications of the end of the enumeration of terms in the |
---|
117 | * response. |
---|
118 | * |
---|
119 | * @throws SRUClientException |
---|
120 | * any SRU exception, possibly wrapping another exception |
---|
121 | */ |
---|
122 | public void onFinishTerms() throws SRUClientException; |
---|
123 | |
---|
124 | |
---|
125 | /** |
---|
126 | * Receive notification of a term. |
---|
127 | * |
---|
128 | * @param value |
---|
129 | * the term (exactly) as it appears in the index |
---|
130 | * @param numberOfRecords |
---|
131 | * the number of records for the current term which would be |
---|
132 | * matched |
---|
133 | * @param displayTerm |
---|
134 | * a string for the current term to display to the end user in |
---|
135 | * place of the term itself or <code>null</code> if not available |
---|
136 | * @param whereInList |
---|
137 | * a flag to indicate the position of the term within the |
---|
138 | * complete term list or <code>null</code> of not available |
---|
139 | * @throws SRUClientException |
---|
140 | * any SRU exception, possibly wrapping another exception |
---|
141 | */ |
---|
142 | public void onTerm(String value, int numberOfRecords, String displayTerm, |
---|
143 | WhereInList whereInList) throws SRUClientException; |
---|
144 | |
---|
145 | |
---|
146 | /** |
---|
147 | * Receive notification of extra term data. |
---|
148 | * |
---|
149 | * @param value |
---|
150 | * the term (exactly) as it appears in the index |
---|
151 | * @param reader |
---|
152 | * a {@link XMLStreamReader} to parse the extra term data |
---|
153 | * @throws XMLStreamException |
---|
154 | * an error occurred while parsing the response |
---|
155 | * @throws SRUClientException |
---|
156 | * any SRU exception, possibly wrapping another exception |
---|
157 | */ |
---|
158 | public void onExtraTermData(String value, XMLStreamReader reader) |
---|
159 | throws XMLStreamException, SRUClientException; |
---|
160 | |
---|
161 | } // interface SRUScanHandler |
---|