/** * Recipe: Iterating a View object using a secondary RowSet iterator. * * <p>Adjusts all the employees commission by a certain percentage. * * @param commissionPctAdjustment, the commission percent adjustment */ public void adjustCommission(Number commissionPctAdjustment) { // check for valid commission adjustment if (commissionPctAdjustment != null) { // create an employee secondary RowSet iterator RowSetIterator employees = this.createRowSetIterator(null); // reset the iterator employees.reset(); // iterate the employees while (employees.hasNext()) { // get the employee EmployeesRowImpl employee = (EmployeesRowImpl) employees.next(); // check for employee belonging to the sales department if (employee.getDepartmentId() != null && SALES_DEPARTMENT_ID == employee.getDepartmentId().intValue()) { // calculate adjusted commission Number commissionPct = employee.getCommissionPct(); Number adjustedCommissionPct = (commissionPct != null) ? commissionPct.add(commissionPctAdjustment) : commissionPctAdjustment; // set the employee's new commission employee.setCommissionPct(adjustedCommissionPct); } } // done with the RowSet iterator employees.closeRowSetIterator(); } }
public void put(EmployeesRowImpl obj, Object value) { obj.setCommissionPct((Number) value); }