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 */
017package org.geonames;
018
019/**
020 * a GeoNames toponym
021 * 
022 * @author marc@geonames
023 * 
024 */
025public class Toponym {
026
027        private int geoNameId;
028
029        private String name;
030
031        private String alternateNames;
032
033        private String continentCode;
034
035        private String countryCode;
036
037        private String countryName;
038
039        private Long population;
040
041        private Integer elevation;
042
043        private FeatureClass featureClass;
044
045        private String featureClassName;
046
047        private String featureCode;
048
049        private String featureCodeName;
050
051        private double latitude;
052
053        private double longitude;
054
055        private String adminCode1;
056        private String adminName1;
057
058        private String adminCode2;
059        private String adminName2;
060
061        private String adminCode3;
062        private String adminName3;
063
064        private String adminCode4;
065        private String adminName4;
066
067        private String adminCode5;
068        private String adminName5;
069
070        private Timezone timezone;
071
072        private Style style;
073
074        private BoundingBox boundingBox;
075
076        /**
077         * @return the continentCode
078         * @throws InsufficientStyleException
079         */
080        public String getContinentCode() throws InsufficientStyleException {
081                if (continentCode == null && style != null
082                                && Style.LONG.compareTo(style) > 0) {
083                        throw new InsufficientStyleException(
084                                        "continentCode not supported by style " + style.name());
085                }
086                return continentCode;
087        }
088
089        /**
090         * @param continentCode
091         *            the continentCode to set
092         */
093        public void setContinentCode(String continentCode) {
094                this.continentCode = continentCode;
095        }
096
097        /**
098         * @return Returns the ISO 3166-1-alpha-2 countryCode.
099         */
100        public String getCountryCode() {
101                return countryCode;
102        }
103
104        /**
105         * @param countryCode
106         *            The ISO 3166-1-alpha-2 countryCode to set.
107         */
108        public void setCountryCode(String countryCode) {
109                this.countryCode = countryCode;
110        }
111
112        /**
113         * @return Returns the elevation in meter.
114         */
115        public Integer getElevation() throws InsufficientStyleException {
116                if (elevation == null && style != null
117                                && Style.LONG.compareTo(style) > 0) {
118                        throw new InsufficientStyleException(
119                                        "elevation not supported by style " + style.name());
120                }
121                return elevation;
122        }
123
124        /**
125         * @param elevation
126         *            The elevation im meter to set.
127         */
128        public void setElevation(Integer elevation) {
129                this.elevation = elevation;
130        }
131
132        /**
133         * the feature class {@link FeatureClass}
134         * 
135         * @see <a href="http://www.geonames.org/export/codes.html">GeoNames Feature
136         *      Codes</a>
137         * @return Returns the featureClass.
138         */
139        public FeatureClass getFeatureClass() {
140                return featureClass;
141        }
142
143        /**
144         * @param featureClass
145         *            The featureClass to set.
146         */
147        public void setFeatureClass(FeatureClass featureClass) {
148                this.featureClass = featureClass;
149        }
150
151        /**
152         * @see <a href="http://www.geonames.org/export/codes.html">GeoNames Feature
153         *      Codes</a>
154         * @return Returns the featureCode.
155         */
156        public String getFeatureCode() {
157                return featureCode;
158        }
159
160        /**
161         * @param featureCode
162         *            The featureCode to set.
163         */
164        public void setFeatureCode(String featureCode) {
165                this.featureCode = featureCode;
166        }
167
168        /**
169         * latitude in decimal degrees (wgs84)
170         * 
171         * @return Returns the latitude.
172         */
173        public double getLatitude() {
174                return latitude;
175        }
176
177        /**
178         * @param latitude
179         *            The latitude to set.
180         */
181        public void setLatitude(double latitude) {
182                this.latitude = latitude;
183        }
184
185        /**
186         * longitude in decimal degrees (wgs84)
187         * 
188         * @return Returns the longitude.
189         */
190        public double getLongitude() {
191                return longitude;
192        }
193
194        /**
195         * @param longitude
196         *            The longitude to set.
197         */
198        public void setLongitude(double longitude) {
199                this.longitude = longitude;
200        }
201
202        /**
203         * @return Returns the name.
204         */
205        public String getName() {
206                return name;
207        }
208
209        /**
210         * @param name
211         *            The name to set.
212         */
213        public void setName(String name) {
214                this.name = name;
215        }
216
217        /**
218         * @return Returns the population.
219         */
220        public Long getPopulation() throws InsufficientStyleException {
221                if (population == null && style != null
222                                && Style.LONG.compareTo(style) > 0) {
223                        throw new InsufficientStyleException(
224                                        "population not supported by style " + style.name());
225                }
226                return population;
227        }
228
229        /**
230         * @param population
231         *            The population to set.
232         */
233        public void setPopulation(Long population) {
234                this.population = population;
235        }
236
237        /**
238         * @return Returns the geoNameId.
239         */
240        public int getGeoNameId() {
241                return geoNameId;
242        }
243
244        /**
245         * @param geoNameId
246         *            The geoNameId to set.
247         */
248        public void setGeoNameId(int geonameId) {
249                this.geoNameId = geonameId;
250        }
251
252        /**
253         * @return Returns the featureClassName.
254         */
255        public String getFeatureClassName() {
256                return featureClassName;
257        }
258
259        /**
260         * @param featureClassName
261         *            The featureClassName to set.
262         */
263        public void setFeatureClassName(String featureClassName) {
264                this.featureClassName = featureClassName;
265        }
266
267        /**
268         * @return Returns the featureCodeName.
269         */
270        public String getFeatureCodeName() {
271                return featureCodeName;
272        }
273
274        /**
275         * @param featureCodeName
276         *            The featureCodeName to set.
277         */
278        public void setFeatureCodeName(String featureCodeName) {
279                this.featureCodeName = featureCodeName;
280        }
281
282        /**
283         * @return Returns the countryName.
284         */
285        public String getCountryName() {
286                return countryName;
287        }
288
289        /**
290         * @param countryName
291         *            The countryName to set.
292         */
293        public void setCountryName(String countryName) {
294                this.countryName = countryName;
295        }
296
297        /**
298         * alternate names of this place as comma separated list
299         * 
300         * @return the alternateNames as comma separated list
301         */
302        public String getAlternateNames() throws InsufficientStyleException {
303                if (alternateNames == null && style != null
304                                && Style.LONG.compareTo(style) > 0) {
305                        throw new InsufficientStyleException(
306                                        "alternateNames not supported by style " + style.name());
307                }
308                return alternateNames;
309        }
310
311        /**
312         * @param alternateNames
313         *            the alternateNames to set
314         */
315        public void setAlternateNames(String alternateNames) {
316                this.alternateNames = alternateNames;
317        }
318
319        public String toString() {
320                StringBuilder str = new StringBuilder();
321                str.append("geoNameId=" + geoNameId + ",");
322                str.append("name=" + name + ",");
323                if (alternateNames != null) {
324                        str.append("alternateNames=" + alternateNames + ",");
325                }
326                str.append("latitude=" + latitude + ",");
327                str.append("longitude=" + longitude + ",");
328                str.append("countryCode=" + countryCode + ",");
329                str.append("population=" + population + ",");
330                str.append("elevation=" + elevation + ",");
331                str.append("featureClass=" + featureClass + ",");
332                str.append("featureCode=" + featureCode);
333                return str.toString();
334        }
335
336        /**
337         * @return the adminCode1
338         */
339        public String getAdminCode1() throws InsufficientStyleException {
340                if (adminCode1 == null && style != null
341                                && Style.LONG.compareTo(style) > 0) {
342                        throw new InsufficientStyleException(
343                                        "adminCode1 not supported by style " + style.name());
344                }
345                return adminCode1;
346        }
347
348        /**
349         * @param adminCode1
350         *            the adminCode1 to set
351         */
352        public void setAdminCode1(String adminCode1) {
353                this.adminCode1 = adminCode1;
354        }
355
356        /**
357         * @return the adminCode2
358         */
359        public String getAdminCode2() throws InsufficientStyleException {
360                if (adminCode2 == null && style != null
361                                && Style.LONG.compareTo(style) > 0) {
362                        throw new InsufficientStyleException(
363                                        "adminCode2 not supported by style " + style.name());
364                }
365                return adminCode2;
366        }
367
368        /**
369         * @param adminCode2
370         *            the adminCode2 to set
371         */
372        public void setAdminCode2(String adminCode2) {
373                this.adminCode2 = adminCode2;
374        }
375
376        /**
377         * @return the adminCode3
378         */
379        public String getAdminCode3() throws InsufficientStyleException {
380                if (adminCode3 == null && style != null
381                                && Style.LONG.compareTo(style) > 0) {
382                        throw new InsufficientStyleException(
383                                        "adminCode3 not supported by style " + style.name());
384                }
385                return adminCode3;
386        }
387
388        /**
389         * @param adminCode3
390         *            the adminCode3 to set
391         */
392        public void setAdminCode3(String adminCode3) {
393                this.adminCode3 = adminCode3;
394        }
395
396        /**
397         * @return the adminCode4
398         */
399        public String getAdminCode4() throws InsufficientStyleException {
400                if (adminCode4 == null && style != null
401                                && Style.LONG.compareTo(style) > 0) {
402                        throw new InsufficientStyleException(
403                                        "adminCode4 not supported by style " + style.name());
404                }
405                return adminCode4;
406        }
407
408        /**
409         * @param adminCode4
410         *            the adminCode4 to set
411         */
412        public void setAdminCode4(String adminCode4) {
413                this.adminCode4 = adminCode4;
414        }
415
416        /**
417         * @return the adminCode5
418         */
419        public String getAdminCode5() {
420                return adminCode5;
421        }
422
423        /**
424         * @param adminCode5
425         *            the adminCode5 to set
426         */
427        public void setAdminCode5(String adminCode5) {
428                this.adminCode5 = adminCode5;
429        }
430
431        /**
432         * @return the timezone
433         */
434        public Timezone getTimezone() throws InsufficientStyleException {
435                if (timezone == null && style != null
436                                && Style.LONG.compareTo(style) > 0) {
437                        throw new InsufficientStyleException(
438                                        "alternateNames not supported by style " + style.name());
439                }
440                return timezone;
441        }
442
443        /**
444         * @param timezone
445         *            the timezone to set
446         */
447        public void setTimezone(Timezone timezone) {
448                this.timezone = timezone;
449        }
450
451        /**
452         * @return the adminName1
453         */
454        public String getAdminName1() throws InsufficientStyleException {
455                if (adminName1 == null && style != null
456                                && Style.LONG.compareTo(style) > 0) {
457                        throw new InsufficientStyleException(
458                                        "adminName1 not supported by style " + style.name());
459                }
460                return adminName1;
461        }
462
463        /**
464         * @param adminName1
465         *            the adminName1 to set
466         */
467        public void setAdminName1(String adminName1) {
468                this.adminName1 = adminName1;
469        }
470
471        /**
472         * @return the adminName2
473         */
474        public String getAdminName2() throws InsufficientStyleException {
475                if (adminName2 == null && style != null
476                                && Style.LONG.compareTo(style) > 0) {
477                        throw new InsufficientStyleException(
478                                        "adminName2 not supported by style " + style.name());
479                }
480                return adminName2;
481        }
482
483        /**
484         * @param adminName2
485         *            the adminName2 to set
486         */
487        public void setAdminName2(String adminName2) {
488                this.adminName2 = adminName2;
489        }
490
491        /**
492         * @return the adminName3
493         */
494        public String getAdminName3() {
495                return adminName3;
496        }
497
498        /**
499         * @param adminName3
500         *            the adminName3 to set
501         */
502        public void setAdminName3(String adminName3) {
503                this.adminName3 = adminName3;
504        }
505
506        /**
507         * @return the adminName4
508         */
509        public String getAdminName4() {
510                return adminName4;
511        }
512
513        /**
514         * @param adminName4
515         *            the adminName4 to set
516         */
517        public void setAdminName4(String adminName4) {
518                this.adminName4 = adminName4;
519        }
520
521        /**
522         * @return the adminName5
523         */
524        public String getAdminName5() {
525                return adminName5;
526        }
527
528        /**
529         * @param adminName5
530         *            the adminName5 to set
531         */
532        public void setAdminName5(String adminName5) {
533                this.adminName5 = adminName5;
534        }
535
536        /**
537         * @return the style used when calling the web service that returned this
538         *         toponym.
539         */
540        public Style getStyle() {
541                return style;
542        }
543
544        /**
545         * @param style
546         *            the style to set
547         */
548        public void setStyle(Style style) {
549                this.style = style;
550        }
551        
552        /**
553         * @return the boundingBox 
554         */
555        public BoundingBox getBoundingBox() {
556                return boundingBox;
557        }
558
559        /**
560         * @param boundingBox
561         *            the boundingBox to set
562         */
563        public void setBoundingBox(BoundingBox boundingBox) {
564                this.boundingBox = boundingBox;
565        }
566
567}