postalcode
Class CanadianPostalCode

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

public class CanadianPostalCode
extends PostalCode

This class is a subclass of PostalCode used to deal with Canadian postal codes.


Fields inherited from class postalcode.PostalCode
code, destination, hasBeenValidated, isValid
 
Constructor Summary
CanadianPostalCode(java.lang.String code)
          Constructs a Canadian postal code object.
 
Method Summary
private  java.lang.String computeDestination()
          This method will return the destination of the postal code.
 java.lang.String getCountry()
          Returns the country of origin of the code.
protected  void validate()
          This method will verifiy the validity of 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

CanadianPostalCode

public CanadianPostalCode(java.lang.String code)
                   throws PostalCodeException
Constructs a Canadian postal code object.
Parameters:
code - The code to be analysed.
Method Detail

getCountry

public java.lang.String getCountry()
Returns the country of origin of the 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 will verifiy the validity of the postal code.
Throws:
PostalCodeException - If the code is found to be invalid.
Overrides:
validate in class PostalCode

computeDestination

private java.lang.String computeDestination()
                                     throws PostalCodeException
This method will return the destination of the postal code.
Throws:
PostalCodeException - If the code has an invalid letter to indicate a destination.