commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r610557 - /commons/proper/scxml/branches/J5/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java
Date Wed, 09 Jan 2008 20:44:33 GMT
Author: rahul
Date: Wed Jan  9 12:44:10 2008
New Revision: 610557

URL: http://svn.apache.org/viewvc?rev=610557&view=rev
Log:
Type safety improvements, remove unnecessary casts.

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

Modified: commons/proper/scxml/branches/J5/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java
URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J5/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java?rev=610557&r1=610556&r2=610557&view=diff
==============================================================================
--- commons/proper/scxml/branches/J5/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java
(original)
+++ commons/proper/scxml/branches/J5/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java
Wed Jan  9 12:44:10 2008
@@ -103,10 +103,10 @@
         if (dm != null) {
             serializeDatamodel(b, dm, INDENT);
         }
-        Map c = scxml.getChildren();
+        Map<String, TransitionTarget> c = scxml.getChildren();
         Iterator i = c.keySet().iterator();
         while (i.hasNext()) {
-            TransitionTarget tt = (TransitionTarget) c.get(i.next());
+            TransitionTarget tt = c.get(i.next());
             if (tt instanceof State) {
                 serializeState(b, (State) tt, INDENT);
             } else {
@@ -137,7 +137,7 @@
         if (ini != null) {
             serializeInitial(b, ini, indent + INDENT);
         }
-        List h = s.getHistory();
+        List<History> h = s.getHistory();
         if (h != null) {
             serializeHistory(b, h, indent + INDENT);
         }
@@ -146,19 +146,19 @@
             serializeDatamodel(b, dm, indent + INDENT);
         }
         serializeOnEntry(b, s, indent + INDENT);
-        List t = s.getTransitionsList();
+        List<Transition> t = s.getTransitionsList();
         for (int i = 0; i < t.size(); i++) {
-            serializeTransition(b, (Transition) t.get(i), indent + INDENT);
+            serializeTransition(b, t.get(i), indent + INDENT);
         }
-        Parallel p = s.getParallel(); //TODO: Remove in v1.0
+        Parallel p = s.getParallel();
         Invoke inv = s.getInvoke();
         if (p != null) {
             serializeParallel(b, p, indent + INDENT);
         } else if (inv != null) {
             serializeInvoke(b , inv, indent + INDENT);
         } else {
-            Map c = s.getChildren();
-            Iterator j = c.keySet().iterator();
+            Map<String, TransitionTarget> c = s.getChildren();
+            Iterator<String> j = c.keySet().iterator();
             while (j.hasNext()) {
                 State cs = (State) c.get(j.next());
                 serializeState(b, cs, indent + INDENT);
@@ -181,8 +181,8 @@
         serializeTransitionTargetAttributes(b, p);
         b.append(">\n");
         serializeOnEntry(b, p, indent + INDENT);
-        Set s = p.getChildren();
-        Iterator i = s.iterator();
+        Set<TransitionTarget> s = p.getChildren();
+        Iterator<TransitionTarget> i = s.iterator();
         while (i.hasNext()) {
             serializeState(b, (State) i.next(), indent + INDENT);
         }
@@ -213,9 +213,9 @@
             b.append(" srcexpr=\"").append(srcexpr).append("\"");
         }
         b.append(">\n");
-        List params = i.params();
-        for (Iterator iter = params.iterator(); iter.hasNext();) {
-            Param p = (Param) iter.next();
+        List<Param> params = i.params();
+        for (Iterator<Param> iter = params.iterator(); iter.hasNext();) {
+            Param p = iter.next();
             b.append(indent).append(INDENT).append("<param name=\"").
                 append(p.getName()).append("\" expr=\"").
                 append(p.getExpr()).append("\"/>\n");
@@ -252,11 +252,11 @@
      * @param l The List of History objects to serialize
      * @param indent The indent for this XML element
      */
-    public static void serializeHistory(final StringBuffer b, final List l,
+    public static void serializeHistory(final StringBuffer b, final List<History> l,
             final String indent) {
         if (l.size() > 0) {
             for (int i = 0; i < l.size(); i++) {
-                History h = (History) l.get(i);
+                History h = l.get(i);
                 b.append(indent).append("<history");
                 serializeTransitionTargetAttributes(b, h);
                  if (h.isDeep()) {
@@ -329,7 +329,7 @@
      */
     public static void serializeDatamodel(final StringBuffer b,
             final Datamodel dm, final String indent) {
-        List data = dm.getData();
+        List<Data> data = dm.getData();
         if (data != null && data.size() > 0) {
             b.append(indent).append("<datamodel>\n");
             if (XFORMER == null) {
@@ -338,8 +338,8 @@
                 b.append(indent).append("</datamodel>\n");
                 return;
             }
-            for (Iterator iter = data.iterator(); iter.hasNext();) {
-                Data datum = (Data) iter.next();
+            for (Iterator<Data> iter = data.iterator(); iter.hasNext();) {
+                Data datum = iter.next();
                 Node dataNode = datum.getNode();
                 if (dataNode != null) {
                     StringWriter out = new StringWriter();
@@ -407,15 +407,15 @@
      * @param indent The indent for this XML element
      * @return boolean true if the list of actions contains an &lt;exit/&gt;
      */
-    public static boolean serializeActions(final StringBuffer b, final List l,
+    public static boolean serializeActions(final StringBuffer b, final List<Action>
l,
             final String indent) {
         if (l == null) {
             return false;
         }
         boolean exit = false;
-        Iterator i = l.iterator();
+        Iterator<Action> i = l.iterator();
         while (i.hasNext()) {
-            Action a = (Action) i.next();
+            Action a = i.next();
             if (a instanceof Var) {
                 Var v = (Var) a;
                 b.append(indent).append("<var name=\"").append(v.getName())
@@ -503,13 +503,13 @@
     public static final String getBodyContent(
             final ExternalContent externalContent) {
         StringBuffer buf = new StringBuffer();
-        List externalNodes = externalContent.getExternalNodes();
+        List<Node> externalNodes = externalContent.getExternalNodes();
         if (externalNodes.size() > 0 && XFORMER == null) {
             buf.append("<!-- Body content was not serialized -->\n");
             return buf.toString();
         }
         for (int i = 0; i < externalNodes.size(); i++) {
-            Source input = new DOMSource((Node) externalNodes.get(i));
+            Source input = new DOMSource(externalNodes.get(i));
             StringWriter out = new StringWriter();
             Result output = new StreamResult(out);
             try {



Mime
View raw message