You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2003/05/28 17:33:15 UTC
cvs commit: cocoon-lenya/src/java/org/apache/lenya/cms/workflow/impl WorkflowImpl.java
andreas 2003/05/28 08:33:15
Modified: src/java/org/apache/lenya/cms/workflow/impl
WorkflowImpl.java
Log:
added containsState(State)
Revision Changes Path
1.3 +32 -13 cocoon-lenya/src/java/org/apache/lenya/cms/workflow/impl/WorkflowImpl.java
Index: WorkflowImpl.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/workflow/impl/WorkflowImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WorkflowImpl.java 24 Apr 2003 13:53:00 -0000 1.2
+++ WorkflowImpl.java 28 May 2003 15:33:15 -0000 1.3
@@ -16,16 +16,15 @@
*
* @author andreas
*/
-public class WorkflowImpl
- implements Workflow {
-
+public class WorkflowImpl implements Workflow {
+
/** Creates a new instance of WorkflowImpl */
public WorkflowImpl(State initialState) {
this.initialState = initialState;
}
-
+
private State initialState;
-
+
/** Returns the initial state of this workflow.
* @return The initial state.
*
@@ -33,9 +32,9 @@
public State getInitialState() {
return initialState;
}
-
+
private Set transitions = new HashSet();
-
+
/**
* Adds a transition.
*/
@@ -43,11 +42,12 @@
assert transition != null;
transitions.add(transition);
}
-
+
protected TransitionImpl[] getTransitions() {
- return (TransitionImpl[]) transitions.toArray(new TransitionImpl[transitions.size()]);
+ return (TransitionImpl[]) transitions.toArray(
+ new TransitionImpl[transitions.size()]);
}
-
+
/** Returns the destination state of a transition.
* @param transition A transition.
* @return The destination state.
@@ -57,7 +57,7 @@
assert transition instanceof TransitionImpl;
return ((TransitionImpl) transition).getDestination();
}
-
+
/** Returns the transitions that leave a state.
* @param state A state.
* @return The transitions that leave the state.
@@ -71,7 +71,26 @@
leavingTransitions.add(transitions[i]);
}
}
- return (Transition[]) leavingTransitions.toArray(new Transition[leavingTransitions.size()]);
+ return (Transition[]) leavingTransitions.toArray(
+ new Transition[leavingTransitions.size()]);
}
-
+
+ /**
+ * Checks if this workflow contains a state.
+ * @param state The state to check.
+ * @return <code>true</code> if the state is contained, <code>false</code> otherwise.
+ */
+ protected boolean containsState(State state) {
+ Transition transitions[] = getTransitions();
+ boolean result = false;
+ for (int i = 0; i < transitions.length; i++) {
+ TransitionImpl transition = (TransitionImpl) transitions[i];
+ if (transition.getSource().equals(state)
+ || transition.getDestination().equals(state)) {
+ result = true;
+ }
+ }
+ return result;
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org