commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r1547205 - in /commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2: io/SCXMLReader.java model/SCXML.java
Date Mon, 02 Dec 2013 21:46:57 GMT
Author: woonsan
Date: Mon Dec  2 21:46:57 2013
New Revision: 1547205

URL: http://svn.apache.org/r1547205
Log:
SCXML-177: give a warning when there's a custom action with a nonexisting custom action

Modified:
    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/model/SCXML.java

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/io/SCXMLReader.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/io/SCXMLReader.java?rev=1547205&r1=1547204&r2=1547205&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/io/SCXMLReader.java
(original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/io/SCXMLReader.java
Mon Dec  2 21:46:57 2013
@@ -1425,14 +1425,20 @@ public final class SCXMLReader {
                         } else {
                             reportIgnoredElement(reader, configuration, end, nsURI, name);
                         }
-                    } else if (configuration.customActions.size() > 0) {
-                        for (CustomAction ca : configuration.customActions) {
-                            if (ca.getNamespaceURI().equals(nsURI) && ca.getLocalName().equals(name))
{
-                                readCustomAction(reader, configuration, ca, tt, executable,
iff);
+                    } else { // custom action
+                        CustomAction customAction = null;
+                        if (!configuration.customActions.isEmpty()) {
+                            for (CustomAction ca : configuration.customActions) {
+                                if (ca.getNamespaceURI().equals(nsURI) && ca.getLocalName().equals(name))
{
+                                    customAction = ca;
+                                }
                             }
                         }
-                    } else {
-                        reportIgnoredElement(reader, configuration, end, nsURI, name);
+                        if (customAction != null) {
+                            readCustomAction(reader, configuration, customAction, tt, executable,
iff);
+                        } else {
+                            reportIgnoredElement(reader, configuration, end, nsURI, name);
+                        }
                     }
                     break;
                 case XMLStreamConstants.END_ELEMENT:
@@ -2067,7 +2073,7 @@ public final class SCXMLReader {
 
         org.apache.commons.logging.Log log = LogFactory.getLog(SCXMLReader.class);
         StringBuffer sb = new StringBuffer();
-        sb.append("Ignoring element <").append(name).append("> in namespace \"").append(nsURI).append("\"
as child ").
+        sb.append("Ignoring unknown or invalid element <").append(name).append("> in
namespace \"").append(nsURI).append("\" as child ").
             append(" of <").append(parent).append("> at ").append(reader.getLocation());
         log.warn(sb.toString());
         XMLReporter reporter = configuration.reporter;

Modified: commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/SCXML.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/SCXML.java?rev=1547205&r1=1547204&r2=1547205&view=diff
==============================================================================
--- commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/SCXML.java (original)
+++ commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml2/model/SCXML.java Mon
Dec  2 21:46:57 2013
@@ -162,14 +162,17 @@ public class SCXML implements Serializab
     }
 
     /**
-     * Get the first immediate child target of the SCXML root.
+     * Get the first immediate child target of the SCXML root. Return null if there's no
child.
      *
-     * @return TransitionTarget Returns the first immediate child target of the SCXML root.
+     * @return TransitionTarget Returns the first immediate child target of the SCXML root.
Return null if there's no child.
      *
      * @since 2.0
      */
     public final TransitionTarget getFirstChild() {
-        return children.values().iterator().next();
+        if (!children.isEmpty()) {
+            return children.values().iterator().next();
+        }
+        return null;
     }
 
     /**



Mime
View raw message