1 | /** |
---|
2 | * This software is copyright (c) 2011-2013 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 | /** |
---|
20 | * An object for performing a <em>explain</em> operation. |
---|
21 | * |
---|
22 | * @see SRUExplainHandler |
---|
23 | * @see <a href="http://www.loc.gov/standards/sru/specs/explain.html">SRU Explain Operation</a> |
---|
24 | */ |
---|
25 | public final class SRUExplainRequest extends SRUAbstractRequest { |
---|
26 | private SRURecordPacking recordPacking; |
---|
27 | |
---|
28 | |
---|
29 | /** |
---|
30 | * Constructor. |
---|
31 | * |
---|
32 | * @param baseURI |
---|
33 | * the baseURI of the endpoint |
---|
34 | */ |
---|
35 | public SRUExplainRequest(String baseURI) { |
---|
36 | super(baseURI); |
---|
37 | } |
---|
38 | |
---|
39 | |
---|
40 | /** |
---|
41 | * Set the requested record packing. |
---|
42 | * |
---|
43 | * @param recordPacking |
---|
44 | * the requested record packing |
---|
45 | * @see SRURecordPacking |
---|
46 | */ |
---|
47 | public void setRecordPacking(SRURecordPacking recordPacking) { |
---|
48 | if (recordPacking == null) { |
---|
49 | throw new NullPointerException("recordPacking == null"); |
---|
50 | } |
---|
51 | this.recordPacking = recordPacking; |
---|
52 | } |
---|
53 | |
---|
54 | |
---|
55 | /** |
---|
56 | * Get the requested record packing. |
---|
57 | * |
---|
58 | * @return the requested record packing |
---|
59 | * @see SRURecordPacking |
---|
60 | */ |
---|
61 | public SRURecordPacking getRecordPacking() { |
---|
62 | return recordPacking; |
---|
63 | } |
---|
64 | |
---|
65 | |
---|
66 | @Override |
---|
67 | SRUOperation getOperation() { |
---|
68 | return SRUOperation.EXPLAIN; |
---|
69 | } |
---|
70 | |
---|
71 | |
---|
72 | @Override |
---|
73 | void addParametersToURI(URIHelper uriHelper) throws SRUClientException { |
---|
74 | // recordPacking |
---|
75 | if (recordPacking != null) { |
---|
76 | switch (recordPacking) { |
---|
77 | case XML: |
---|
78 | uriHelper.append(PARAM_RECORD_PACKING, RECORD_PACKING_XML); |
---|
79 | break; |
---|
80 | case STRING: |
---|
81 | uriHelper.append(PARAM_RECORD_PACKING, RECORD_PACKING_STRING); |
---|
82 | break; |
---|
83 | default: |
---|
84 | throw new SRUClientException("unsupported record packing: " + |
---|
85 | recordPacking); |
---|
86 | } // switch |
---|
87 | } |
---|
88 | } |
---|
89 | |
---|
90 | } // class SRUExplainRequest |
---|