You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by at...@apache.org on 2014/03/14 00:22:38 UTC

svn commit: r1577373 - in /commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2: SCXMLExecutor2.java semantics/SCXMLSemanticsImpl2.java

Author: ate
Date: Thu Mar 13 23:22:38 2014
New Revision: 1577373

URL: http://svn.apache.org/r1577373
Log:
SCXML-196: reshuffling class methods and members in more logical order (at least to me) and fix or suppress IntelliJ warnings (I like 'green')

Modified:
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutor2.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/semantics/SCXMLSemanticsImpl2.java

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutor2.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutor2.java?rev=1577373&r1=1577372&r2=1577373&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutor2.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutor2.java Thu Mar 13 23:22:38 2014
@@ -16,7 +16,6 @@
  */
 package org.apache.commons.scxml2;
 
-import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -47,6 +46,7 @@ import org.apache.commons.scxml2.system.
  *
  * @see org.apache.commons.scxml2.SCXMLSemantics
  */
+@SuppressWarnings("unused,deprecation") // TODO: remove when done refactoring
 public class SCXMLExecutor2 extends SCXMLExecutor {
 
     /**
@@ -55,6 +55,28 @@ public class SCXMLExecutor2 extends SCXM
     private static final long serialVersionUID = 1L;
 
     /**
+     * The special variable for storing single event data / payload.
+     * @deprecated
+     */
+    private static final String EVENT_DATA = "_eventdata";
+
+    /**
+     * The special variable for storing event data / payload,
+     * when multiple events are triggered, keyed by event name.
+     */
+    private static final String EVENT_DATA_MAP = "_eventdatamap";
+
+    /**
+     * The special variable for storing single event data / payload.
+     */
+    private static final String EVENT_VARIABLE = "_event";
+
+    /**
+     * SCXMLExecutor put into motion without setting a model (state machine).
+     */
+    private static final String ERR_NO_STATE_MACHINE = "SCXMLExecutor: State machine not set";
+
+    /**
      * The Logger for the SCXMLExecutor.
      */
     private Log log = LogFactory.getLog(SCXMLExecutor2.class);
@@ -95,71 +117,10 @@ public class SCXMLExecutor2 extends SCXM
     private SCInstance scInstance;
 
     /**
-     * The worker method.
-     * Re-evaluates current status whenever any events are triggered.
-     *
-     * @param evts
-     *            an array of external events which triggered during the last
-     *            time quantum
-     * @throws org.apache.commons.scxml2.model.ModelException in case there is a fatal SCXML object
-     *            model problem.
-     */
-    public synchronized void triggerEvents(final TriggerEvent[] evts)
-            throws ModelException {
-        // Set event data, saving old values
-        Object[] oldData = setEventData(evts);
-
-        // Forward events (external only) to any existing invokes,
-        // and finalize processing
-        semantics.processInvokes(evts, errorReporter, scInstance);
-
-        List<TriggerEvent> evs = new ArrayList<TriggerEvent>(Arrays.asList(evts));
-        Step step = null;
-
-        do {
-            // CreateStep
-            step = new Step(evs, currentStatus);
-            // EnumerateReachableTransitions
-            semantics.enumerateReachableTransitions(stateMachine, step,
-                errorReporter);
-            // FilterTransitionSet
-            semantics.filterTransitionsSet(step, eventdispatcher,
-                errorReporter, scInstance);
-            // FollowTransitions
-            semantics.followTransitions(step, errorReporter, scInstance);
-            // UpdateHistoryStates
-            semantics.updateHistoryStates(step, errorReporter, scInstance);
-            // ExecuteActions
-            semantics.executeActions(step, stateMachine, eventdispatcher,
-                errorReporter, scInstance);
-            // AssignCurrentStatus
-            updateStatus(step);
-            // ***Cleanup external events if superStep
-            if (superStep) {
-                evs.clear();
-            }
-        } while (superStep && currentStatus.getEvents().size() > 0);
-
-        // InitiateInvokes only after state machine has stabilized
-        semantics.initiateInvokes(step, errorReporter, scInstance);
-
-        // Restore event data
-        restoreEventData(oldData);
-        logState();
-    }
-
-    /**
-     * Convenience method when only one event needs to be triggered.
-     *
-     * @param evt
-     *            the external events which triggered during the last
-     *            time quantum
-     * @throws org.apache.commons.scxml2.model.ModelException in case there is a fatal SCXML object
-     *            model problem.
+     * Convenience constructor.
      */
-    public void triggerEvent(final TriggerEvent evt)
-            throws ModelException {
-        triggerEvents(new TriggerEvent[] {evt});
+    public SCXMLExecutor2() {
+        this(null, null, null, null);
     }
 
     /**
@@ -175,13 +136,6 @@ public class SCXMLExecutor2 extends SCXM
     }
 
     /**
-     * Convenience constructor.
-     */
-    public SCXMLExecutor2() {
-        this(null, null, null, null);
-    }
-
-    /**
      * Constructor.
      *
      * @param expEvaluator The expression evaluator
@@ -207,73 +161,6 @@ public class SCXMLExecutor2 extends SCXM
     }
 
     /**
-     * Clear all state and begin from &quot;initialstate&quot; indicated
-     * on root SCXML element.
-     *
-     * @throws org.apache.commons.scxml2.model.ModelException in case there is a fatal SCXML object
-     *         model problem.
-     */
-    public synchronized void reset() throws ModelException {
-        // Reset all variable contexts
-        Context rootCtx = scInstance.getRootContext();
-        // Clone root datamodel
-        if (stateMachine == null) {
-            log.error(ERR_NO_STATE_MACHINE);
-            throw new ModelException(ERR_NO_STATE_MACHINE);
-        } else {
-            Datamodel rootdm = stateMachine.getDatamodel();
-            SCXMLHelper.cloneDatamodel(rootdm, rootCtx,
-                scInstance.getEvaluator(), log);
-        }
-        if (stateMachine.getInitialScript() != null) {
-            Context initialScriptCtx = scInstance.getContext(stateMachine.getInitialScript().getParentTransitionTarget());
-            if (initialScriptCtx != null) {
-                initialScriptCtx.reset();
-            }
-        }
-        // all states and parallels, only states have variable contexts
-        for (TransitionTarget tt : stateMachine.getTargets().values()) {
-            if (tt instanceof State) {
-                Context context = scInstance.lookupContext(tt);
-                if (context != null) {
-                    context.reset();
-                    Datamodel dm = tt.getDatamodel();
-                    if (dm != null) {
-                        SCXMLHelper.cloneDatamodel(dm, context,
-                            scInstance.getEvaluator(), log);
-                    }
-                }
-            } else if (tt instanceof History) {
-                scInstance.reset((History) tt);
-            }
-        }
-        // CreateEmptyStatus
-        currentStatus = new Status();
-        Step step = new Step(null, currentStatus);
-        // DetermineInitialStates
-        semantics.determineInitialStates(stateMachine,
-                step.getAfterStatus().getStates(),
-                step.getEntryList(), errorReporter, scInstance);
-        // execute initial script if defined configured as transition so as to not trigger events
-        if (stateMachine.getInitialScript() != null) {
-            step.getTransitList().add((Transition)stateMachine.getInitialScript().getParent());
-        }
-        // ExecuteActions
-        semantics.executeActions(step, stateMachine, eventdispatcher,
-                errorReporter, scInstance);
-        // AssignCurrentStatus
-        updateStatus(step);
-        // Execute Immediate Transitions
-        if (superStep && currentStatus.getEvents().size() > 0) {
-            this.triggerEvents(new TriggerEvent[0]);
-        } else {
-            // InitiateInvokes only after state machine has stabilized
-            semantics.initiateInvokes(step, errorReporter, scInstance);
-            logState();
-        }
-    }
-
-    /**
      * Get the current status.
      *
      * @return The current Status
@@ -343,22 +230,7 @@ public class SCXMLExecutor2 extends SCXM
      * @param stateMachine The stateMachine to set.
      */
     public void setStateMachine(final SCXML stateMachine) {
-        // NormalizeStateMachine
-        SCXML sm = semantics.normalizeStateMachine(stateMachine,
-                errorReporter);
-        // StoreStateMachine
-        this.stateMachine = sm;
-    }
-
-    /**
-     * Initiate state machine execution.
-     *
-     * @throws org.apache.commons.scxml2.model.ModelException in case there is a fatal SCXML object
-     *  model problem.
-     */
-    public void go() throws ModelException {
-        // same as reset
-        this.reset();
+        this.stateMachine = semantics.normalizeStateMachine(stateMachine, errorReporter);
     }
 
     /**
@@ -418,78 +290,155 @@ public class SCXMLExecutor2 extends SCXM
      * CurrentStatus property and processed within the next
      * triggerEvents() invocation, also the immediate (empty event) transitions
      * are deferred until the next step
-      */
+     */
     public void setSuperStep(final boolean superStep) {
         this.superStep = superStep;
     }
 
     /**
-     * Add a listener to the {@link org.apache.commons.scxml2.model.Observable}.
+     * Initiate state machine execution.
      *
-     * @param observable The {@link org.apache.commons.scxml2.model.Observable} to attach the listener to.
-     * @param listener The SCXMLListener.
+     * @throws org.apache.commons.scxml2.model.ModelException in case there is a fatal SCXML object
+     *  model problem.
      */
-    public void addListener(final Observable observable, final SCXMLListener listener) {
-        scInstance.getNotificationRegistry().addListener(observable, listener);
+    public void go() throws ModelException {
+        // same as reset
+        this.reset();
     }
 
     /**
-     * Remove this listener from the {@link org.apache.commons.scxml2.model.Observable}.
+     * Clear all state and begin from &quot;initialstate&quot; indicated
+     * on root SCXML element.
      *
-     * @param observable The {@link org.apache.commons.scxml2.model.Observable}.
-     * @param listener The SCXMLListener to be removed.
+     * @throws org.apache.commons.scxml2.model.ModelException in case there is a fatal SCXML object
+     *         model problem.
      */
-    public void removeListener(final Observable observable,
-            final SCXMLListener listener) {
-        scInstance.getNotificationRegistry().removeListener(observable,
-            listener);
+    public synchronized void reset() throws ModelException {
+        // Reset all variable contexts
+        Context rootCtx = scInstance.getRootContext();
+        // Clone root datamodel
+        if (stateMachine == null) {
+            log.error(ERR_NO_STATE_MACHINE);
+            throw new ModelException(ERR_NO_STATE_MACHINE);
+        } else {
+            Datamodel rootdm = stateMachine.getDatamodel();
+            SCXMLHelper.cloneDatamodel(rootdm, rootCtx,
+                    scInstance.getEvaluator(), log);
+        }
+        if (stateMachine.getInitialScript() != null) {
+            Context initialScriptCtx = scInstance.getContext(stateMachine.getInitialScript().getParentTransitionTarget());
+            if (initialScriptCtx != null) {
+                initialScriptCtx.reset();
+            }
+        }
+        // all states and parallels, only states have variable contexts
+        for (TransitionTarget tt : stateMachine.getTargets().values()) {
+            if (tt instanceof State) {
+                Context context = scInstance.lookupContext(tt);
+                if (context != null) {
+                    context.reset();
+                    Datamodel dm = tt.getDatamodel();
+                    if (dm != null) {
+                        SCXMLHelper.cloneDatamodel(dm, context,
+                                scInstance.getEvaluator(), log);
+                    }
+                }
+            } else if (tt instanceof History) {
+                scInstance.reset((History) tt);
+            }
+        }
+        // CreateEmptyStatus
+        currentStatus = new Status();
+        Step step = new Step(null, currentStatus);
+        // DetermineInitialStates
+        semantics.determineInitialStates(stateMachine,
+                step.getAfterStatus().getStates(),
+                step.getEntryList(), errorReporter, scInstance);
+        // execute initial script if defined configured as transition so as to not trigger events
+        if (stateMachine.getInitialScript() != null) {
+            step.getTransitList().add((Transition)stateMachine.getInitialScript().getParent());
+        }
+        // ExecuteActions
+        semantics.executeActions(step, stateMachine, eventdispatcher,
+                errorReporter, scInstance);
+        // AssignCurrentStatus
+        updateStatus(step);
+        // Execute Immediate Transitions
+        if (superStep && currentStatus.getEvents().size() > 0) {
+            this.triggerEvents(new TriggerEvent[0]);
+        } else {
+            // InitiateInvokes only after state machine has stabilized
+            semantics.initiateInvokes(step, errorReporter, scInstance);
+            logState();
+        }
     }
 
     /**
-     * Register an <code>Invoker</code> for this target type.
+     * Convenience method when only one event needs to be triggered.
      *
-     * @param type The target type (specified by "type"
-     *             attribute of &lt;invoke&gt; tag).
-     * @param invokerClass The <code>Invoker</code> <code>Class</code>.
+     * @param evt
+     *            the external events which triggered during the last
+     *            time quantum
+     * @throws org.apache.commons.scxml2.model.ModelException in case there is a fatal SCXML object
+     *            model problem.
      */
-    public void registerInvokerClass(final String type,
-            final Class<? extends Invoker> invokerClass) {
-        scInstance.registerInvokerClass(type, invokerClass);
+    public void triggerEvent(final TriggerEvent evt)
+            throws ModelException {
+        triggerEvents(new TriggerEvent[] {evt});
     }
 
     /**
-     * Remove the <code>Invoker</code> registered for this target
-     * type (if there is one registered).
+     * The worker method.
+     * Re-evaluates current status whenever any events are triggered.
      *
-     * @param type The target type (specified by "type"
-     *             attribute of &lt;invoke&gt; tag).
+     * @param evts
+     *            an array of external events which triggered during the last
+     *            time quantum
+     * @throws org.apache.commons.scxml2.model.ModelException in case there is a fatal SCXML object
+     *            model problem.
      */
-    public void unregisterInvokerClass(final String type) {
-        scInstance.unregisterInvokerClass(type);
-    }
+    public synchronized void triggerEvents(final TriggerEvent[] evts)
+            throws ModelException {
+        // Set event data, saving old values
+        Object[] oldData = setEventData(evts);
 
-    /**
-     * Get the state chart instance for this executor.
-     *
-     * @return The SCInstance for this executor.
-     */
-    SCInstance getSCInstance() {
-        return scInstance;
-    }
+        // Forward events (external only) to any existing invokes,
+        // and finalize processing
+        semantics.processInvokes(evts, errorReporter, scInstance);
 
-    /**
-     * Log the current set of active states.
-     */
-    private void logState() {
-        if (log.isDebugEnabled()) {
-            StringBuffer sb = new StringBuffer("Current States: [ ");
-            for (TransitionTarget tt : currentStatus.getStates()) {
-                sb.append(tt.getId()).append(", ");
+        List<TriggerEvent> evs = new ArrayList<TriggerEvent>(Arrays.asList(evts));
+        Step step;
+
+        do {
+            // CreateStep
+            step = new Step(evs, currentStatus);
+            // EnumerateReachableTransitions
+            semantics.enumerateReachableTransitions(stateMachine, step,
+                errorReporter);
+            // FilterTransitionSet
+            semantics.filterTransitionsSet(step, eventdispatcher,
+                errorReporter, scInstance);
+            // FollowTransitions
+            semantics.followTransitions(step, errorReporter, scInstance);
+            // UpdateHistoryStates
+            semantics.updateHistoryStates(step, errorReporter, scInstance);
+            // ExecuteActions
+            semantics.executeActions(step, stateMachine, eventdispatcher,
+                errorReporter, scInstance);
+            // AssignCurrentStatus
+            updateStatus(step);
+            // ***Cleanup external events if superStep
+            if (superStep) {
+                evs.clear();
             }
-            int length = sb.length();
-            sb.delete(length - 2, length).append(" ]");
-            log.debug(sb.toString());
-        }
+        } while (superStep && currentStatus.getEvents().size() > 0);
+
+        // InitiateInvokes only after state machine has stabilized
+        semantics.initiateInvokes(step, errorReporter, scInstance);
+
+        // Restore event data
+        restoreEventData(oldData);
+        logState();
     }
 
     /**
@@ -498,8 +447,8 @@ public class SCXMLExecutor2 extends SCXM
     private void updateStatus(final Step step) {
         currentStatus = step.getAfterStatus();
         scInstance.getRootContext().setLocal("_ALL_STATES",
-            SCXMLHelper.getAncestorClosure(currentStatus.getStates(), null));
-        setEventData(currentStatus.getEvents().toArray(new TriggerEvent[0]));
+                SCXMLHelper.getAncestorClosure(currentStatus.getStates(), null));
+        setEventData(currentStatus.getEvents().toArray(new TriggerEvent[currentStatus.getEvents().size()]));
     }
 
     /**
@@ -554,28 +503,72 @@ public class SCXMLExecutor2 extends SCXM
     }
 
     /**
-     * The special variable for storing single event data / payload.
-     * @deprecated
+     * Add a listener to the {@link org.apache.commons.scxml2.model.Observable}.
+     *
+     * @param observable The {@link org.apache.commons.scxml2.model.Observable} to attach the listener to.
+     * @param listener The SCXMLListener.
      */
-    private static final String EVENT_DATA = "_eventdata";
+    public void addListener(final Observable observable, final SCXMLListener listener) {
+        scInstance.getNotificationRegistry().addListener(observable, listener);
+    }
 
     /**
-     * The special variable for storing event data / payload,
-     * when multiple events are triggered, keyed by event name.
+     * Remove this listener from the {@link org.apache.commons.scxml2.model.Observable}.
+     *
+     * @param observable The {@link org.apache.commons.scxml2.model.Observable}.
+     * @param listener The SCXMLListener to be removed.
      */
-    // TODO: is _eventdatamap really being used somewhere?
-    private static final String EVENT_DATA_MAP = "_eventdatamap";
+    public void removeListener(final Observable observable,
+            final SCXMLListener listener) {
+        scInstance.getNotificationRegistry().removeListener(observable,
+            listener);
+    }
 
     /**
-     * The special variable for storing single event data / payload.
+     * Register an <code>Invoker</code> for this target type.
+     *
+     * @param type The target type (specified by "type"
+     *             attribute of &lt;invoke&gt; tag).
+     * @param invokerClass The <code>Invoker</code> <code>Class</code>.
      */
-    private static final String EVENT_VARIABLE = "_event";
+    public void registerInvokerClass(final String type,
+            final Class<? extends Invoker> invokerClass) {
+        scInstance.registerInvokerClass(type, invokerClass);
+    }
 
     /**
-     * SCXMLExecutor put into motion without setting a model (state machine).
+     * Remove the <code>Invoker</code> registered for this target
+     * type (if there is one registered).
+     *
+     * @param type The target type (specified by "type"
+     *             attribute of &lt;invoke&gt; tag).
      */
-    private static final String ERR_NO_STATE_MACHINE =
-        "SCXMLExecutor: State machine not set";
+    public void unregisterInvokerClass(final String type) {
+        scInstance.unregisterInvokerClass(type);
+    }
 
+    /**
+     * Get the state chart instance for this executor.
+     *
+     * @return The SCInstance for this executor.
+     */
+    SCInstance getSCInstance() {
+        return scInstance;
+    }
+
+    /**
+     * Log the current set of active states.
+     */
+    private void logState() {
+        if (log.isDebugEnabled()) {
+            StringBuilder sb = new StringBuilder("Current States: [ ");
+            for (TransitionTarget tt : currentStatus.getStates()) {
+                sb.append(tt.getId()).append(", ");
+            }
+            int length = sb.length();
+            sb.delete(length - 2, length).append(" ]");
+            log.debug(sb.toString());
+        }
+    }
 }
 

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/semantics/SCXMLSemanticsImpl2.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/semantics/SCXMLSemanticsImpl2.java?rev=1577373&r1=1577372&r2=1577373&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/semantics/SCXMLSemanticsImpl2.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/semantics/SCXMLSemanticsImpl2.java Thu Mar 13 23:22:38 2014
@@ -63,8 +63,10 @@ import org.apache.commons.scxml2.model.T
 
 /**
  * This class will encapsulate and implement the
- * <a href="http://www.w3.org/TR/2014/CR-scxml-20140313/#AlgorithmforSCXMLInterpretation">W3C SCXML Algorithm for SCXML Interpretation</a>
+ * <a href="http://www.w3.org/TR/2014/CR-scxml-20140313/#AlgorithmforSCXMLInterpretation">
+ *     W3C SCXML Algorithm for SCXML Interpretation</a>
  */
+@SuppressWarnings("unused") // TODO: remove when done refactoring
 public class SCXMLSemanticsImpl2 implements SCXMLSemantics, Serializable {
 
     /**
@@ -96,14 +98,90 @@ public class SCXMLSemanticsImpl2 impleme
     private static final String ERR_ILLEGAL_ALLOC = ".error.illegalalloc";
 
     /**
-     * Zero-length array of {@link org.apache.commons.scxml2.model.TransitionTarget}s.
+     * TransitionTargetComparator factory method.
+     * @return Comparator The TransitionTarget comparator
+     */
+    protected Comparator<TransitionTarget> getTTComparator() {
+        return targetComparator;
+    }
+
+    /**
+     * Set the log used by this <code>SCXMLSemantics</code> instance.
+     *
+     * @param log The new log.
+     */
+    protected void setLog(final Log log) {
+        this.appLog = log;
+    }
+
+    /**
+     * Get the log used by this <code>SCXMLSemantics</code> instance.
+     *
+     * @return Log The log being used.
      */
-    private static final TransitionTarget[] TT_ARR0 = new TransitionTarget[0];
+    protected Log getLog() {
+        return appLog;
+    }
+
+    /**
+     * Implements prefix match, that is, if, for example,
+     * &quot;mouse.click&quot; is a member of eventOccurrences and a
+     * transition is triggered by &quot;mouse&quot;, the method returns true.
+     *
+     * @param transEvent
+     *            a trigger event of a transition
+     * @param eventOccurrences
+     *            current events
+     * @return true/false
+     */
+    protected boolean eventMatch(final String transEvent,
+                                 final Set<TriggerEvent> eventOccurrences) {
+        if (SCXMLHelper.isStringEmpty(transEvent)) { // Eventless transition
+            return true;
+        } else {
+            String trimTransEvent = transEvent.trim();
+            for (TriggerEvent te : eventOccurrences) {
+                String event = te.getName();
+                if (event == null) {
+                    continue; // Unnamed events
+                }
+                String trimEvent = event.trim();
+                if (trimEvent.equals(trimTransEvent)) {
+                    return true; // Match
+                } else if (te.getType() != TriggerEvent.CHANGE_EVENT
+                        && trimTransEvent.equals("*")) {
+                    return true; // Wildcard, skip gen'ed ones like .done etc.
+                } else if (trimTransEvent.endsWith(".*")
+                        && trimEvent.startsWith(trimTransEvent.substring(0,
+                        trimTransEvent.length() - 1))) {
+                    return true; // Prefixed wildcard
+                }
+            }
+            return false;
+        }
+    }
 
     /**
-     * Zero-length array of {@link org.apache.commons.scxml2.model.Transition}s.
+     * Implements event prefix match to ascertain &lt;finalize&gt; execution.
+     *
+     * @param parentStateId
+     *            the ID of the parent state of the &lt;invoke&gt; holding
+     *            the &lt;finalize&gt;
+     * @param eventOccurrences
+     *            current events
+     * @return true/false
      */
-    private static final Transition[] TR_ARR0 = new Transition[0];
+    protected boolean finalizeMatch(final String parentStateId,
+                                    final Set<TriggerEvent> eventOccurrences) {
+        String prefix = parentStateId + ".invoke."; // invoke prefix
+        for (TriggerEvent te : eventOccurrences) {
+            String evt = te.getName();
+            if (evt != null && evt.trim().startsWith(prefix)) {
+                return true;
+            }
+        }
+        return false;
+    }
 
     /**
      * @param input
@@ -146,7 +224,7 @@ public class SCXMLSemanticsImpl2 impleme
             //set of ALL entered states (even if initialState is a jump-over)
             Set<TransitionTarget> onEntry = SCXMLHelper.getAncestorClosure(targets, null);
             // sort onEntry according state hierarchy
-            TransitionTarget[] oen = onEntry.toArray(TT_ARR0);
+            TransitionTarget[] oen = onEntry.toArray(new TransitionTarget[onEntry.size()]);
             onEntry.clear();
             Arrays.sort(oen, getTTComparator());
             // we need to impose reverse order for the onEntry list
@@ -391,7 +469,7 @@ public class SCXMLSemanticsImpl2 impleme
                 continue; //makes no sense to eval guard cond.
             }
             // guard condition check
-            Boolean rslt = Boolean.FALSE;
+            Boolean rslt;
             String expr = t.getCond();
             if (SCXMLHelper.isStringEmpty(expr)) {
                 rslt = Boolean.TRUE;
@@ -414,7 +492,7 @@ public class SCXMLSemanticsImpl2 impleme
                     // TODO: place the error 'error.execution' in the internal event queue. (section "3.12.2 Errors")
                 }
             }
-            if (!rslt.booleanValue()) {
+            if (!rslt) {
                 // guard condition has not passed
                 removeList.add(t);
             }
@@ -428,7 +506,7 @@ public class SCXMLSemanticsImpl2 impleme
         // only if there are multiple enabled transitions
         if (step.getTransitList().size() > 1) {
             // global transition precedence check
-            Transition[] trans = step.getTransitList().toArray(TR_ARR0);
+            Transition[] trans = step.getTransitList().toArray(new Transition[step.getTransitList().size()]);
             // non-determinism candidates
             Set<Transition> nonDeterm = new LinkedHashSet<Transition>();
             for (int i = 0; i < trans.length; i++) {
@@ -608,12 +686,11 @@ public class SCXMLSemanticsImpl2 impleme
                                 //calculate shallow history for a given state
                                 // once
                                 shallow = new HashSet<TransitionTarget>();
-                                Collection<TransitionTarget> children =
-                                    new HashSet<TransitionTarget>();
+                                Collection<TransitionTarget> children;
                                 if (tt instanceof State) {
                                     children = ((State) tt).getChildren().
                                         values();
-                                } else if (tt instanceof Parallel) {
+                                } else { // (tt instanceof Parallel) {
                                     children = ((Parallel) tt).getChildren();
                                 }
                                 shallow.addAll(children);
@@ -623,8 +700,6 @@ public class SCXMLSemanticsImpl2 impleme
                             scInstance.setLastConfiguration(h, shallow);
                         }
                     }
-                    shallow = null;
-                    deep = null;
                 }
             }
         }
@@ -684,9 +759,9 @@ public class SCXMLSemanticsImpl2 impleme
             throw new ModelException("Illegal state machine configuration!");
         }
         // sort onEntry and onExit according state hierarchy
-        TransitionTarget[] oex = exitedStates.toArray(TT_ARR0);
+        TransitionTarget[] oex = exitedStates.toArray(new TransitionTarget[exitedStates.size()]);
         exitedStates.clear();
-        TransitionTarget[] oen = entered.toArray(TT_ARR0);
+        TransitionTarget[] oen = entered.toArray(new TransitionTarget[entered.size()]);
         entered.clear();
         Arrays.sort(oex, getTTComparator());
         Arrays.sort(oen, getTTComparator());
@@ -756,7 +831,7 @@ public class SCXMLSemanticsImpl2 impleme
                 String src = i.getSrc();
                 if (src == null) {
                     String srcexpr = i.getSrcexpr();
-                    Object srcObj = null;
+                    Object srcObj;
                     try {
                         ctx.setLocal(NAMESPACES_KEY, i.getNamespaces());
                         srcObj = eval.eval(ctx, srcexpr);
@@ -773,7 +848,7 @@ public class SCXMLSemanticsImpl2 impleme
                     source = i.getPathResolver().resolvePath(src);
                 }
                 String type = i.getType();
-                Invoker inv = null;
+                Invoker inv;
                 try {
                     inv = scInstance.newInvoker(type);
                 } catch (InvokerException ie) {
@@ -830,94 +905,5 @@ public class SCXMLSemanticsImpl2 impleme
             }
         }
     }
-
-    /**
-     * Implements prefix match, that is, if, for example,
-     * &quot;mouse.click&quot; is a member of eventOccurrences and a
-     * transition is triggered by &quot;mouse&quot;, the method returns true.
-     *
-     * @param transEvent
-     *            a trigger event of a transition
-     * @param eventOccurrences
-     *            current events
-     * @return true/false
-     */
-    protected boolean eventMatch(final String transEvent,
-            final Set<TriggerEvent> eventOccurrences) {
-        if (SCXMLHelper.isStringEmpty(transEvent)) { // Eventless transition
-            return true;
-        } else {
-            String trimTransEvent = transEvent.trim();
-            for (TriggerEvent te : eventOccurrences) {
-                String event = te.getName();
-                if (event == null) {
-                    continue; // Unnamed events
-                }
-                String trimEvent = event.trim();
-                if (trimEvent.equals(trimTransEvent)) {
-                    return true; // Match
-                } else if (te.getType() != TriggerEvent.CHANGE_EVENT
-                        && trimTransEvent.equals("*")) {
-                    return true; // Wildcard, skip gen'ed ones like .done etc.
-                } else if (trimTransEvent.endsWith(".*")
-                        && trimEvent.startsWith(trimTransEvent.substring(0,
-                                trimTransEvent.length() - 1))) {
-                    return true; // Prefixed wildcard
-                }
-            }
-            return false;
-        }
-    }
-
-    /**
-     * Implements event prefix match to ascertain &lt;finalize&gt; execution.
-     *
-     * @param parentStateId
-     *            the ID of the parent state of the &lt;invoke&gt; holding
-     *            the &lt;finalize&gt;
-     * @param eventOccurrences
-     *            current events
-     * @return true/false
-     */
-    protected boolean finalizeMatch(final String parentStateId,
-            final Set<TriggerEvent> eventOccurrences) {
-        String prefix = parentStateId + ".invoke."; // invoke prefix
-        for (TriggerEvent te : eventOccurrences) {
-            String evt = te.getName();
-            if (evt == null) {
-                continue; // Unnamed events
-            } else if (evt.trim().startsWith(prefix)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * TransitionTargetComparator factory method.
-     * @return Comparator The TransitionTarget comparator
-     */
-    protected Comparator<TransitionTarget> getTTComparator() {
-        return targetComparator;
-    }
-
-    /**
-     * Set the log used by this <code>SCXMLSemantics</code> instance.
-     *
-     * @param log The new log.
-     */
-    protected void setLog(final Log log) {
-        this.appLog = log;
-    }
-
-    /**
-     * Get the log used by this <code>SCXMLSemantics</code> instance.
-     *
-     * @return Log The log being used.
-     */
-    protected Log getLog() {
-        return appLog;
-    }
-
 }