You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ra...@apache.org on 2005/09/30 02:35:19 UTC

svn commit: r292589 - in /jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml: SCXMLSemantics.java env/jsp/Standalone.java

Author: rahul
Date: Thu Sep 29 17:35:16 2005
New Revision: 292589

URL: http://svn.apache.org/viewcvs?rev=292589&view=rev
Log:
Enhance the Standalone testing functionality to enable value change events on the current Context, and firing dummy events to re-evaluate conditionals on event-less transitions.

Modified:
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLSemantics.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/jsp/Standalone.java

Modified: jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLSemantics.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLSemantics.java?rev=292589&r1=292588&r2=292589&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLSemantics.java (original)
+++ jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLSemantics.java Thu Sep 29 17:35:16 2005
@@ -727,8 +727,9 @@
             Iterator i = eventOccurrences.iterator();
             while (i.hasNext()) {
                 String evt = (String) i.next();
-                if (evt.equals(transEvent) || evt.startsWith(transEventDot)) {
-                    return true;
+                if (evt == null || evt.equals(transEvent) //null for Standalone
+                    || evt.startsWith(transEventDot)) {
+                        return true;
                 }
             }
             return false;

Modified: jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/jsp/Standalone.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/jsp/Standalone.java?rev=292589&r1=292588&r2=292589&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/jsp/Standalone.java (original)
+++ jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/jsp/Standalone.java Thu Sep 29 17:35:16 2005
@@ -29,6 +29,7 @@
 import org.apache.commons.scxml.EventDispatcher;
 import org.apache.commons.scxml.SCXMLDigester;
 import org.apache.commons.scxml.SCXMLExecutor;
+import org.apache.commons.scxml.SCXMLHelper;
 import org.apache.commons.scxml.TriggerEvent;
 import org.apache.commons.scxml.env.SimpleDispatcher;
 import org.apache.commons.scxml.env.Tracer;
@@ -36,8 +37,20 @@
 import org.apache.commons.scxml.model.SCXML;
 
 /**
- * Standalone SCXML Interpreter.
- * Useful for command-line testing and debugging.
+ * Standalone SCXML interpreter, useful for command-line testing and
+ * debugging.
+ *
+ * <p><b>USAGE:</b></p>
+ * <p><code>java org.apache.commons.scxml.env.jsp.Standalone url</code></p>
+ * <p>or</p>
+ * <p><code>java org.apache.commons.scxml.env.jsp.Standalone filename</code>
+ * </p>
+ *
+ * <p><b>RUNNING:</b></p>
+ * <p>Enter a space-separated list of "events"</p>
+ * <p>To quit, enter "quit"</p>
+ * <p>To populate a variable in the current context, type "name=value"</p>
+ * <p>To reset state machine, enter "reset"</p>
  *
  */
 public final class Standalone {
@@ -77,15 +90,32 @@
             while ((event = br.readLine()) != null) {
                 event = event.trim();
                 if (event.equalsIgnoreCase("help") || event.equals("?")) {
-                    System.out.println("enter a space-separated list of "
+                    System.out.println("Enter a space-separated list of "
                         + "events");
-                    System.out.println("to quit, enter \"quit\"");
-                    System.out.println("to reset state machine, enter "
+                    System.out.println("To populate a variable in the "
+                        + "current context, type \"name=value\"");
+                    System.out.println("To quit, enter \"quit\"");
+                    System.out.println("To reset state machine, enter "
                         + "\"reset\"");
                 } else if (event.equalsIgnoreCase("quit")) {
                     break;
                 } else if (event.equalsIgnoreCase("reset")) {
                     exec.reset();
+                } else if (event.indexOf('=') != -1) {
+                    int marker = event.indexOf('=');
+                    String name = event.substring(0, marker);
+                    String value = event.substring(marker + 1);
+                    rootCtx.setLocal(name, value);
+                    System.out.println("Set variable " + name + " to " +
+                        value);
+                } else if (SCXMLHelper.isStringEmpty(event)
+                           || event.equalsIgnoreCase("null")) {
+                    TriggerEvent[] evts = { new TriggerEvent(null,
+                    TriggerEvent.SIGNAL_EVENT, null) };
+                        exec.triggerEvents(evts);
+                    if (exec.getCurrentStatus().isFinal()) {
+                        System.out.println("A final configuration reached.");
+                    }
                 } else {
                     StringTokenizer st = new StringTokenizer(event);
                     int tkns = st.countTokens();



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org