package edu.ucsb.cs.jicos.services.tasks; import edu.ucsb.cs.jicos.services.*; /** A compositional Task, whose inputs & output are Integer. */ public final class AddInteger extends Task { /** This method's returned value is the Integer whose intValue is the sum * of the intValues of its Integer inputs. * @return the Integer whose intValue is the sum of the intValues of its Integer inputs. * @param environment Not used by this Task. */ public Object execute ( Environment environment ) { int sum = 0; for ( int i = 0; i < numInputs(); i++ ) { sum += ((Integer) getInput( i )).intValue(); } return new Integer( sum ); } /** This task executes on the task server. * @param environment Session environment (ignored). * @return true: This task executes on the task server. */ public boolean executeOnServer( Environment environment ) { return true; } }