A.1 Session Bean Helper Classes

The following four code samples show the helper classes defined for the Enrollment session bean.

Code Example A.1 Definition of Helper Classes
 package com.star.benefits; public class EmployeeInfo implements java.io.Serializable {    int employeeNumber;    String firstName;    String lastName;    public EmployeeInfo() { }    public EmployeeInfo(int emplnum, String fname, String lname) {       employeeNumber = emplnum;       firstName = fname;       lastName = lname;    }    public int getEmployeeNumber() { return employeeNumber; }    public String getFirstName() { return firstName; }    public String getLastName() { return lastName; }    public void setEmployeeNumber(int val) { employeeNumber = val; }    public void setFirstName(String val) { firstName = val; }    public void setLastName(String val) { lastName = val; } } package com.star.benefits; public class Options implements java.io.Serializable {    String[] optionDescription;    double[] optionCost;    int selectedOption;    int size;    public Options() {       size = 0;       selectedOption = -1;    }    public Options(int size) {       this.size = size;       optionDescription = new String[size];       optionCost = new double[size];       selectedOption = -1;    }    public String getOptionDescription(int i) {       return optionDescription[i];    }    public void setOptionDescription(int i, String val) {       optionDescription[i] = val;    }    public String[] getOptionDescription() {       return optionDescription;    }    public void setOptionDescription(String[] vals) {       optionDescription = vals;    }    public double getOptionCost(int i) {       return optionCost[i];    }    public void setOptionCost(int i, double val) {       optionCost[i] = val;    }    public double[] getOptionCost() {       return optionCost;    }    public int getSelectedOption() {       return selectedOption;    }    public void setSelectedOption(int val) {       selectedOption = val;    }    public int getSize() {       return size;    } } package com.star.benefits; public class Summary implements java.io.Serializable {    String coverageOption;    String medicalOption;    String dentalOption;    double medicalOptionCost;    double dentalOptionCost;    double totalCost;    double payrollDeduction;    boolean smokerStatus;    public Summary() { }    public String getCoverageDescription() {       return coverageOption;    }    public void setCoverageDescription(String s) {       coverageOption = s;    }    public String getMedicalDescription() {       return medicalOption;    }    public void setMedicalDescription(String s) {       medicalOption = s;    }    public String getDentalDescription() {       return dentalOption;    }    public void setDentalDescription(String s) {       dentalOption = s;    }    public double getMedicalCost() {       return medicalOptionCost;    }    public void setMedicalCost(double c) {       medicalOptionCost = c;    }    public double getDentalCost() {       return dentalOptionCost;    }    public void setDentalCost(double c) {       dentalOptionCost = c;    }    public double getTotalCost() {       return totalCost;    }    public void setTotalCost(double c) {       totalCost = c;    }    public void setPayrollDeduction(double c) {       payrollDeduction = c;    }    public double getPayrollDeduction() {       return payrollDeduction;    }    public boolean getSmokerStatus() {       return smokerStatus;    }    public void setSmokerStatus(boolean s) {       smokerStatus  = s;    } } package com.star.benefits; public class EnrollmentException extends Exception {    // error codes    public static int UNKNOWN = 0;    public static int INVAL_PARAM = 1;    static String[] defaultMessage = {       "unknown error code",       "invalid value of input parameter"    };    private int errorCode;    public EnrollmentException() {       super();    }    public EnrollmentException(String s) {       super(s);    }    public EnrollmentException(int errorCode, String s) {       super(s);       this.errorCode = errorCode;    }    public EnrollmentException(int errorCode) {       super(errorCode >= 0 && errorCode < defaultMessage.length ?          defaultMessage[errorCode] : "");       this.errorCode = errorCode;    } } 


Applying Enterprise Javabeans
Applying Enterprise JavaBeans(TM): Component-Based Development for the J2EE(TM) Platform
ISBN: 0201702673
EAN: 2147483647
Year: 2003
Pages: 110

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net