Source code for PhoneRegion.java

package PhoneApp.Data;

/**
 * Manages all information associated with a Phone Region. A
 * phone region corresponds to an area code, and includes city,
 * province/state and country information for that area code.
 *
 * @version $Date: 2001/06/25 $
 * @author  Steve Franklin
 * @since   jdk 1.3.1
 */

class PhoneRegion extends DataObject {

 /**
  * Creates a new object based on the supplied information
  */
  public PhoneRegion(String newAreaCode, String newCity, String newProvince, String newCountry) {
    boolean success = true;
    success = success && testString(newAreaCode, VERIFY_TEXT, VERIFY_MANDATORY, 11);
    success = success && testString(newCity, VERIFY_TEXT, VERIFY_MANDATORY, 100);
    success = success && testString(newProvince, VERIFY_TEXT, VERIFY_MANDATORY, 30);
    success = success && testString(newCountry, VERIFY_TEXT, VERIFY_MANDATORY, 50);
    if ( success ) {
      areaCode = newAreaCode;
      city = newCity;
      province = newProvince;
      country = newCountry;
    }
  }

  public String getAreaCode() {
    return areaCode;
  }
  
  /** Converts the contents of the object to a human-readable string. */
  public String toString() {
    String s = "";

    s += "(" + areaCode + ") " + city + ", " + province + ", " + country;

    return s;
  }

  /** Area Code for the region, of the form ### */
  private String areaCode;

  /** City corresponding to the area code (obviously flawed - some area codes span cities) */
  private String city;

  /** Province or state for the area code (again, often a flawed assumption) */
  private String province;

  /** Country corresponding to the area code */
  private String country;
}