commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1580369 [1/5] - in /commons/proper/scxml/trunk/src: main/java/org/apache/commons/scxml2/ main/java/org/apache/commons/scxml2/env/ main/java/org/apache/commons/scxml2/env/groovy/ main/java/org/apache/commons/scxml2/env/jexl/ main/java/org/a...
Date Sat, 22 Mar 2014 23:34:23 GMT
Author: ate
Date: Sat Mar 22 23:34:20 2014
New Revision: 1580369

URL: http://svn.apache.org/r1580369
Log:
SCXML-200:

Added:
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/DocumentOrder.java   (with props)
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/EnterableState.java   (with props)
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/SimpleTransition.java   (with props)
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/TransitionalState.java   (with props)
Removed:
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/semantics/TransitionTargetComparator.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/semantics/
Modified:
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Builtin.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/NotificationRegistry.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCInstance.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLHelper.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLListener.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLSemantics.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Status.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Step.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/AbstractSCXMLListener.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/AbstractStateMachine.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/LogUtils.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/SimpleErrorReporter.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/SimpleSCXMLListener.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/Tracer.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/groovy/GroovySCXMLScript.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/jexl/JexlBuiltin.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/xpath/FunctionResolver.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/xpath/XPathEvaluator.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/io/ModelUpdater.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/io/SCXMLReader.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/io/SCXMLWriter.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Action.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Assign.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Final.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Foreach.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/History.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/If.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Initial.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Log.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Parallel.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Param.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/SCXML.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Script.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Send.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/State.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Transition.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/TransitionTarget.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/Var.java
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/semantics/SCXMLSemanticsImpl.java
    commons/proper/scxml/trunk/src/site/xdoc/guide/scxml-documents.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/BuiltinTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/EventDataTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/NamespacePrefixedXPathsTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCInstanceTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCXMLExecutorTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCXMLHelperTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/SCXMLTestHelper.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/StatusTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/TieBreakerTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/WildcardTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/WizardsTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-01.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-02.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-03.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/custom-hello-world-04-jexl.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/AbstractSCXMLListenerTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/StopWatch.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/GroovyClosureTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/SerializableInitialBaseScriptTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/StaticMethodTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/serializable-initial-base-script.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/groovy/static-method.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/JSExampleTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/example-01.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/StaticMethodTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/datamodel-01.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/datamodel-02.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/datamodel-03.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/datamodel-04.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/eventdata-01.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/eventdata-02.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/eventdata-03.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/eventdata-04.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/stateless-01.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/static-method.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/jexl/wildcard-01.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/xpath/XPathExampleTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/external-hello-world.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/hello-world.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/history-deep-01.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/history-default-01.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/history-shallow-01.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/invoke/InvokeTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/invoke/invoked-01.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/invoke/invoked-02.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/invoke/invoked-03-01.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/invoke/invoked-03.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/invoke/invoker-01.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/invoke/invoker-02.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/invoke/invoker-03.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/SCXMLReaderTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/StateSrcTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/src-test-1.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/src-test-2.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/src-test-3.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/src-test-4.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/io/src-test-5.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/issues/Issue112Test.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/issues/Issue62Test.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/issues/issue62-02-ext.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/issues/issue62-02.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/issues/issue64-01.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/issues/issue64-02.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/ActionTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/AssignTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/CustomActionTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/DatamodelTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/HistoryTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/ScriptTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/StatelessModelTest.java
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/actions-state-test.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/assign-test-01.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/assign-test-02.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/parallel-01.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/parallel-03.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/model/stateless-parallel-01.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/prefix-01.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/send-01.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/send-02.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/tie-breaker-01.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/tie-breaker-02.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/tie-breaker-03.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/tie-breaker-04.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/transitions-01.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/transitions-02.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/transitions-03.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/transitions-04.xml
    commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/transitions-05.xml

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Builtin.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Builtin.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Builtin.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Builtin.java Sat Mar 22 23:34:20 2014
@@ -61,7 +61,7 @@ public class Builtin implements Serializ
      * @param state The State ID to compare with
      * @return Whether this State belongs to this Set
      */
-    public static boolean isMember(final Set<TransitionTarget> allStates,
+    public static boolean isMember(final Set<? extends TransitionTarget> allStates,
             final String state) {
         for (TransitionTarget tt : allStates) {
             if (state.equals(tt.getId())) {
@@ -178,7 +178,6 @@ public class Builtin implements Serializ
 
         /** Serial version UID. */
         private static final long serialVersionUID = 8620558582288851315L;
-        /** Map supplied by digester. */
         private final Map<String, String> namespaces;
 
         /**

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/NotificationRegistry.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/NotificationRegistry.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/NotificationRegistry.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/NotificationRegistry.java Sat Mar 22 23:34:20 2014
@@ -23,6 +23,7 @@ import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.commons.scxml2.model.EnterableState;
 import org.apache.commons.scxml2.model.Observable;
 import org.apache.commons.scxml2.model.Transition;
 import org.apache.commons.scxml2.model.TransitionTarget;
@@ -30,7 +31,7 @@ import org.apache.commons.scxml2.model.T
 /**
  * The registry where SCXML listeners are recorded for nodes of
  * interest such as the <code>SCXML</code> root,
- * <code>TransitionTarget</code>s and <code>Transition</code>s.
+ * <code>EnterableState</code>s and <code>Transition</code>s.
  * The notification registry keeps track of all
  * <code>SCXMLListener</code>s attached and notifies relevant
  * listeners of the events that interest them.
@@ -87,14 +88,14 @@ public final class NotificationRegistry 
     }
 
     /**
-     * Inform all relevant listeners that a TransitionTarget has been
+     * Inform all relevant listeners that a EnterableState has been
      * entered.
      *
      * @param source The Observable
-     * @param state The TransitionTarget that was entered
+     * @param state The EnterableState that was entered
      */
     public synchronized void fireOnEntry(final Observable source,
-            final TransitionTarget state) {
+            final EnterableState state) {
         Set<SCXMLListener> entries = regs.get(source);
         if (entries != null) {
             for (SCXMLListener lst : entries) {
@@ -104,14 +105,14 @@ public final class NotificationRegistry 
     }
 
     /**
-     * Inform all relevant listeners that a TransitionTarget has been
+     * Inform all relevant listeners that a EnterableState has been
      * exited.
      *
      * @param source The Observable
-     * @param state The TransitionTarget that was exited
+     * @param state The EnterableState that was exited
      */
     public synchronized void fireOnExit(final Observable source,
-            final TransitionTarget state) {
+            final EnterableState state) {
         Set<SCXMLListener> entries = regs.get(source);
         if (entries != null) {
             for (SCXMLListener lst : entries) {
@@ -124,8 +125,8 @@ public final class NotificationRegistry 
      * Inform all relevant listeners of a transition that has occured.
      *
      * @param source The Observable
-     * @param from The source TransitionTarget
-     * @param to The destination TransitionTarget
+     * @param from The source EnterableState
+     * @param to The destination EnterableState
      * @param transition The Transition that was taken
      */
     public synchronized void fireOnTransition(final Observable source,

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCInstance.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCInstance.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCInstance.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCInstance.java Sat Mar 22 23:34:20 2014
@@ -26,8 +26,10 @@ import java.util.Set;
 import org.apache.commons.scxml2.invoke.Invoker;
 import org.apache.commons.scxml2.invoke.InvokerException;
 import org.apache.commons.scxml2.model.Datamodel;
+import org.apache.commons.scxml2.model.EnterableState;
 import org.apache.commons.scxml2.model.History;
 import org.apache.commons.scxml2.model.TransitionTarget;
+import org.apache.commons.scxml2.model.TransitionalState;
 
 /**
  * The <code>SCInstance</code> performs book-keeping functions for
@@ -48,21 +50,21 @@ public class SCInstance implements Seria
 
     /**
      * The <code>Map</code> of <code>Context</code>s per
-     * <code>TransitionTarget</code>.
+     * <code>EnterableState</code>.
      */
-    private final Map<TransitionTarget, Context> contexts;
+    private final Map<EnterableState, Context> contexts;
 
     /**
      * The <code>Map</code> of last known configurations per
      * <code>History</code>.
      */
-    private final Map<History, Set<TransitionTarget>> histories;
+    private final Map<History, Set<EnterableState>> histories;
 
     /**
      * <code>Map</code> for recording the run to completion status of
      * composite states.
      */
-    private final Map<TransitionTarget, Boolean> completions;
+    private final Map<EnterableState, Boolean> completions;
 
     /**
      * The <code>Invoker</code> classes <code>Map</code>, keyed by
@@ -74,7 +76,7 @@ public class SCInstance implements Seria
      * The <code>Map</code> of active <code>Invoker</code>s, keyed by
      * (leaf) <code>State</code>s.
      */
-    private final Map<TransitionTarget, Invoker> invokers;
+    private final Map<TransitionalState, Invoker> invokers;
 
     /**
      * The evaluator for expressions.
@@ -103,11 +105,11 @@ public class SCInstance implements Seria
      */
     SCInstance(final SCXMLExecutor executor) {
         this.notificationRegistry = new NotificationRegistry();
-        this.contexts = Collections.synchronizedMap(new HashMap<TransitionTarget, Context>());
-        this.histories = Collections.synchronizedMap(new HashMap<History, Set<TransitionTarget>>());
+        this.contexts = Collections.synchronizedMap(new HashMap<EnterableState, Context>());
+        this.histories = Collections.synchronizedMap(new HashMap<History, Set<EnterableState>>());
         this.invokerClasses = Collections.synchronizedMap(new HashMap<String, Class<? extends Invoker>>());
-        this.invokers = Collections.synchronizedMap(new HashMap<TransitionTarget, Invoker>());
-        this.completions = Collections.synchronizedMap(new HashMap<TransitionTarget, Boolean>());
+        this.invokers = Collections.synchronizedMap(new HashMap<TransitionalState, Invoker>());
+        this.completions = Collections.synchronizedMap(new HashMap<EnterableState, Boolean>());
         this.evaluator = null;
         this.rootContext = null;
         this.executor = executor;
@@ -176,54 +178,57 @@ public class SCInstance implements Seria
      *
      * @param notifRegistry The notification registry.
      */
+    @SuppressWarnings("unused")
     void setNotificationRegistry(final NotificationRegistry notifRegistry) {
         this.notificationRegistry = notifRegistry;
     }
 
     /**
-     * Get the <code>Context</code> for this <code>TransitionTarget</code>.
+     * Get the <code>Context</code> for this <code>EnterableState</code>.
      * If one is not available it is created.
      *
-     * @param transitionTarget The TransitionTarget.
+     * @param state The EnterableState.
      * @return The Context.
      */
-    public Context getContext(final TransitionTarget transitionTarget) {
-        Context context = contexts.get(transitionTarget);
+    public Context getContext(final EnterableState state) {
+        Context context = contexts.get(state);
         if (context == null) {
-            TransitionTarget parent = transitionTarget.getParent();
+            EnterableState parent = state.getParent();
             if (parent == null) {
                 // docroot
                 context = evaluator.newContext(getGlobalScriptContext());
             } else {
                 context = evaluator.newContext(getContext(parent));
             }
-            Datamodel datamodel = transitionTarget.getDatamodel();
-            SCXMLHelper.cloneDatamodel(datamodel, context, evaluator, null);
-            contexts.put(transitionTarget, context);
+            if (state instanceof TransitionalState) {
+                Datamodel datamodel = ((TransitionalState)state).getDatamodel();
+                SCXMLHelper.cloneDatamodel(datamodel, context, evaluator, null);
+            }
+            contexts.put(state, context);
         }
         return context;
     }
 
     /**
-     * Get the <code>Context</code> for this <code>TransitionTarget</code>.
+     * Get the <code>Context</code> for this <code>EnterableState</code>.
      * May return <code>null</code>.
      *
-     * @param transitionTarget The <code>TransitionTarget</code>.
+     * @param state The <code>EnterableState</code>.
      * @return The Context.
      */
-    Context lookupContext(final TransitionTarget transitionTarget) {
-        return contexts.get(transitionTarget);
+    Context lookupContext(final EnterableState state) {
+        return contexts.get(state);
     }
 
     /**
-     * Set the <code>Context</code> for this <code>TransitionTarget</code>.
+     * Set the <code>Context</code> for this <code>EnterableState</code>.
      *
-     * @param transitionTarget The TransitionTarget.
+     * @param state The EnterableState.
      * @param context The Context.
      */
-    void setContext(final TransitionTarget transitionTarget,
+    void setContext(final EnterableState state,
             final Context context) {
-        contexts.put(transitionTarget, context);
+        contexts.put(state, context);
     }
 
     /**
@@ -232,10 +237,10 @@ public class SCInstance implements Seria
      * @param history The history.
      * @return Returns the lastConfiguration.
      */
-    public Set<TransitionTarget> getLastConfiguration(final History history) {
-        Set<TransitionTarget> lastConfiguration = histories.get(history);
+    public Set<EnterableState> getLastConfiguration(final History history) {
+        Set<EnterableState> lastConfiguration = histories.get(history);
         if (lastConfiguration == null) {
-            lastConfiguration = new HashSet<TransitionTarget>();
+            lastConfiguration = new HashSet<EnterableState>();
             histories.put(history, lastConfiguration);
         }
         return lastConfiguration;
@@ -248,8 +253,8 @@ public class SCInstance implements Seria
      * @param lc The lastConfiguration to set.
      */
     public void setLastConfiguration(final History history,
-            final Set<TransitionTarget> lc) {
-        Set<TransitionTarget> lastConfiguration = getLastConfiguration(history);
+            final Set<EnterableState> lc) {
+        Set<EnterableState> lastConfiguration = getLastConfiguration(history);
         lastConfiguration.clear();
         lastConfiguration.addAll(lc);
     }
@@ -261,11 +266,8 @@ public class SCInstance implements Seria
      * @return Whether we have a non-empty last configuration
      */
     public boolean isEmpty(final History history) {
-        Set<TransitionTarget> lastConfiguration = histories.get(history);
-        if (lastConfiguration == null || lastConfiguration.isEmpty()) {
-            return true;
-        }
-        return false;
+        Set<EnterableState> lastConfiguration = histories.get(history);
+        return lastConfiguration == null || lastConfiguration.isEmpty();
     }
 
     /**
@@ -275,7 +277,7 @@ public class SCInstance implements Seria
      * @see org.apache.commons.scxml2.SCXMLExecutor#reset()
      */
     public void reset(final History history) {
-        Set<TransitionTarget> lastConfiguration = histories.get(history);
+        Set<EnterableState> lastConfiguration = histories.get(history);
         if (lastConfiguration != null) {
             lastConfiguration.clear();
         }
@@ -334,7 +336,7 @@ public class SCInstance implements Seria
             throw new InvokerException("No Invoker registered for type \""
                 + type + "\"");
         }
-        Invoker invoker = null;
+        Invoker invoker;
         try {
             invoker = invokerClass.newInstance();
         } catch (InstantiationException ie) {
@@ -346,27 +348,27 @@ public class SCInstance implements Seria
     }
 
     /**
-    * Get the {@link Invoker} for this {@link TransitionTarget}.
+    * Get the {@link Invoker} for this {@link TransitionalState}.
      * May return <code>null</code>. A non-null {@link Invoker} will be
-     * returned if and only if the {@link TransitionTarget} is
+     * returned if and only if the {@link TransitionalState} is
      * currently active and contains an &lt;invoke&gt; child.
      *
-     * @param transitionTarget The <code>TransitionTarget</code>.
+     * @param state The <code>TransitionalState</code>.
      * @return The Invoker.
      */
-    public Invoker getInvoker(final TransitionTarget transitionTarget) {
-        return invokers.get(transitionTarget);
+    public Invoker getInvoker(final TransitionalState state) {
+        return invokers.get(state);
     }
 
     /**
-     * Set the {@link Invoker} for this {@link TransitionTarget}.
+     * Set the {@link Invoker} for this {@link TransitionalState}.
      *
-     * @param transitionTarget The TransitionTarget.
+     * @param state The TransitionalState.
      * @param invoker The Invoker.
      */
-    public void setInvoker(final TransitionTarget transitionTarget,
+    public void setInvoker(final TransitionalState state,
             final Invoker invoker) {
-        invokers.put(transitionTarget, invoker);
+        invokers.put(state, invoker);
     }
 
     /**
@@ -374,41 +376,40 @@ public class SCInstance implements Seria
      *
      * @return The map of invokers.
      */
-    public Map<TransitionTarget, Invoker> getInvokers() {
+    public Map<TransitionalState, Invoker> getInvokers() {
         return invokers;
     }
 
     /**
      * Get the completion status for this composite
-     * {@link TransitionTarget}.
+     * {@link EnterableState}.
      *
-     * @param transitionTarget The <code>TransitionTarget</code>.
+     * @param state The <code>EnterableState</code>.
      * @return The completion status.
      *
      * @since 0.7
      */
     @SuppressWarnings("boxing")
-    public boolean isDone(final TransitionTarget transitionTarget) {
-        if (completions.containsKey(transitionTarget)) {
-            return completions.get(transitionTarget);
+    public boolean isDone(final EnterableState state) {
+        if (completions.containsKey(state)) {
+            return completions.get(state);
         }
         return false;
     }
 
     /**
      * Set the completion status for this composite
-     * {@link TransitionTarget}.
+     * {@link EnterableState}.
      *
-     * @param transitionTarget The TransitionTarget.
+     * @param state The EnterableState.
      * @param done The completion status.
      *
      * @since 0.7
      */
     @SuppressWarnings("boxing")
-    public void setDone(final TransitionTarget transitionTarget,
+    public void setDone(final EnterableState state,
             final boolean done) {
-        completions.put(transitionTarget, done);
+        completions.put(state, done);
     }
-
 }
 

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLExecutor.java Sat Mar 22 23:34:20 2014
@@ -27,12 +27,14 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.scxml2.invoke.Invoker;
 import org.apache.commons.scxml2.model.Datamodel;
+import org.apache.commons.scxml2.model.EnterableState;
 import org.apache.commons.scxml2.model.History;
 import org.apache.commons.scxml2.model.ModelException;
 import org.apache.commons.scxml2.model.Observable;
 import org.apache.commons.scxml2.model.SCXML;
 import org.apache.commons.scxml2.model.State;
 import org.apache.commons.scxml2.model.TransitionTarget;
+import org.apache.commons.scxml2.model.TransitionalState;
 import org.apache.commons.scxml2.semantics.SCXMLSemanticsImpl;
 import org.apache.commons.scxml2.system.EventVariable;
 
@@ -132,8 +134,8 @@ public class SCXMLExecutor implements Se
     private void logState() {
         if (log.isDebugEnabled()) {
             StringBuilder sb = new StringBuilder("Current States: [ ");
-            for (TransitionTarget tt : currentStatus.getStates()) {
-                sb.append(tt.getId()).append(", ");
+            for (EnterableState es : currentStatus.getStates()) {
+                sb.append(es.getId()).append(", ");
             }
             int length = sb.length();
             sb.delete(length - 2, length).append(" ]");
@@ -416,14 +418,13 @@ public class SCXMLExecutor implements Se
         }
         // 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 (tt instanceof EnterableState) {
+                Context context = scInstance.lookupContext((EnterableState)tt);
                 if (context != null) {
                     context.reset();
-                    Datamodel dm = tt.getDatamodel();
-                    if (dm != null) {
-                        SCXMLHelper.cloneDatamodel(dm, context,
-                                scInstance.getEvaluator(), log);
+                    if (tt instanceof TransitionalState) {
+                        Datamodel dm = ((TransitionalState)tt).getDatamodel();
+                        SCXMLHelper.cloneDatamodel(dm, context, scInstance.getEvaluator(), log);
                     }
                 }
             } else if (tt instanceof History) {

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLHelper.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLHelper.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLHelper.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLHelper.java Sat Mar 22 23:34:20 2014
@@ -27,6 +27,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.scxml2.model.Data;
 import org.apache.commons.scxml2.model.Datamodel;
+import org.apache.commons.scxml2.model.EnterableState;
 import org.apache.commons.scxml2.model.Parallel;
 import org.apache.commons.scxml2.model.Path;
 import org.apache.commons.scxml2.model.State;
@@ -66,16 +67,9 @@ public final class SCXMLHelper {
      *            TransitionTarget context - a potential ancestor
      * @return true iff tt is a descendant of ctx, false otherwise
      */
-    public static boolean isDescendant(final TransitionTarget tt,
-            final TransitionTarget ctx) {
-        TransitionTarget parent = tt.getParent();
-        while (parent != null) {
-            if (parent == ctx) {
-                return true;
-            }
-            parent = parent.getParent();
-        }
-        return false;
+    public static boolean isDescendant(final TransitionTarget tt, final TransitionTarget ctx) {
+        return tt.getNumberOfAncestors() > ctx.getNumberOfAncestors()
+            && tt.getAncestor(ctx.getNumberOfAncestors()) == ctx;
     }
 
     /**
@@ -87,12 +81,12 @@ public final class SCXMLHelper {
      * @param upperBounds The Set of upper bound States
      * @return transitive closure of a given state set
      */
-    public static Set<TransitionTarget> getAncestorClosure(final Set<TransitionTarget> states,
-            final Set<TransitionTarget> upperBounds) {
-        Set<TransitionTarget> closure = new HashSet<TransitionTarget>(states.size() * 2);
+    public static Set<EnterableState> getAncestorClosure(final Set<? extends TransitionTarget> states,
+            final Set<? extends TransitionTarget> upperBounds) {
+        Set<EnterableState> closure = new HashSet<EnterableState>(states.size() * 2);
         for (TransitionTarget tt : states) {
             while (tt != null) {
-                if (!closure.add(tt)) {
+                if (tt instanceof EnterableState && !closure.add((EnterableState)tt)) {
                     //tt is already a part of the closure
                     break;
                 }
@@ -116,7 +110,7 @@ public final class SCXMLHelper {
      *            ErrorReporter to report detailed error info if needed
      * @return true if a given state configuration is legal, false otherwise
      */
-    public static boolean isLegalConfig(final Set<TransitionTarget> states,
+    public static boolean isLegalConfig(final Set<EnterableState> states,
             final ErrorReporter errRep) {
         /*
          * For every active state we add 1 to the count of its parent. Each
@@ -127,29 +121,29 @@ public final class SCXMLHelper {
          * states = active configuration.
          */
         boolean legalConfig = true; // let's be optimists
-        Map<TransitionTarget, Set<TransitionTarget>> counts =
-            new IdentityHashMap<TransitionTarget, Set<TransitionTarget>>();
-        Set<TransitionTarget> scxmlCount = new HashSet<TransitionTarget>();
-        for (TransitionTarget tt : states) {
-            TransitionTarget parent = null;
-            while ((parent = tt.getParent()) != null) {
-                Set<TransitionTarget> cnt = counts.get(parent);
+        Map<EnterableState, Set<EnterableState>> counts =
+            new IdentityHashMap<EnterableState, Set<EnterableState>>();
+        Set<EnterableState> scxmlCount = new HashSet<EnterableState>();
+        for (EnterableState es : states) {
+            EnterableState parent = null;
+            while ((parent = es.getParent()) != null) {
+                Set<EnterableState> cnt = counts.get(parent);
                 if (cnt == null) {
-                    cnt = new HashSet<TransitionTarget>();
+                    cnt = new HashSet<EnterableState>();
                     counts.put(parent, cnt);
                 }
-                cnt.add(tt);
-                tt = parent;
+                cnt.add(es);
+                es = parent;
             }
             //top-level contribution
-            scxmlCount.add(tt);
+            scxmlCount.add(es);
         }
         //Validate counts:
-        for (Map.Entry<TransitionTarget, Set<TransitionTarget>> entry : counts.entrySet()) {
-            TransitionTarget tt = entry.getKey();
-            Set<TransitionTarget> count = entry.getValue();
-            if (tt instanceof Parallel) {
-                Parallel p = (Parallel) tt;
+        for (Map.Entry<EnterableState, Set<EnterableState>> entry : counts.entrySet()) {
+            EnterableState es = entry.getKey();
+            Set<EnterableState> count = entry.getValue();
+            if (es instanceof Parallel) {
+                Parallel p = (Parallel) es;
                 if (count.size() < p.getChildren().size()) {
                     errRep.onError(ErrorConstants.ILLEGAL_CONFIG,
                         "Not all AND states active for parallel "
@@ -160,7 +154,7 @@ public final class SCXMLHelper {
                 if (count.size() > 1) {
                     errRep.onError(ErrorConstants.ILLEGAL_CONFIG,
                         "Multiple OR states active for state "
-                        + tt.getId(), entry);
+                        + es.getId(), entry);
                     legalConfig = false;
                 }
             }
@@ -223,17 +217,21 @@ public final class SCXMLHelper {
      * @return a set of all states (including composite) which are exited if a
      *         given transition is taken
      */
-    public static Set<TransitionTarget> getStatesExited(final Transition t,
-            final Set<TransitionTarget> currentStates) {
-        Set<TransitionTarget> allStates = new HashSet<TransitionTarget>();
+    public static Set<EnterableState> getStatesExited(final Transition t,
+            final Set<EnterableState> currentStates) {
+        Set<EnterableState> allStates = new HashSet<EnterableState>();
         if (t.getTargets().size() == 0) {
             return allStates;
         }
         Path p = t.getPaths().get(0); // all paths have same upseg
         //the easy part
-        allStates.addAll(p.getUpwardSegment());
+        for (TransitionTarget tt : p.getUpwardSegment()) {
+            if (tt instanceof EnterableState) {
+                allStates.add((EnterableState)tt);
+            }
+        }
         TransitionTarget source = t.getParent();
-        for (TransitionTarget a : currentStates) {
+        for (EnterableState a : currentStates) {
             if (isDescendant(a, source)) {
                 boolean added = false;
                 added = allStates.add(a);
@@ -247,14 +245,13 @@ public final class SCXMLHelper {
             for (State region : p.getRegionsExited()) {
                 Parallel par = (Parallel) region.getParent();
                 //let's find affected states in sibling regions
-                for (TransitionTarget tt : par.getChildren()) {
-                    State s = (State) tt;
-                    for (TransitionTarget a : currentStates) {
-                        if (isDescendant(a, s) || a == s) {
+                for (EnterableState es : par.getChildren()) {
+                    for (EnterableState a : currentStates) {
+                        if (isDescendant(a, es) || a == es) {
                             //a is affected
                             boolean added = false;
                             added = allStates.add(a);
-                            while (added && a != s) {
+                            while (added && a != es) {
                                 a = a.getParent();
                                 added = allStates.add(a);
                             }
@@ -277,9 +274,9 @@ public final class SCXMLHelper {
      * @see #getStatesExited(Transition, Set)
      */
     public static boolean inConflict(final Transition t1,
-            final Transition t2, final Set<TransitionTarget> currentStates) {
-        Set<TransitionTarget> ts1 = getStatesExited(t1, currentStates);
-        Set<TransitionTarget> ts2 = getStatesExited(t2, currentStates);
+            final Transition t2, final Set<EnterableState> currentStates) {
+        Set<EnterableState> ts1 = getStatesExited(t1, currentStates);
+        Set<EnterableState> ts2 = getStatesExited(t2, currentStates);
         ts1.retainAll(ts2);
         if (ts1.isEmpty()) {
             return false;
@@ -288,50 +285,6 @@ public final class SCXMLHelper {
     }
 
     /**
-     * Whether the first argument is a subtype of the second.
-     *
-     * @param child The candidate subtype
-     * @param parent The supertype
-     * @return true if child is subtype of parent, otherwise false
-     */
-    public static boolean subtypeOf(final Class<?> child, final Class<?> parent) {
-        if (child == null || parent == null) {
-            return false;
-        }
-        for (Class<?> current = child; current != Object.class;
-                current = current.getSuperclass()) {
-            if (current == parent) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Whether the class implements the interface.
-     *
-     * @param clas The candidate class
-     * @param interfayce The interface
-     * @return true if clas implements interfayce, otherwise false
-     */
-    public static boolean implementationOf(final Class<?> clas,
-            final Class<?> interfayce) {
-        if (clas == null || interfayce == null || !interfayce.isInterface()) {
-            return false;
-        }
-        for (Class<?> current = clas; current != Object.class;
-                current = current.getSuperclass()) {
-            Class<?>[] implementedInterfaces = current.getInterfaces();
-            for (int i = 0; i < implementedInterfaces.length; i++) {
-                if (implementedInterfaces[i] == interfayce) {
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
-    /**
      * Set node value, depending on its type, from a String.
      *
      * @param node A Node whose value is to be set

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLListener.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLListener.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLListener.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLListener.java Sat Mar 22 23:34:20 2014
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.scxml2;
 
+import org.apache.commons.scxml2.model.EnterableState;
 import org.apache.commons.scxml2.model.Transition;
 import org.apache.commons.scxml2.model.TransitionTarget;
 
@@ -32,18 +33,18 @@ import org.apache.commons.scxml2.model.T
 public interface SCXMLListener {
 
     /**
-     * Handle the entry into a TransitionTarget.
+     * Handle the entry into a EnterableState.
      *
-     * @param state The TransitionTarget entered
+     * @param state The EnterableState entered
      */
-    void onEntry(TransitionTarget state);
+    void onEntry(EnterableState state);
 
     /**
-     * Handle the exit out of a TransitionTarget.
+     * Handle the exit out of a EnterableState.
      *
-     * @param state The TransitionTarget exited
+     * @param state The EnterableState exited
      */
-    void onExit(TransitionTarget state);
+    void onExit(EnterableState state);
 
     /**
      * Handle the transition.

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLSemantics.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLSemantics.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLSemantics.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/SCXMLSemantics.java Sat Mar 22 23:34:20 2014
@@ -35,7 +35,7 @@ import org.apache.commons.scxml2.model.S
 public interface SCXMLSemantics {
 
     /**
-     * Optional post processing immediately following Digester. May be used
+     * Optional post processing immediately following SCXMLReader. May be used
      * for removing pseudo-states etc.
      *
      * @param input

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Status.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Status.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Status.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Status.java Sat Mar 22 23:34:20 2014
@@ -22,8 +22,8 @@ import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
 
-import org.apache.commons.scxml2.model.State;
-import org.apache.commons.scxml2.model.TransitionTarget;
+import org.apache.commons.scxml2.model.EnterableState;
+import org.apache.commons.scxml2.model.Final;
 
 /**
  * The encapsulation of the current state of a state machine.
@@ -39,7 +39,7 @@ public class Status implements Serializa
     /**
      * The states that are currently active.
      */
-    private Set<TransitionTarget> states;
+    private Set<EnterableState> states;
 
     /**
      * The events that are currently queued.
@@ -56,14 +56,13 @@ public class Status implements Serializa
      */
     public boolean isFinal() {
         boolean rslt = true;
-        for (TransitionTarget tt : states) {
-            State s = (State) tt;
-            if (!s.isFinal()) {
+        for (EnterableState es : states) {
+            if (!(es instanceof Final)) {
                 rslt = false;
                 break;
             }
-            //the status is final only iff these are top-level states
-            if (s.getParent() != null) {
+            //the status is final only if these are top-level states
+            if (es.getParent() != null) {
                 rslt = false;
                 break;
             }
@@ -78,7 +77,7 @@ public class Status implements Serializa
      * Constructor.
      */
     public Status() {
-        states = new HashSet<TransitionTarget>();
+        states = new HashSet<EnterableState>();
         events = new ArrayList<TriggerEvent>();
     }
 
@@ -87,7 +86,7 @@ public class Status implements Serializa
      *
      * @return Returns the states configuration - simple (leaf) states only.
      */
-    public Set<TransitionTarget> getStates() {
+    public Set<EnterableState> getStates() {
         return states;
     }
 
@@ -106,7 +105,7 @@ public class Status implements Serializa
      * @return complete states configuration including simple states and their
      *         complex ancestors up to the root.
      */
-    public Set<TransitionTarget> getAllStates() {
+    public Set<EnterableState> getAllStates() {
         return SCXMLHelper.getAncestorClosure(states, null);
     }
 

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Step.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Step.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Step.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/Step.java Sat Mar 22 23:34:20 2014
@@ -20,8 +20,8 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
+import org.apache.commons.scxml2.model.EnterableState;
 import org.apache.commons.scxml2.model.Transition;
-import org.apache.commons.scxml2.model.TransitionTarget;
 
 /**
  * A logical unit of progression in the execution of a SCXML model.
@@ -47,17 +47,17 @@ public class Step {
     /**
      * The list of TransitionTargets that were exited during this step.
      */
-    private List<TransitionTarget> exitList;
+    private List<EnterableState> exitList;
 
     /**
      * The list of TransitionTargets that were entered during this step.
      */
-    private List<TransitionTarget> entryList;
+    private List<EnterableState> entryList;
 
     /**
      * The list of TransitionTargets that were entered during this step by default
      */
-    private List<TransitionTarget> defaultEntryList;
+    private List<EnterableState> defaultEntryList;
     /**
      * The list of Transitions taken during this step.
      */
@@ -87,9 +87,9 @@ public class Step {
             this.beforeStatus = new Status();
         }
         this.afterStatus = new Status();
-        this.exitList = new ArrayList<TransitionTarget>();
-        this.entryList = new ArrayList<TransitionTarget>();
-        this.defaultEntryList = new ArrayList<TransitionTarget>();
+        this.exitList = new ArrayList<EnterableState>();
+        this.entryList = new ArrayList<EnterableState>();
+        this.defaultEntryList = new ArrayList<EnterableState>();
         this.transitList = new ArrayList<Transition>();
     }
 
@@ -124,21 +124,21 @@ public class Step {
     /**
      * @return Returns the entryList.
      */
-    public List<TransitionTarget> getEntryList() {
+    public List<EnterableState> getEntryList() {
         return entryList;
     }
 
     /**
      * @return Returns the defaultEntryList.
      */
-    public List<TransitionTarget> getDefaultEntryList() {
+    public List<EnterableState> getDefaultEntryList() {
         return defaultEntryList;
     }
 
     /**
      * @return Returns the exitList.
      */
-    public List<TransitionTarget> getExitList() {
+    public List<EnterableState> getExitList() {
         return exitList;
     }
 

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/AbstractSCXMLListener.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/AbstractSCXMLListener.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/AbstractSCXMLListener.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/AbstractSCXMLListener.java Sat Mar 22 23:34:20 2014
@@ -17,6 +17,7 @@
 package org.apache.commons.scxml2.env;
 
 import org.apache.commons.scxml2.SCXMLListener;
+import org.apache.commons.scxml2.model.EnterableState;
 import org.apache.commons.scxml2.model.Transition;
 import org.apache.commons.scxml2.model.TransitionTarget;
 
@@ -30,16 +31,16 @@ import org.apache.commons.scxml2.model.T
 public abstract class AbstractSCXMLListener implements SCXMLListener {
 
     /**
-     * @see SCXMLListener#onEntry(TransitionTarget)
+     * @see SCXMLListener#onEntry(EnterableState)
      */
-    public void onEntry(final TransitionTarget state) {
+    public void onEntry(final EnterableState state) {
         // empty
     }
 
     /**
-     * @see SCXMLListener#onExit(TransitionTarget)
+     * @see SCXMLListener#onExit(EnterableState)
      */
-    public void onExit(final TransitionTarget state) {
+    public void onExit(final EnterableState state) {
         // empty
     }
 

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/AbstractStateMachine.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/AbstractStateMachine.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/AbstractStateMachine.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/AbstractStateMachine.java Sat Mar 22 23:34:20 2014
@@ -33,6 +33,7 @@ import org.apache.commons.scxml2.Trigger
 import org.apache.commons.scxml2.env.jexl.JexlContext;
 import org.apache.commons.scxml2.env.jexl.JexlEvaluator;
 import org.apache.commons.scxml2.io.SCXMLReader;
+import org.apache.commons.scxml2.model.EnterableState;
 import org.apache.commons.scxml2.model.ModelException;
 import org.apache.commons.scxml2.model.SCXML;
 import org.apache.commons.scxml2.model.Transition;
@@ -297,7 +298,7 @@ public abstract class AbstractStateMachi
         /**
          * {@inheritDoc}
          */
-        public void onEntry(final TransitionTarget entered) {
+        public void onEntry(final EnterableState entered) {
             invoke(entered.getId());
         }
 
@@ -316,9 +317,9 @@ public abstract class AbstractStateMachi
         /**
          * No-op.
          *
-         * @param exited The transition target being exited.
+         * @param exited The state being exited.
          */
-        public void onExit(final TransitionTarget exited) {
+        public void onExit(final EnterableState exited) {
             // nothing to do
         }
 

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/LogUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/LogUtils.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/LogUtils.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/LogUtils.java Sat Mar 22 23:34:20 2014
@@ -16,8 +16,6 @@
  */
 package org.apache.commons.scxml2.env;
 
-import java.util.LinkedList;
-
 import org.apache.commons.scxml2.model.Transition;
 import org.apache.commons.scxml2.model.TransitionTarget;
 
@@ -54,22 +52,13 @@ public final class LogUtils {
      *                the SCXML document
      */
     public static String getTTPath(final TransitionTarget tt) {
-        TransitionTarget parent = tt.getParent();
-        if (parent == null) {
-            return "/" + tt.getId();
-        } else {
-            LinkedList<TransitionTarget> pathElements = new LinkedList<TransitionTarget>();
-            pathElements.addFirst(tt);
-            while (parent != null) {
-                pathElements.addFirst(parent);
-                parent = parent.getParent();
-            }
-            StringBuffer names = new StringBuffer();
-            for (TransitionTarget pathElement : pathElements) {
-                names.append('/').append(pathElement.getId());
-            }
-            return names.toString();
+        StringBuilder sb = new StringBuilder("/");
+        for (int i = 0; i < tt.getNumberOfAncestors(); i++) {
+            sb.append(tt.getAncestor(i).getId());
+            sb.append("/");
         }
+        sb.append(tt.getId());
+        return sb.toString();
     }
 
     /**

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/SimpleErrorReporter.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/SimpleErrorReporter.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/SimpleErrorReporter.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/SimpleErrorReporter.java Sat Mar 22 23:34:20 2014
@@ -24,6 +24,7 @@ import java.util.Set;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.scxml2.ErrorReporter;
+import org.apache.commons.scxml2.model.EnterableState;
 import org.apache.commons.scxml2.model.Executable;
 import org.apache.commons.scxml2.model.SCXML;
 import org.apache.commons.scxml2.model.State;
@@ -74,26 +75,25 @@ public class SimpleErrorReporter impleme
         } else if (errCode == ErrorConstants.ILLEGAL_CONFIG) {
             //isLegalConfig
             if (errCtx instanceof Map.Entry) { //unchecked cast below
-                Map.Entry<TransitionTarget, Set<TransitionTarget>> badConfigMap =
-                    (Map.Entry<TransitionTarget, Set<TransitionTarget>>) errCtx;
-                TransitionTarget tt = badConfigMap.getKey();
-                Set<TransitionTarget> vals = badConfigMap.getValue();
-                msg.append(LogUtils.getTTPath(tt) + " : [");
-                for (Iterator<TransitionTarget> i = vals.iterator();
-                        i.hasNext();) {
-                    TransitionTarget tx = i.next();
-                    msg.append(LogUtils.getTTPath(tx));
+                Map.Entry<EnterableState, Set<EnterableState>> badConfigMap =
+                    (Map.Entry<EnterableState, Set<EnterableState>>) errCtx;
+                EnterableState es = badConfigMap.getKey();
+                Set<EnterableState> vals = badConfigMap.getValue();
+                msg.append(LogUtils.getTTPath(es) + " : [");
+                for (Iterator<EnterableState> i = vals.iterator(); i.hasNext();) {
+                    EnterableState ex = i.next();
+                    msg.append(LogUtils.getTTPath(ex));
                     if (i.hasNext()) { // reason for iterator usage
                         msg.append(", ");
                     }
                 }
                 msg.append(']');
             } else if (errCtx instanceof Set) { //unchecked cast below
-                Set<TransitionTarget> vals = (Set<TransitionTarget>) errCtx;
+                Set<EnterableState> vals = (Set<EnterableState>) errCtx;
                 msg.append("<SCXML> : [");
-                for (Iterator<TransitionTarget> i = vals.iterator(); i.hasNext();) {
-                    TransitionTarget tx = i.next();
-                    msg.append(LogUtils.getTTPath(tx));
+                for (Iterator<EnterableState> i = vals.iterator(); i.hasNext();) {
+                    EnterableState ex = i.next();
+                    msg.append(LogUtils.getTTPath(ex));
                     if (i.hasNext()) {
                         msg.append(", ");
                     }

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/SimpleSCXMLListener.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/SimpleSCXMLListener.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/SimpleSCXMLListener.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/SimpleSCXMLListener.java Sat Mar 22 23:34:20 2014
@@ -21,6 +21,7 @@ import java.io.Serializable;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.scxml2.SCXMLListener;
+import org.apache.commons.scxml2.model.EnterableState;
 import org.apache.commons.scxml2.model.Transition;
 import org.apache.commons.scxml2.model.TransitionTarget;
 
@@ -37,18 +38,18 @@ public class SimpleSCXMLListener impleme
 
 
     /**
-     * @see SCXMLListener#onEntry(TransitionTarget)
+     * @see SCXMLListener#onEntry(EnterableState)
      */
-    public void onEntry(final TransitionTarget state) {
+    public void onEntry(final EnterableState state) {
         if (log.isInfoEnabled()) {
             log.info(LogUtils.getTTPath(state));
         }
     }
 
     /**
-     * @see SCXMLListener#onExit(TransitionTarget)
+     * @see SCXMLListener#onExit(EnterableState)
      */
-    public void onExit(final TransitionTarget state) {
+    public void onExit(final EnterableState state) {
         if (log.isInfoEnabled()) {
             log.info(LogUtils.getTTPath(state));
         }

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/Tracer.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/Tracer.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/Tracer.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/Tracer.java Sat Mar 22 23:34:20 2014
@@ -24,6 +24,7 @@ import javax.xml.stream.XMLStreamExcepti
 
 import org.apache.commons.scxml2.ErrorReporter;
 import org.apache.commons.scxml2.SCXMLListener;
+import org.apache.commons.scxml2.model.EnterableState;
 import org.apache.commons.scxml2.model.Transition;
 import org.apache.commons.scxml2.model.TransitionTarget;
 import org.xml.sax.ErrorHandler;
@@ -92,17 +93,17 @@ public class Tracer implements ErrorHand
     }
 
     /**
-     * @see SCXMLListener#onEntry(TransitionTarget)
+     * @see SCXMLListener#onEntry(EnterableState)
      */
-    public void onEntry(final TransitionTarget target) {
-        scxmlListener.onEntry(target);
+    public void onEntry(final EnterableState state) {
+        scxmlListener.onEntry(state);
     }
 
     /**
-     * @see SCXMLListener#onExit(TransitionTarget)
+     * @see SCXMLListener#onExit(EnterableState)
      */
-    public void onExit(final TransitionTarget target) {
-        scxmlListener.onExit(target);
+    public void onExit(final EnterableState state) {
+        scxmlListener.onExit(state);
     }
 
     /**

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/groovy/GroovySCXMLScript.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/groovy/GroovySCXMLScript.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/groovy/GroovySCXMLScript.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/groovy/GroovySCXMLScript.java Sat Mar 22 23:34:20 2014
@@ -22,7 +22,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.commons.scxml2.Builtin;
-import org.apache.commons.scxml2.model.TransitionTarget;
+import org.apache.commons.scxml2.model.EnterableState;
 
 import groovy.lang.Binding;
 import groovy.lang.MissingPropertyException;
@@ -62,8 +62,8 @@ public abstract class GroovySCXMLScript 
      * @return the ALL_STATES set
      */
     @SuppressWarnings("unchecked")
-    private Set<TransitionTarget> getAllStates() {
-        return (Set<TransitionTarget>) context.get("_ALL_STATES");
+    private Set<EnterableState> getAllStates() {
+        return (Set<EnterableState>) context.get("_ALL_STATES");
     }
 
     /**

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/jexl/JexlBuiltin.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/jexl/JexlBuiltin.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/jexl/JexlBuiltin.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/jexl/JexlBuiltin.java Sat Mar 22 23:34:20 2014
@@ -20,7 +20,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.commons.scxml2.Builtin;
-import org.apache.commons.scxml2.model.TransitionTarget;
+import org.apache.commons.scxml2.model.EnterableState;
 
 /**
  * Global JEXL namespace functor, implements Data() and In() operators.
@@ -44,6 +44,7 @@ public final class JexlBuiltin {
      * Gets the ALL_NAMESPACES map from context.
      * @return the ALL_NAMESPACES map
      */
+    @SuppressWarnings("unchecked")
     private Map<String, String> getNamespaces() {
         return (Map<String, String>) context.get("_ALL_NAMESPACES");
     }
@@ -52,8 +53,9 @@ public final class JexlBuiltin {
      * Gets the ALL_STATES set from context.
      * @return the ALL_STATES set
      */
-    private Set<TransitionTarget> getAllStates() {
-        return (Set<TransitionTarget>) context.get("_ALL_STATES");
+    @SuppressWarnings("unchecked")
+    private Set<EnterableState> getAllStates() {
+        return (Set<EnterableState>) context.get("_ALL_STATES");
     }
 
     /**

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/xpath/FunctionResolver.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/xpath/FunctionResolver.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/xpath/FunctionResolver.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/xpath/FunctionResolver.java Sat Mar 22 23:34:20 2014
@@ -29,7 +29,7 @@ import javax.xml.xpath.XPathFunctionReso
 
 import org.apache.commons.scxml2.Builtin;
 import org.apache.commons.scxml2.Context;
-import org.apache.commons.scxml2.model.TransitionTarget;
+import org.apache.commons.scxml2.model.EnterableState;
 
 /**
  * A {@link XPathFunctionResolver} for the Commons SCXML environment.
@@ -113,8 +113,8 @@ public class FunctionResolver implements
         @Override
         @SuppressWarnings({ "unchecked", "boxing" })
         public Object evaluate(final List args) throws XPathFunctionException {
-            Set<TransitionTarget> allStates =
-                (Set<TransitionTarget>) xctx.get(STATES);
+            Set<EnterableState> allStates =
+                (Set<EnterableState>) xctx.get(STATES);
             return Builtin.isMember(allStates, (String) args.get(0));
         }
 

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/xpath/XPathEvaluator.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/xpath/XPathEvaluator.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/xpath/XPathEvaluator.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/env/xpath/XPathEvaluator.java Sat Mar 22 23:34:20 2014
@@ -184,7 +184,6 @@ public class XPathEvaluator implements E
 
         /** Serial version UID. */
         private static final long serialVersionUID = 8620558582288851315L;
-        /** Map supplied by digester. */
         private final Map<String, String> namespaces;
 
         /**

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/io/ModelUpdater.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/io/ModelUpdater.java?rev=1580369&r1=1580368&r2=1580369&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/io/ModelUpdater.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/io/ModelUpdater.java Sat Mar 22 23:34:20 2014
@@ -25,15 +25,18 @@ import java.util.StringTokenizer;
 
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.scxml2.SCXMLHelper;
+import org.apache.commons.scxml2.model.EnterableState;
 import org.apache.commons.scxml2.model.History;
 import org.apache.commons.scxml2.model.Initial;
 import org.apache.commons.scxml2.model.Invoke;
 import org.apache.commons.scxml2.model.ModelException;
 import org.apache.commons.scxml2.model.Parallel;
 import org.apache.commons.scxml2.model.SCXML;
+import org.apache.commons.scxml2.model.SimpleTransition;
 import org.apache.commons.scxml2.model.State;
 import org.apache.commons.scxml2.model.Transition;
 import org.apache.commons.scxml2.model.TransitionTarget;
+import org.apache.commons.scxml2.model.TransitionalState;
 
 /**
  * The ModelUpdater provides the utility methods to check the Commons
@@ -149,8 +152,10 @@ final class ModelUpdater {
      * @throws ModelException If the object model is flawed
      */
     static void updateSCXML(final SCXML scxml) throws ModelException {
+        initDocumentOrder(scxml.getChildren(), 0);
+
         String initial = scxml.getInitial();
-        Transition initialTransition = new Transition();
+        SimpleTransition initialTransition = new SimpleTransition();
 
         if (initial != null) {
 
@@ -170,95 +175,108 @@ final class ModelUpdater {
 
         scxml.setInitialTransition(initialTransition);
         Map<String, TransitionTarget> targets = scxml.getTargets();
-        Map<String, TransitionTarget> children = scxml.getChildren();
-        for (TransitionTarget tt : children.values()) {
-            if (tt instanceof State) {
-                updateState((State) tt, targets);
-            } else {
-                updateParallel((Parallel) tt, targets);
+        for (EnterableState es : scxml.getChildren()) {
+            if (es instanceof State) {
+                updateState((State) es, targets);
+            } else if (es instanceof Parallel) {
+                updateParallel((Parallel) es, targets);
+            }
+        }
+    }
+
+    private static int initDocumentOrder(final List<EnterableState> states, final int currentOrder) {
+        int nextOrder = currentOrder;
+        for (EnterableState state : states) {
+            state.setOrder(++nextOrder);
+            if (state instanceof TransitionalState) {
+                TransitionalState ts = (TransitionalState)state;
+                for (Transition t : ts.getTransitionsList()) {
+                    t.setOrder(++nextOrder);
+                }
+                nextOrder = initDocumentOrder(ts.getChildren(), nextOrder);
             }
         }
+        return nextOrder;
     }
 
     /**
      * Update this State object (part of post-read processing).
      * Also checks for any errors in the document.
      *
-     * @param s The State object
+     * @param state The State object
      * @param targets The global Map of all transition targets
      * @throws ModelException If the object model is flawed
      */
-    private static void updateState(final State s, final Map<String, TransitionTarget> targets)
+    private static void updateState(final State state, final Map<String, TransitionTarget> targets)
             throws ModelException {
-        Map<String, TransitionTarget> c = s.getChildren();
-        if (s.isComposite()) {
+        List<EnterableState> children = state.getChildren();
+        if (state.isComposite()) {
             //initialize next / initial
-            Initial ini = s.getInitial();
+            Initial ini = state.getInitial();
             if (ini == null) {
-                s.setFirst(c.keySet().iterator().next());
-                ini = s.getInitial();
+                state.setFirst(children.get(0).getId());
+                ini = state.getInitial();
             }
-            Transition initialTransition = ini.getTransition();
+            SimpleTransition initialTransition = ini.getTransition();
             updateTransition(initialTransition, targets);
             List<TransitionTarget> initialStates = initialTransition.getTargets();
             // we have to allow for an indirect descendant initial (targets)
             //check that initialState is a descendant of s
             if (initialStates.size() == 0) {
                 logAndThrowModelError(ERR_STATE_BAD_INIT,
-                        new Object[] {getName(s)});
+                        new Object[] {getName(state)});
             } else {
                 for (TransitionTarget initialState : initialStates) {
-                    if (!SCXMLHelper.isDescendant(initialState, s)) {
+                    if (!SCXMLHelper.isDescendant(initialState, state)) {
                         logAndThrowModelError(ERR_STATE_BAD_INIT,
-                                new Object[] {getName(s)});
+                                new Object[] {getName(state)});
                     }
                 }
             }
         }
-        else if (s.getInitial() != null) {
-            logAndThrowModelError(ERR_UNSUPPORTED_INIT, new Object[] {getName(s)});
+        else if (state.getInitial() != null) {
+            logAndThrowModelError(ERR_UNSUPPORTED_INIT, new Object[] {getName(state)});
         }
 
-        List<History> histories = s.getHistory();
-        if (histories.size() > 0 && s.isSimple()) {
+        List<History> histories = state.getHistory();
+        if (histories.size() > 0 && state.isSimple()) {
             logAndThrowModelError(ERR_HISTORY_SIMPLE_STATE,
-                    new Object[] {getName(s)});
+                    new Object[] {getName(state)});
         }
-        for (History h : histories) {
-            updateHistory(h, targets, s);
+        for (History history : histories) {
+            updateHistory(history, targets, state);
         }
-        for (Transition trn : s.getTransitionsList()) {
-            updateTransition(trn, targets);
+        for (Transition transition : state.getTransitionsList()) {
+            updateTransition(transition, targets);
         }
 
         // TODO: state must may have multiple invokes
-        Invoke inv = s.getInvoke();
+        Invoke inv = state.getInvoke();
         if (inv != null) {
             String type = inv.getType();
-            if (type == null || type.trim().length() == 0) {
+            if (SCXMLHelper.isStringEmpty(type)) {
                 logAndThrowModelError(ERR_INVOKE_NO_TYPE,
-                        new Object[] {getName(s)});
+                        new Object[] {getName(state)});
             }
             String src = inv.getSrc();
-            boolean noSrc = (src == null || src.trim().length() == 0);
+            boolean noSrc = SCXMLHelper.isStringEmpty(src);
             String srcexpr = inv.getSrcexpr();
-            boolean noSrcexpr = (srcexpr == null
-                    || srcexpr.trim().length() == 0);
+            boolean noSrcexpr = SCXMLHelper.isStringEmpty(srcexpr);
             if (noSrc && noSrcexpr) {
                 logAndThrowModelError(ERR_INVOKE_NO_SRC,
-                        new Object[] {getName(s)});
+                        new Object[] {getName(state)});
             }
             if (!noSrc && !noSrcexpr) {
                 logAndThrowModelError(ERR_INVOKE_AMBIGUOUS_SRC,
-                        new Object[] {getName(s)});
+                        new Object[] {getName(state)});
             }
         }
 
-        for (TransitionTarget tt : c.values()) {
-            if (tt instanceof State) {
-                updateState((State) tt, targets);
-            } else if (tt instanceof Parallel) {
-                updateParallel((Parallel) tt, targets);
+        for (EnterableState es : children) {
+            if (es instanceof State) {
+                updateState((State) es, targets);
+            } else if (es instanceof Parallel) {
+                updateParallel((Parallel) es, targets);
             }
         }
     }
@@ -266,21 +284,25 @@ final class ModelUpdater {
     /**
      * Update this Parallel object (part of post-read processing).
      *
-     * @param p The Parallel object
+     * @param parallel The Parallel object
      * @param targets The global Map of all transition targets
      * @throws ModelException If the object model is flawed
      */
-    private static void updateParallel(final Parallel p, final Map<String, TransitionTarget> targets)
+    private static void updateParallel(final Parallel parallel, final Map<String, TransitionTarget> targets)
             throws ModelException {
-        for (TransitionTarget tt : p.getChildren()) {
-            updateState((State) tt, targets);
-        }
-        for (Transition trn : p.getTransitionsList()) {
-            updateTransition(trn, targets);
+        for (EnterableState es : parallel.getChildren()) {
+            if (es instanceof State) {
+                updateState((State) es, targets);
+            } else if (es instanceof Parallel) {
+                updateParallel((Parallel) es, targets);
+            }
         }
-        List<History> histories = p.getHistory();
-        for (History h : histories) {
-            updateHistory(h, targets, p);
+        for (Transition transition : parallel.getTransitionsList()) {
+            updateTransition(transition, targets);
+        }
+        List<History> histories = parallel.getHistory();
+        for (History history : histories) {
+            updateHistory(history, targets, parallel);
         }
         // TODO: parallel must may have invokes too
     }
@@ -288,39 +310,31 @@ final class ModelUpdater {
     /**
      * Update this History object (part of post-read processing).
      *
-     * @param h The History object
+     * @param history The History object
      * @param targets The global Map of all transition targets
-     * @param parent The parent TransitionTarget for this History
+     * @param parent The parent TransitionalState for this History
      * @throws ModelException If the object model is flawed
      */
-    private static void updateHistory(final History h,
+    private static void updateHistory(final History history,
                                       final Map<String, TransitionTarget> targets,
-                                      final TransitionTarget parent)
+                                      final TransitionalState parent)
             throws ModelException {
-        Transition historyTransition = h.getTransition();
-        if (historyTransition == null || historyTransition.getNext() == null) {
+        SimpleTransition transition = history.getTransition();
+        if (transition == null || transition.getNext() == null) {
             logAndThrowModelError(ERR_HISTORY_NO_DEFAULT,
-                    new Object[] {h.getId(), getName(parent)});
+                    new Object[] {history.getId(), getName(parent)});
         }
         else {
-            updateTransition(historyTransition, targets);
-            List<TransitionTarget> historyStates = historyTransition.getTargets();
+            updateTransition(transition, targets);
+            List<TransitionTarget> historyStates = transition.getTargets();
             if (historyStates.size() == 0) {
                 logAndThrowModelError(ERR_STATE_NO_HIST,
                         new Object[] {getName(parent)});
             }
             for (TransitionTarget historyState : historyStates) {
-                if (!h.isDeep()) {
+                if (!history.isDeep()) {
                     // Shallow history
-                    boolean shallow = false;
-                    if (parent instanceof State) {
-                        shallow = ((State) parent).getChildren().
-                                containsValue(historyState);
-                    } else if (parent instanceof Parallel) {
-                        shallow = ((Parallel) parent).getChildren().
-                                contains(historyState);
-                    }
-                    if (!shallow) {
+                    if (!parent.getChildren().contains(historyState)) {
                         logAndThrowModelError(ERR_STATE_BAD_SHALLOW_HIST,
                                 new Object[] {getName(parent)});
                     }
@@ -338,17 +352,17 @@ final class ModelUpdater {
     /**
      * Update this Transition object (part of post-read processing).
      *
-     * @param t The Transition object
+     * @param transition The Transition object
      * @param targets The global Map of all transition targets
      * @throws ModelException If the object model is flawed
      */
-    private static void updateTransition(final Transition t,
+    private static void updateTransition(final SimpleTransition transition,
                                          final Map<String, TransitionTarget> targets) throws ModelException {
-        String next = t.getNext();
+        String next = transition.getNext();
         if (next == null) { // stay transition
             return;
         }
-        List<TransitionTarget> tts = t.getTargets();
+        List<TransitionTarget> tts = transition.getTargets();
         if (tts.size() == 0) {
             // 'next' is a space separated list of transition target IDs
             StringTokenizer ids = new StringTokenizer(next);
@@ -369,7 +383,7 @@ final class ModelUpdater {
                 }
             }
         }
-        t.getPaths(); // init paths
+        transition.getPaths(); // init paths
     }
 
     /**
@@ -436,16 +450,16 @@ final class ModelUpdater {
         if (lca == null || !(lca instanceof Parallel)) {
             return false; // Must have a Parallel LCA
         }
-        Parallel p = (Parallel) lca;
+        Parallel parallel = (Parallel) lca;
         Set<TransitionTarget> regions = new HashSet<TransitionTarget>();
         for (TransitionTarget tt : tts) {
-            while (tt.getParent() != p) {
+            while (tt.getParent() != parallel) {
                 tt = tt.getParent();
             }
             if (!regions.add(tt)) {
                 return false; // One per region
             }
         }
-        return regions.size() == p.getChildren().size();
+        return regions.size() == parallel.getChildren().size();
     }
 }
\ No newline at end of file



Mime
View raw message