commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r608631 - /commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java
Date Thu, 03 Jan 2008 21:17:33 GMT
Author: rahul
Date: Thu Jan  3 13:17:25 2008
New Revision: 608631

URL: http://svn.apache.org/viewvc?rev=608631&view=rev
Log:
Only render transition attributes if the values are not null, and try to render the target
attribute (as against target child element) where possible.

Modified:
    commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java?rev=608631&r1=608630&r2=608631&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java
(original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java
Thu Jan  3 13:17:25 2008
@@ -277,10 +277,20 @@
      */
     public static void serializeTransition(final StringBuffer b,
             final Transition t, final String indent) {
-        b.append(indent).append("<transition event=\"").append(t.getEvent())
-            .append("\" cond=\"").append(t.getCond()).append("\">\n");
+        b.append(indent).append("<transition");
+        if (!SCXMLHelper.isStringEmpty(t.getEvent())) {
+            b.append(" event=\"").append(t.getEvent()).append("\"");
+        }
+        if (!SCXMLHelper.isStringEmpty(t.getCond())) {
+            b.append(" cond=\"").append(t.getCond()).append("\"");
+        }
+        boolean next = !SCXMLHelper.isStringEmpty(t.getNext());
+        if (next) {
+            b.append(" target=\"" + t.getNext() + "\"");
+        }
+        b.append(">\n");
         boolean exit = serializeActions(b, t.getActions(), indent + INDENT);
-        if (!exit) {
+        if (!next && !exit) {
             serializeTarget(b, t, indent + INDENT);
         }
         b.append(indent).append("</transition>\n");
@@ -299,18 +309,12 @@
      */
     public static void serializeTarget(final StringBuffer b,
             final Transition t, final String indent) {
-        b.append(indent).append("<target");
-        String n = t.getNext();
-        if (n != null) {
-            b.append(" next=\"" + n + "\">\n");
-        } else {
-            b.append(">\n");
-            if (t.getTarget() != null) {
-                // The inline transition target can only be a state
-                serializeState(b, (State) t.getTarget(), indent + INDENT);
-            }
+        if (t.getTarget() != null) {
+            b.append(indent).append("<target>");
+            // The inline transition target can only be a state
+            serializeState(b, (State) t.getTarget(), indent + INDENT);
+            b.append(indent).append("</target>");
         }
-        b.append(indent).append("</target>\n");
     }
 
     /**



Mime
View raw message