/* * PostalCodeEntry.java * Copyright (C) 2006 Amin Ahmad * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package org.ahmadsoft.postal; /** * Represents a USPS recognized city, state, postal code combination. Instances * of this class are immutable. * * @author Amin Ahmad */ public class PostalCodeEntry { private int postalCode; private String state; private String city; private int entryType; /** * Constructs a new postal code entry. * * @param postalCode the postal code. * @param city the city name. * @param state the state. * @param type the type of entry. */ public PostalCodeEntry(int postalCode, String city, String state, int type) { super(); this.city = city; entryType = type; this.postalCode = postalCode; this.state = state; } /** * Returns the city associated with this entry. * @return the city associated with this entry. */ public String getCity() { return city; } /** * Returns the type of this entry. PostalCodeConstants.CITY* * fully enumerates the valid values for this entry. * * @return the type of this entry. */ public int getEntryType() { return entryType; } /** * Returns the postal code associated with this entry. * @return the postal code associated with this entry. */ public int getPostalCode() { return postalCode; } /** * Returns the two-letter abbreviation for the state associated * with this entry. All valid two-letter abbreviations are * enumerated in * Official USPS Abbreviations. * @return the two-letter abbreviation for the state associated * with this entry. */ public String getState() { return state; } /** * @inheritDoc */ public String toString() { return getCity() + ", " + getState() + " " + getPostalCode() + " [" + PostalCodeConstants.toString(getEntryType()) + "]"; } }