/** * the slash separated name that includes all the superstate names. */ public String getFullyQualifiedName() { return superState != null ? superState.getFullyQualifiedName() + '/' + name : name; }
public boolean hasNode(String name) { return getNodesMap().containsKey(name); }
public ProcessDefinition getProcessDefinition() { return superState != null ? superState.getProcessDefinition() : processDefinition; }
/** * collect all superstates of a that do not contain node b. */ static List collectAllSuperStates(Node a, Node b) { SuperState superState = a.getSuperState(); List leavingSuperStates = new ArrayList(); while (superState != null) { if (!superState.containsNode(b)) { leavingSuperStates.add(superState); superState = superState.getSuperState(); } else { superState = null; } } return leavingSuperStates; }
/** * recursively checks if the given node is one of the descendants of this * supernode. */ public boolean containsNode(Node node) { boolean containsNode = false; SuperState parent = node.getSuperState(); while ((!containsNode) && (parent != null)) { if (this.equals(parent)) { containsNode = true; } else { parent = parent.getSuperState(); } } return containsNode; }
/** * updates the name of this node */ public void setName(String name) { if (isDifferent(this.name, name)) { String oldName = this.name; if (superState != null) { if (superState.hasNode(name)) { throw new IllegalArgumentException("Super state '" + superState + "' already has a node named " + name); } Map nodes = superState.getNodesMap(); nodes.remove(oldName); nodes.put(name, this); } else if (processDefinition != null) { if (processDefinition.hasNode(name)) { throw new IllegalArgumentException("Process definition '" + processDefinition + "' contains two nodes with name " + name); } Map nodeMap = processDefinition.getNodesMap(); nodeMap.remove(oldName); nodeMap.put(name, this); } this.name = name; } }
/** * tells whether this node lacks leaving transitions. */ public boolean hasNoLeavingTransitions() { return (leavingTransitions == null || leavingTransitions.isEmpty()) && (superState == null || superState.hasNoLeavingTransitions()); }
/** * fires the give event on all the superstates in the list. */ void fireSuperStateEvents(List superStates, String eventType, ExecutionContext executionContext) { for (Iterator iter = superStates.iterator(); iter.hasNext();) { SuperState leavingSuperState = (SuperState) iter.next(); leavingSuperState.fireEvent(eventType, executionContext); } }
/** * retrieves a leaving transition by name. the leaving transitions of the supernode are taken * into account as well. */ public Transition getLeavingTransition(String transitionName) { if (leavingTransitions != null) { for (Iterator i = leavingTransitions.iterator(); i.hasNext();) { Transition transition = (Transition) i.next(); if (transitionName != null ? transitionName.equals(transition.getName()) : transition.getName() == null) return transition; } } return superState != null ? superState.getLeavingTransition(transitionName) : null; }
/** * is the default leaving transition. */ public Transition getDefaultLeavingTransition() { if (leavingTransitions != null && !leavingTransitions.isEmpty()) { // select the first unconditional transition for (Iterator i = leavingTransitions.iterator(); i.hasNext();) { Transition transition = (Transition) i.next(); if (transition.getCondition() == null) return transition; } // there is no unconditional transition, just pick the first one return (Transition) leavingTransitions.get(0); } else if (superState != null) { return superState.getDefaultLeavingTransition(); } return null; }
/** * collect all superstates of a that do not contain node b. */ static List collectAllSuperStates(Node a, Node b) { SuperState superState = a.getSuperState(); List leavingSuperStates = new ArrayList(); while (superState != null) { if (!superState.containsNode(b)) { leavingSuperStates.add(superState); superState = superState.getSuperState(); } else { superState = null; } } return leavingSuperStates; }
/** * recursively checks if the given node is one of the descendants of this * supernode. */ public boolean containsNode(Node node) { boolean containsNode = false; SuperState parent = node.getSuperState(); while ((!containsNode) && (parent != null)) { if (this.equals(parent)) { containsNode = true; } else { parent = parent.getSuperState(); } } return containsNode; }
/** * updates the name of this node */ public void setName(String name) { if (isDifferent(this.name, name)) { String oldName = this.name; if (superState != null) { if (superState.hasNode(name)) { throw new IllegalArgumentException("cannot rename " + this + " because " + superState + " already has a node named " + name); } Map nodes = superState.getNodesMap(); nodes.remove(oldName); nodes.put(name, this); } else if (processDefinition != null) { if (processDefinition.hasNode(name)) { throw new IllegalArgumentException("cannot rename " + this + " because " + processDefinition + " already has a node named " + name); } Map nodeMap = processDefinition.getNodesMap(); nodeMap.remove(oldName); nodeMap.put(name, this); } this.name = name; } }
/** * tells whether this node lacks leaving transitions. */ public boolean hasNoLeavingTransitions() { return (leavingTransitions == null || leavingTransitions.isEmpty()) && (superState == null || superState.hasNoLeavingTransitions()); }
/** * fires the give event on all the superstates in the list. */ void fireSuperStateEvents(List superStates, String eventType, ExecutionContext executionContext) { for (Iterator iter = superStates.iterator(); iter.hasNext();) { SuperState leavingSuperState = (SuperState) iter.next(); leavingSuperState.fireEvent(eventType, executionContext); } }
/** * retrieves a leaving transition by name. the leaving transitions of the supernode are taken * into account as well. */ public Transition getLeavingTransition(String transitionName) { if (leavingTransitions != null) { for (Iterator i = leavingTransitions.iterator(); i.hasNext();) { Transition transition = (Transition) i.next(); if (transitionName != null ? transitionName.equals(transition.getName()) : transition.getName() == null) return transition; } } return superState != null ? superState.getLeavingTransition(transitionName) : null; }
/** * is the default leaving transition. */ public Transition getDefaultLeavingTransition() { if (leavingTransitions != null && !leavingTransitions.isEmpty()) { // select the first unconditional transition for (Iterator i = leavingTransitions.iterator(); i.hasNext();) { Transition transition = (Transition) i.next(); if (transition.getCondition() == null) return transition; } // there is no unconditional transition, just pick the first one return (Transition) leavingTransitions.get(0); } else if (superState != null) { return superState.getDefaultLeavingTransition(); } return null; }
public Node getNode(String name) { return (Node) getNodesMap().get(name); }
/** * the slash separated name that includes all the superstate names. */ public String getFullyQualifiedName() { return superState != null ? superState.getFullyQualifiedName() + '/' + name : name; }
public ProcessDefinition getProcessDefinition() { return superState != null ? superState.getProcessDefinition() : processDefinition; }