commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r612273 - /commons/proper/scxml/branches/J5/src/main/java/org/apache/commons/scxml/SCXMLExecutor.java
Date Tue, 15 Jan 2008 22:49:42 GMT
Author: rahul
Date: Tue Jan 15 14:49:40 2008
New Revision: 612273

URL: http://svn.apache.org/viewvc?rev=612273&view=rev
Log:
Use for-each to reduce clutter.

Modified:
    commons/proper/scxml/branches/J5/src/main/java/org/apache/commons/scxml/SCXMLExecutor.java

Modified: commons/proper/scxml/branches/J5/src/main/java/org/apache/commons/scxml/SCXMLExecutor.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J5/src/main/java/org/apache/commons/scxml/SCXMLExecutor.java?rev=612273&r1=612272&r2=612273&view=diff
==============================================================================
--- commons/proper/scxml/branches/J5/src/main/java/org/apache/commons/scxml/SCXMLExecutor.java
(original)
+++ commons/proper/scxml/branches/J5/src/main/java/org/apache/commons/scxml/SCXMLExecutor.java
Tue Jan 15 14:49:40 2008
@@ -20,7 +20,6 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -224,9 +223,7 @@
                 scInstance.getEvaluator(), log);
         }
         // all states and parallels, only states have variable contexts
-        for (Iterator i = stateMachine.getTargets().values().iterator();
-                i.hasNext();) {
-            TransitionTarget tt = (TransitionTarget) i.next();
+        for (TransitionTarget tt : stateMachine.getTargets().values()) {
             if (tt instanceof State) {
                 Context context = scInstance.lookupContext(tt);
                 if (context != null) {
@@ -462,16 +459,12 @@
      */
     private void logState() {
         if (log.isDebugEnabled()) {
-            Iterator si = currentStatus.getStates().iterator();
-            StringBuffer sb = new StringBuffer("Current States: [");
-            while (si.hasNext()) {
-                State s = (State) si.next();
-                sb.append(s.getId());
-                if (si.hasNext()) {
-                    sb.append(", ");
-                }
+            StringBuffer sb = new StringBuffer("Current States: [ ");
+            for (TransitionTarget tt : currentStatus.getStates()) {
+                sb.append(tt.getId()).append(", ");
             }
-            sb.append(']');
+            int length = sb.length();
+            sb.delete(length - 2, length).append(" ]");
             log.debug(sb.toString());
         }
     }
@@ -499,8 +492,7 @@
         if (len > 0) { // 0 has retry semantics (eg: see usage in reset())
             Object eventData = null;
             Map<String, Object> payloadMap = new HashMap<String, Object>();
-            for (int i = 0; i < len; i++) {
-                TriggerEvent te = evts[i];
+            for (TriggerEvent te : evts) {
                 payloadMap.put(te.getName(), te.getPayload());
             }
             if (len == 1) {



Mime
View raw message