1/* 2 * PostalCodeEntry.java 3 * Copyright (C) 2006 Amin Ahmad 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 */ 19package org.ahmadsoft.postal; 20 21/** 22 * Represents a USPS recognized city, state, postal code combination. Instances 23 * of this class are immutable. 24 * 25 * @author Amin Ahmad 26 */ 27public class PostalCodeEntry { 28 private int postalCode; 29 private String state; 30 private String city; 31 private int entryType; 32 33 /** 34 * Constructs a new postal code entry. 35 * 36 * @param postalCode the postal code. 37 * @param city the city name. 38 * @param state the state. 39 * @param type the type of entry. 40 */ 41 public PostalCodeEntry(int postalCode, String city, String state, int type) { 42 super(); 43 this.city = city; 44 entryType = type; 45 this.postalCode = postalCode; 46 this.state = state; 47 } 48 49 /** 50 * Returns the city associated with this entry. 51 * @return the city associated with this entry. 52 */ 53 public String getCity() { 54 return city; 55 } 56 57 /** 58 * Returns the type of this entry. <code><a href="PostalCodeConstants.html">PostalCodeConstants.CITY*</a></code> 59 * fully enumerates the valid values for this entry. 60 * 61 * @return the type of this entry. 62 */ 63 public int getEntryType() { 64 return entryType; 65 } 66 67 /** 68 * Returns the postal code associated with this entry. 69 * @return the postal code associated with this entry. 70 */ 71 public int getPostalCode() { 72 return postalCode; 73 } 74 75 /** 76 * Returns the two-letter abbreviation for the state associated 77 * with this entry. All valid two-letter abbreviations are 78 * enumerated in <a href="http://www.usps.com/ncsc/lookups/usps_abbreviations.html"> 79 * Official USPS Abbreviations</a>. 80 * @return the two-letter abbreviation for the state associated 81 * with this entry. 82 */ 83 public String getState() { 84 return state; 85 } 86 87 /** 88 * @inheritDoc 89 */ 90 public String toString() { 91 return getCity() + ", " + getState() + " " + getPostalCode() + " [" + PostalCodeConstants.toString(getEntryType()) + "]"; 92 } 93} 94