craigmcc 01/08/13 16:15:23
Modified: workflow/src/java/org/apache/commons/workflow Activity.java
workflow/src/java/org/apache/commons/workflow/base
BaseActivity.java
Log:
Add another way to initialize the set of Steps associated with an
Activity.
Submitted by: Jon Stevens <[EMAIL PROTECTED]>
Revision Changes Path
1.2 +25 -4
jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Activity.java
Index: Activity.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Activity.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Activity.java 2001/08/13 21:15:03 1.1
+++ Activity.java 2001/08/13 23:15:23 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Activity.java,v
1.1 2001/08/13 21:15:03 craigmcc Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/13 21:15:03 $
+ * $Header:
/home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Activity.java,v
1.2 2001/08/13 23:15:23 craigmcc Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/08/13 23:15:23 $
*
* ====================================================================
*
@@ -69,7 +69,7 @@
* within the <code>execute()</code> method of a <code>Context</code> that
* is utilizing this <code>Activity</code> definition.</p>
*
- * @version $Revision: 1.1 $ $Date: 2001/08/13 21:15:03 $
+ * @version $Revision: 1.2 $ $Date: 2001/08/13 23:15:23 $
* @author Craig R. McClanahan
*/
@@ -101,6 +101,27 @@
* @param step The new step to be added
*/
public void addStep(Step step);
+
+
+ /**
+ * Clear any existing Steps associated with this Activity.
+ */
+ public void clear();
+
+
+ /**
+ * Return the set of Steps associated with this Activity.
+ */
+ public Step[] getSteps();
+
+
+ /**
+ * Set the set of Steps associated with this Activity, replacing any
+ * existing ones.
+ *
+ * @param steps The new set of steps.
+ */
+ public void setSteps(Step steps[]);
}
1.2 +48 -4
jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseActivity.java
Index: BaseActivity.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseActivity.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BaseActivity.java 2001/08/13 21:16:01 1.1
+++ BaseActivity.java 2001/08/13 23:15:23 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseActivity.java,v
1.1 2001/08/13 21:16:01 craigmcc Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/13 21:16:01 $
+ * $Header:
/home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseActivity.java,v
1.2 2001/08/13 23:15:23 craigmcc Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/08/13 23:15:23 $
*
* ====================================================================
*
@@ -62,6 +62,7 @@
package org.apache.commons.workflow.base;
+import java.util.ArrayList;
import org.apache.commons.workflow.Activity;
import org.apache.commons.workflow.Step;
@@ -72,7 +73,7 @@
* management of the static relationships of Steps to each other as part
* of an owning Activity.</p>
*
- * @version $Revision: 1.1 $ $Date: 2001/08/13 21:16:01 $
+ * @version $Revision: 1.2 $ $Date: 2001/08/13 23:15:23 $
* @author Craig R. McClanahan
*/
@@ -139,6 +140,49 @@
lastStep.setNextStep(step);
lastStep = step;
}
+
+ }
+
+
+ /**
+ * Clear any existing Steps associated with this Activity.
+ */
+ public void clear() {
+
+ firstStep = null;
+ lastStep = null;
+
+ }
+
+
+ /**
+ * Return the set of Steps associated with this Activity.
+ */
+ public Step[] getSteps() {
+
+ ArrayList list = new ArrayList();
+ Step currentStep = firstStep;
+ while (currentStep != null) {
+ list.add(currentStep);
+ currentStep = currentStep.getNextStep();
+ }
+ Step steps[] = new Step[list.size()];
+ return ((Step[]) list.toArray(steps));
+
+ }
+
+
+ /**
+ * Set the set of Steps associated with this Activity, replacing any
+ * existing ones.
+ *
+ * @param steps The new set of steps.
+ */
+ public void setSteps(Step steps[]) {
+
+ clear();
+ for (int i = 0; i < steps.length; i++)
+ addStep(steps[i]);
}