campus.compass
Class ZipCodeSource

java.lang.Object
  |
  +--campus.compass.ZipCodeSource

public class ZipCodeSource
extends java.lang.Object

Given a zip code, determine associated city/state, or vice versa.

Version:
$Id: ZipCodeSource.java,v 1.2 2003/09/08 05:22:45 glchen Exp $
Author:
Guanling Chen

Field Summary
protected static java.util.Hashtable _region
           
static java.util.Hashtable _state
           
protected static java.util.Hashtable _zipcode
           
 
Constructor Summary
ZipCodeSource()
           
 
Method Summary
private static java.lang.String decodeCity(java.lang.String region)
          Decode city from region represtation.
private static java.lang.String decodeState(java.lang.String region)
          Decode state from region represtation.
private static java.lang.String encodeRegion(java.lang.String city, java.lang.String state)
          Encode city and state into region representation.
static java.lang.String getCity(java.lang.String zipcode)
          Return the city for specified zipcode.
static java.lang.String getRegion(java.lang.String zipcode)
          Return the region (city and state) for specified zipcode.
static java.lang.String getState(java.lang.String zipcode)
          Return the state for specified zipcode.
static java.lang.String getStateAbbr(java.lang.String name)
          Get abbr name of a state for specified full name.
static java.lang.String getStateName(java.lang.String abbr)
          Get full name of a state for specified abbreviation.
static java.lang.String getZipCode(java.lang.String city, java.lang.String state)
          Return the zipcode for specified region (city and state).
private static void initStateMapping()
          Init state name to abbrev mapping.
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_state

public static java.util.Hashtable _state

_region

protected static java.util.Hashtable _region

_zipcode

protected static java.util.Hashtable _zipcode
Constructor Detail

ZipCodeSource

public ZipCodeSource()
Method Detail

getZipCode

public static java.lang.String getZipCode(java.lang.String city,
                                          java.lang.String state)
                                   throws java.lang.Exception
Return the zipcode for specified region (city and state).

java.lang.Exception

getRegion

public static java.lang.String getRegion(java.lang.String zipcode)
                                  throws java.lang.Exception
Return the region (city and state) for specified zipcode.

java.lang.Exception

getCity

public static java.lang.String getCity(java.lang.String zipcode)
                                throws java.lang.Exception
Return the city for specified zipcode.

java.lang.Exception

getState

public static java.lang.String getState(java.lang.String zipcode)
                                 throws java.lang.Exception
Return the state for specified zipcode.

java.lang.Exception

encodeRegion

private static java.lang.String encodeRegion(java.lang.String city,
                                             java.lang.String state)
Encode city and state into region representation.


decodeCity

private static java.lang.String decodeCity(java.lang.String region)
Decode city from region represtation.


decodeState

private static java.lang.String decodeState(java.lang.String region)
Decode state from region represtation.


getStateName

public static java.lang.String getStateName(java.lang.String abbr)
Get full name of a state for specified abbreviation.


getStateAbbr

public static java.lang.String getStateAbbr(java.lang.String name)
Get abbr name of a state for specified full name.


initStateMapping

private static void initStateMapping()
Init state name to abbrev mapping.


main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
java.lang.Exception