001    /*-----------------------------------------------------------------------
002     *  Copyright (C) 2006
003     *  Associated Universities, Inc. Washington DC, USA.
004     *  This program is free software; you can redistribute it and/or
005     *  modify it under the terms of the GNU General Public License as
006     *  published by the Free Software Foundation; either version 2 of
007     *  the License, or (at your option) any later version.
008     *
009     *  This program is distributed in the hope that it will be useful,
010     *  but WITHOUT ANY WARRANTY; without even the implied warranty of
011     *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012     *  GNU General Public License for more details.
013     *
014     *  Correspondence concerning this software should be addressed as follows:
015     *         Internet email: switz@nrao.edu
016     *         Postal address: User Database
017     *                         National Radio Astronomy Observatory
018     *                         Post Office Box 0
019     *                         Socorro, NM 87801  USA
020     *-----------------------------------------------------------------------*/
021    package edu.nrao.sss.model.user;
022    
023    import edu.nrao.sss.xml.XMLTransform;
024    
025    public class AddressCountry extends ObjectId implements XMLable {
026    
027            private static final long serialVersionUID = 1L;
028    
029            private String addressCountry;
030    
031            private String countryName;
032    
033            private boolean hasPostalCodes;
034    
035            public boolean equals(Object obj) {
036                    if (null == obj)
037                            return false;
038                    if (!(obj instanceof AddressCountry))
039                            return false;
040                    else {
041                            AddressCountry mObj = (AddressCountry) obj;
042                            return (this.getId() == mObj.getId());
043                    }
044            }
045    
046            public java.lang.String getAddressCountry() {
047                    return addressCountry;
048            }
049    
050            public String getCountryName() {
051                    return countryName;
052            }
053    
054            public boolean hasUsingPostalCodes() {
055                    return hasPostalCodes;
056            }
057    
058            public boolean isDomestic() {
059                    if (addressCountry != null
060                                    && addressCountry.equalsIgnoreCase("United States")
061                                    || addressCountry.equals("USA"))
062                            return true;
063                    return false;
064            }
065    
066            public void setAddressCountry(java.lang.String addressCountry) {
067                    this.addressCountry = addressCountry;
068            }
069    
070            public void setCountryName(String countryName) {
071                    this.countryName = countryName;
072            }
073    
074            public void setHasPostalCodes(boolean hasPostalCodes) {
075                    this.hasPostalCodes = hasPostalCodes;
076            }
077    
078            public String toXML() {
079                    return "<country>" + XMLTransform.encode(getAddressCountry())
080                                    + "</country>\n";
081            }
082    }