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 | import java.net.URI; |
---|
20 | |
---|
21 | /** |
---|
22 | * An object for performing a <em>explain</em> operation. |
---|
23 | * |
---|
24 | * @see SRUExplainHandler |
---|
25 | * @see <a href="http://www.loc.gov/standards/sru/specs/explain.html">SRU Explain Operation</a> |
---|
26 | */ |
---|
27 | public class SRUExplainRequest extends SRUAbstractRequest { |
---|
28 | private SRURecordPacking recordPacking; |
---|
29 | private boolean parseRecordDataEnabled = false; |
---|
30 | |
---|
31 | /** |
---|
32 | * Constructor. |
---|
33 | * |
---|
34 | * @param baseURI |
---|
35 | * the baseURI of the endpoint |
---|
36 | */ |
---|
37 | public SRUExplainRequest(URI baseURI) { |
---|
38 | super(baseURI); |
---|
39 | } |
---|
40 | |
---|
41 | |
---|
42 | /** |
---|
43 | * Constructor. |
---|
44 | * |
---|
45 | * @param baseURI |
---|
46 | * the baseURI of the endpoint |
---|
47 | */ |
---|
48 | public SRUExplainRequest(String baseURI) { |
---|
49 | super(baseURI); |
---|
50 | } |
---|
51 | |
---|
52 | |
---|
53 | /** |
---|
54 | * Set the requested record packing. |
---|
55 | * |
---|
56 | * @param recordPacking |
---|
57 | * the requested record packing |
---|
58 | * @see SRURecordPacking |
---|
59 | */ |
---|
60 | public void setRecordPacking(SRURecordPacking recordPacking) { |
---|
61 | if (recordPacking == null) { |
---|
62 | throw new NullPointerException("recordPacking == null"); |
---|
63 | } |
---|
64 | this.recordPacking = recordPacking; |
---|
65 | } |
---|
66 | |
---|
67 | |
---|
68 | /** |
---|
69 | * Get the requested record packing. |
---|
70 | * |
---|
71 | * @return the requested record packing |
---|
72 | * @see SRURecordPacking |
---|
73 | */ |
---|
74 | public SRURecordPacking getRecordPacking() { |
---|
75 | return recordPacking; |
---|
76 | } |
---|
77 | |
---|
78 | |
---|
79 | /** |
---|
80 | * Enable or disable parsing of explain record data (ZeeRex record) of the |
---|
81 | * explain response. |
---|
82 | * |
---|
83 | * @param enabled |
---|
84 | * <code>true</code> enabled parsing, <code>false</code> disables |
---|
85 | * parsing |
---|
86 | */ |
---|
87 | public void setParseRecordDataEnabled(boolean enabled) { |
---|
88 | this.parseRecordDataEnabled = enabled; |
---|
89 | } |
---|
90 | |
---|
91 | |
---|
92 | /** |
---|
93 | * Check, whether the record data of a explain response (ZeeRex record) |
---|
94 | * shall be parsed or not. |
---|
95 | * |
---|
96 | * @return <code>true</code> if parsing is enabled, <code>false</code> |
---|
97 | * otherwise |
---|
98 | */ |
---|
99 | public boolean isParseRecordDataEnabled() { |
---|
100 | return parseRecordDataEnabled; |
---|
101 | } |
---|
102 | |
---|
103 | |
---|
104 | @Override |
---|
105 | SRUOperation getOperation() { |
---|
106 | return SRUOperation.EXPLAIN; |
---|
107 | } |
---|
108 | |
---|
109 | |
---|
110 | @Override |
---|
111 | void addParametersToURI(URIHelper uriHelper) throws SRUClientException { |
---|
112 | // recordPacking |
---|
113 | if (recordPacking != null) { |
---|
114 | switch (recordPacking) { |
---|
115 | case XML: |
---|
116 | uriHelper.append(PARAM_RECORD_PACKING, RECORD_PACKING_XML); |
---|
117 | break; |
---|
118 | case STRING: |
---|
119 | uriHelper.append(PARAM_RECORD_PACKING, RECORD_PACKING_STRING); |
---|
120 | break; |
---|
121 | default: |
---|
122 | throw new SRUClientException("unsupported record packing: " + |
---|
123 | recordPacking); |
---|
124 | } // switch |
---|
125 | } |
---|
126 | } |
---|
127 | |
---|
128 | } // class SRUExplainRequest |
---|