postalcode
Class USZipCode

java.lang.Object
  |
  +--postalcode.PostalCode
        |
        +--postalcode.USZipCode

public class USZipCode
extends PostalCode

This class is a subclass of PostalCode used to handle and verify US ZIP codes.


Fields inherited from class postalcode.PostalCode
code, destination, hasBeenValidated, isValid
 
Constructor Summary
USZipCode(java.lang.String code)
          Constructs a ZIP Code type object.
 
Method Summary
private  java.lang.String computeDestination()
          This method will return a String indicating the location of the destination address.
 java.lang.String getCountry()
          This method returns the country of origin of this code.
protected  void validate()
          This method validates the postal code.
 
Methods inherited from class postalcode.PostalCode
getCode, getDestination, isValid, setDestination, throwException, toString
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Constructor Detail

USZipCode

public USZipCode(java.lang.String code)
          throws PostalCodeException
Constructs a ZIP Code type object. Calls the superclass constructor.
Parameters:
code - The postal code to be analysed.
Method Detail

getCountry

public java.lang.String getCountry()
This method returns the country of origin of this code.
Returns:
A String containing the country of origin of the code.
Overrides:
getCountry in class PostalCode

validate

protected void validate()
                 throws PostalCodeException
This method validates the postal code.
Throws:
PostalCodeException - If the code is invalid.
Overrides:
validate in class PostalCode

computeDestination

private java.lang.String computeDestination()
This method will return a String indicating the location of the destination address. 10 character codes have destinations in major cities, while 5 character codes have destination in minor cities.
Returns:
A String indicating the size of the city where the destination is located.