001 /*
002 * Copyright 2008 Marc Wick, geonames.org
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 */
017 package org.geonames;
018
019 /**
020 * search criteria for web services returning toponyms.
021 *
022 * The string parameters do not have to be utf8 encoded. The encoding is done
023 * transparently in the call to the web service.
024 *
025 * The main parameter for the search over all fields is the 'q' parameter.
026 *
027 * @see WebService#search
028 *
029 * @see <a href="http://www.geonames.org/export/geonames-search.html">search
030 * webservice documentation< /a>
031 *
032 * @author marc@geonames
033 *
034 */
035 public class ToponymSearchCriteria {
036
037 private String q;
038
039 private String countryCode;
040
041 private String countryBias;
042
043 private String continentCode;
044
045 private String name;
046
047 private String nameEquals;
048
049 private String nameStartsWith;
050
051 private String tag;
052
053 private String language;
054
055 private Style style;
056
057 private FeatureClass featureClass;
058
059 private String[] featureCodes;
060
061 private String adminCode1;
062
063 private String adminCode2;
064
065 private String adminCode3;
066
067 private String adminCode4;
068
069 private int maxRows;
070
071 private int startRow;
072
073 /**
074 * @return Returns the ISO 3166-1-alpha-2 countryCode.
075 */
076 public String getCountryCode() {
077 return countryCode;
078 }
079
080 /**
081 * @param countryCode
082 * The ISO 3166-1-alpha-2 countryCode to set.
083 */
084 public void setCountryCode(String countryCode)
085 throws InvalidParameterException {
086 if (countryCode != null && countryCode.length() != 2) {
087 throw new InvalidParameterException("invalid country code "
088 + countryCode);
089 }
090 this.countryCode = countryCode;
091 }
092
093 /**
094 * @return the countryBias
095 */
096 public String getCountryBias() {
097 return countryBias;
098 }
099
100 /**
101 * @param countryBias
102 * the countryBias to set
103 */
104 public void setCountryBias(String countryBias) {
105 this.countryBias = countryBias;
106 }
107
108 /**
109 * @return the continentCode
110 */
111 public String getContinentCode() {
112 return continentCode;
113 }
114
115 /**
116 * @param continentCode
117 * the continentCode to set
118 */
119 public void setContinentCode(String continentCode) {
120 this.continentCode = continentCode;
121 }
122
123 /**
124 * @return Returns the nameEquals.
125 */
126 public String getNameEquals() {
127 return nameEquals;
128 }
129
130 /**
131 * @param nameEquals
132 * The nameEquals to set.
133 */
134 public void setNameEquals(String exactName) {
135 this.nameEquals = exactName;
136 }
137
138 /**
139 * @return Returns the featureCodes.
140 */
141 public String[] getFeatureCodes() {
142 return featureCodes;
143 }
144
145 /**
146 * @param featureCodes
147 * The featureCodes to set.
148 */
149 public void setFeatureCodes(String[] featureCodes) {
150 this.featureCodes = featureCodes;
151 }
152
153 public void setFeatureCode(String featureCode) {
154 this.featureCodes = new String[] { featureCode };
155 }
156
157 /**
158 * @return Returns the language.
159 */
160 public String getLanguage() {
161 return language;
162 }
163
164 /**
165 * @param language
166 * The language to set.
167 */
168 public void setLanguage(String language) {
169 this.language = language;
170 }
171
172 /**
173 * @return Returns the maxRows.
174 */
175 public int getMaxRows() {
176 return maxRows;
177 }
178
179 /**
180 * @param maxRows
181 * The maxRows to set.
182 */
183 public void setMaxRows(int maxRows) {
184 this.maxRows = maxRows;
185 }
186
187 /**
188 * @return Returns the name.
189 */
190 public String getName() {
191 return name;
192 }
193
194 /**
195 * search over the name field only.
196 *
197 * @param name
198 * The name to set.
199 */
200 public void setName(String name) {
201 this.name = name;
202 }
203
204 /**
205 * @return Returns the q.
206 */
207 public String getQ() {
208 return q;
209 }
210
211 /**
212 * The main search term. The search is executed over all fields (place name,
213 * country name, admin names, etc)
214 *
215 * @param q
216 * The q to set.
217 */
218 public void setQ(String q) {
219 this.q = q;
220 }
221
222 /**
223 * @return Returns the startRow.
224 */
225 public int getStartRow() {
226 return startRow;
227 }
228
229 /**
230 * @param startRow
231 * The startRow to set.
232 */
233 public void setStartRow(int startRow) {
234 this.startRow = startRow;
235 }
236
237 /**
238 * @return Returns the style.
239 */
240 public Style getStyle() {
241 return style;
242 }
243
244 /**
245 * @param style
246 * The style to set.
247 */
248 public void setStyle(Style style) {
249 this.style = style;
250 }
251
252 /**
253 * @return Returns the tag.
254 */
255 public String getTag() {
256 return tag;
257 }
258
259 /**
260 * @param tag
261 * The tag to set.
262 */
263 public void setTag(String tag) {
264 this.tag = tag;
265 }
266
267 /**
268 * @return Returns the nameStartsWith.
269 */
270 public String getNameStartsWith() {
271 return nameStartsWith;
272 }
273
274 /**
275 * @param nameStartsWith
276 * The nameStartsWith to set.
277 */
278 public void setNameStartsWith(String nameStartsWith) {
279 this.nameStartsWith = nameStartsWith;
280 }
281
282 /**
283 * @return the featureClass
284 */
285 public FeatureClass getFeatureClass() {
286 return featureClass;
287 }
288
289 /**
290 * @param featureClass
291 * the featureClass to set
292 */
293 public void setFeatureClass(FeatureClass featureClass) {
294 this.featureClass = featureClass;
295 }
296
297 /**
298 * @return the adminCode1
299 */
300 public String getAdminCode1() {
301 return adminCode1;
302 }
303
304 /**
305 * @param adminCode1
306 * the adminCode1 to set
307 */
308 public void setAdminCode1(String adminCode1) {
309 this.adminCode1 = adminCode1;
310 }
311
312 /**
313 * @return the adminCode2
314 */
315 public String getAdminCode2() {
316 return adminCode2;
317 }
318
319 /**
320 * @param adminCode2
321 * the adminCode2 to set
322 */
323 public void setAdminCode2(String adminCode2) {
324 this.adminCode2 = adminCode2;
325 }
326
327 /**
328 * @return the adminCode3
329 */
330 public String getAdminCode3() {
331 return adminCode3;
332 }
333
334 /**
335 * @param adminCode3
336 * the adminCode3 to set
337 */
338 public void setAdminCode3(String adminCode3) {
339 this.adminCode3 = adminCode3;
340 }
341
342 public String getAdminCode4() {
343 return adminCode4;
344 }
345
346 public void setAdminCode4(String adminCode4) {
347 this.adminCode4 = adminCode4;
348 }
349
350 }