/* * (C) 2004 - Geotechnical Software Services * * This code is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This code is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. */ package no.geosoft.cc.country; /** * Class reprenting a country (according to ISO 3166-1). The class consist * of both ISO code and name, where name is a localized version of the * official country name. * * @see CountryManager * * @author <a href="mailto:info@geosoft.no">GeoSoft</a> */ public class Country implements Comparable { private String isoCode_; private String name_; private String shortName_; /** * Create a country instance with given ISO code. * * @param isoCode ISO code of country. */ public Country (String isoCode) { isoCode_ = isoCode; } /** * Create a copy of the country instance specified. * * @param country Country to copy. */ public Country (Country country) { isoCode_ = country.isoCode_; name_ = country.name_; shortName_ = country.shortName_; } /** * Retur ISO code of this country. * * @return */ public String getIsoCode() { return isoCode_; } /** * Return localized name of this country. * * @return Localized name of this country. */ public String getName() { return name_; } /** * Set localized name of this country. * * @param name Localized name of this country. */ public void setName (String name) { name_ = name; } /** * Return localized short name of this country. * * @return Localized short name of this country. */ public String getShortName() { return shortName_; } /** * Set localized short name of this country. * * @param shortName Localized short name of this country. */ public void setShortName (String shortName) { shortName_ = shortName; } /** * Retrun a string representation of this country. * * @return String representation of this country. */ public String toString() { return name_; } /** * Lexiographically compare this country to the specified object. * * @param object Country to compare to. * @return A negative integer, zero, or a positive integer as this * object is less than, equal to, or greater than the * specified object. * @see Comparable */ public int compareTo (Object object) { Country country = (Country) object; return name_.compareTo (country.name_); } /** * Return hash code for this object. * * @return Hash code for this object. */ public int hashCode() { return isoCode_.hashCode(); } /** * Check if this object equals the specified object. * * @param object Object to compare to. * @return True if this equals to the specified object, * false otherwise. */ public boolean equals (Object object) { if (object == null) return false; if (!(object instanceof Country)) return false; return ((Country) object).isoCode_.equals (isoCode_); } }