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 org.w3c.dom.DocumentFragment; |
---|
20 | |
---|
21 | |
---|
22 | /** |
---|
23 | * Class to hold a single entry from a scan response. |
---|
24 | * |
---|
25 | * @see SRUScanResponse |
---|
26 | */ |
---|
27 | public final class SRUTerm { |
---|
28 | private final String value; |
---|
29 | private final int numberOfRecords; |
---|
30 | private final String displayTerm; |
---|
31 | private final SRUWhereInList whereInList; |
---|
32 | private DocumentFragment extraTermData = null; |
---|
33 | |
---|
34 | |
---|
35 | /** |
---|
36 | * Constructor. |
---|
37 | * |
---|
38 | * @param value |
---|
39 | * value of the term |
---|
40 | * @param numberOfRecords |
---|
41 | * number of record or <code>-1</code> |
---|
42 | * @param displayTerm |
---|
43 | * a display string or <code>null</code> |
---|
44 | * @param whereInList |
---|
45 | * flag or <code>null</code> |
---|
46 | */ |
---|
47 | SRUTerm(String value, int numberOfRecords, String displayTerm, |
---|
48 | SRUWhereInList whereInList) { |
---|
49 | if (value == null) { |
---|
50 | throw new NullPointerException("value == null"); |
---|
51 | } |
---|
52 | this.value = value; |
---|
53 | this.numberOfRecords = numberOfRecords; |
---|
54 | this.displayTerm = displayTerm; |
---|
55 | this.whereInList = whereInList; |
---|
56 | } |
---|
57 | |
---|
58 | |
---|
59 | /** |
---|
60 | * Get the term as it appeared in the index. |
---|
61 | * |
---|
62 | * @return the value of the term |
---|
63 | */ |
---|
64 | public String getValue() { |
---|
65 | return value; |
---|
66 | } |
---|
67 | |
---|
68 | |
---|
69 | /** |
---|
70 | * Get the number of records which would me matched by the term. |
---|
71 | * |
---|
72 | * @return the number of record or <code>-1</code> if unknown |
---|
73 | */ |
---|
74 | public int getNumberOfRecords() { |
---|
75 | return numberOfRecords; |
---|
76 | } |
---|
77 | |
---|
78 | |
---|
79 | /** |
---|
80 | * Get A string to display to the end user in place of the term itself. |
---|
81 | * |
---|
82 | * @return a display string or <code>null</code> if unknown |
---|
83 | */ |
---|
84 | public String getDisplayTerm() { |
---|
85 | return displayTerm; |
---|
86 | } |
---|
87 | |
---|
88 | |
---|
89 | /** |
---|
90 | * Get the flag to indicate the position of the term within the complete |
---|
91 | * term list. |
---|
92 | * |
---|
93 | * @return the flag or <code>null</code> if unknown |
---|
94 | */ |
---|
95 | public SRUWhereInList getWhereInList() { |
---|
96 | return whereInList; |
---|
97 | } |
---|
98 | |
---|
99 | |
---|
100 | /** |
---|
101 | * Get extra term data for this term. |
---|
102 | * |
---|
103 | * @return get an instance of {@link DocumentFragment} containing the XML |
---|
104 | * fragment for the extra term data from the SRU response or |
---|
105 | * <code>null</code> if none are available |
---|
106 | */ |
---|
107 | public DocumentFragment getExtraTermData() { |
---|
108 | return extraTermData; |
---|
109 | } |
---|
110 | |
---|
111 | |
---|
112 | /** |
---|
113 | * Check, if this term has extra term data attached to it. |
---|
114 | * |
---|
115 | * @return <code>true</code> if extra term data is attached, |
---|
116 | * <code>false</code> otherwise |
---|
117 | */ |
---|
118 | public boolean hasExtraTermData() { |
---|
119 | return extraTermData != null; |
---|
120 | } |
---|
121 | |
---|
122 | void setExtraTermData(DocumentFragment extraTermData) { |
---|
123 | this.extraTermData = extraTermData; |
---|
124 | } |
---|
125 | |
---|
126 | } // class SRUTerm |
---|