1 |
2741
|
costa
|
/**
|
2 |
|
|
* '$RCSfile$'
|
3 |
|
|
* Copyright: 2005 University of New Mexico and the
|
4 |
|
|
* Regents of the University of California and the
|
5 |
|
|
* National Center for Ecological Analysis and Synthesis
|
6 |
|
|
* '$Author$'
|
7 |
|
|
* '$Date$'
|
8 |
|
|
* '$Revision$'
|
9 |
|
|
*
|
10 |
|
|
* This program is free software; you can redistribute it and/or modify
|
11 |
|
|
* it under the terms of the GNU General Public License as published by
|
12 |
|
|
* the Free Software Foundation; either version 2 of the License, or
|
13 |
|
|
* (at your option) any later version.
|
14 |
|
|
*
|
15 |
|
|
* This program is distributed in the hope that it will be useful,
|
16 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
|
|
* GNU General Public License for more details.
|
19 |
|
|
*
|
20 |
|
|
* You should have received a copy of the GNU General Public License
|
21 |
|
|
* along with this program; if not, write to the Free Software
|
22 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
23 |
|
|
*/
|
24 |
|
|
|
25 |
|
|
package edu.ucsb.nceas.metacat.advancedsearch;
|
26 |
|
|
|
27 |
|
|
/**
|
28 |
|
|
* @author dcosta
|
29 |
|
|
*
|
30 |
|
|
* The AdvancedSearchQueryTerm class holds the data needed to produce a xml
|
31 |
|
|
* string fragment representing a single queryterm in a querygroup.
|
32 |
|
|
*/
|
33 |
|
|
public class AdvancedSearchQueryTerm {
|
34 |
|
|
|
35 |
|
|
// Object variables
|
36 |
|
|
private final String caseSensitive;//Case sensitive setting, "true" or "false"
|
37 |
|
|
private final String indent; // String of spaces for indenting output
|
38 |
|
|
private final int initialLength = 100; // Initial length of the stringBuffer
|
39 |
|
|
private final String pathExpr; // The search field, e.g. "keyword"
|
40 |
|
|
private final String searchMode; // The search mode, e.g. "less-than"
|
41 |
|
|
private StringBuffer stringBuffer; // Holds the queryterm xml string
|
42 |
|
|
private final String value; // The search value to match, e.g. "35"
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
/**
|
46 |
|
|
* Constructor. Initializes searchMode, caseSensitive, value, and indent.
|
47 |
|
|
*
|
48 |
|
|
* @param searchMode The search mode, e.g. "less-than-equals"
|
49 |
|
|
* @param caseSensitive Case sensitive setting, "true" or "false"
|
50 |
|
|
* @param pathExpr The search field, e.g. "northBoundingCoordinate"
|
51 |
|
|
* @param value The search value to match, e.g. "35"
|
52 |
|
|
* @param indent String of spaces for indenting output
|
53 |
|
|
*/
|
54 |
|
|
public AdvancedSearchQueryTerm(final String searchMode,
|
55 |
|
|
final String caseSensitive,
|
56 |
|
|
final String pathExpr,
|
57 |
|
|
final String value,
|
58 |
|
|
final String indent
|
59 |
|
|
) {
|
60 |
|
|
this.searchMode = searchMode;
|
61 |
|
|
this.caseSensitive = caseSensitive;
|
62 |
|
|
this.pathExpr = pathExpr;
|
63 |
|
|
this.value = value;
|
64 |
|
|
this.indent = indent;
|
65 |
|
|
stringBuffer = new StringBuffer(initialLength);
|
66 |
|
|
}
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
/**
|
70 |
|
|
* Produce a xml string fragment that represents this queryterm.
|
71 |
|
|
*
|
72 |
|
|
* @return A xml string fragment that represents this queryterm.
|
73 |
|
|
*/
|
74 |
|
|
public String toString() {
|
75 |
|
|
stringBuffer.append(indent +
|
76 |
|
|
"<queryterm searchmode=\"" +
|
77 |
|
|
searchMode +
|
78 |
|
|
"\" casesensitive=\"" +
|
79 |
|
|
caseSensitive +
|
80 |
|
|
"\">\n"
|
81 |
|
|
);
|
82 |
|
|
|
83 |
|
|
stringBuffer.append(indent + " <value>" + value + "</value>\n");
|
84 |
|
|
|
85 |
|
|
// For a simple search or a browse search, the pathExpr string will be "".
|
86 |
|
|
if (!pathExpr.equals("")) {
|
87 |
|
|
stringBuffer.append(indent + " <pathexpr>" + pathExpr + "</pathexpr>\n");
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
stringBuffer.append(indent + "</queryterm>\n");
|
91 |
|
|
|
92 |
|
|
return stringBuffer.toString();
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
}
|