commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1076176 - in /commons/sandbox/digester3/trunk/src: main/java/org/apache/commons/digester3/Digester.java main/java/org/apache/commons/digester3/internal/DigesterImpl.java test/java/org/apache/commons/digester3/plugins/TestXmlRuleInfo.java
Date Wed, 02 Mar 2011 11:39:45 GMT
Author: simonetripodi
Date: Wed Mar  2 11:39:44 2011
New Revision: 1076176

URL: http://svn.apache.org/viewvc?rev=1076176&view=rev
Log:
added 'auto-cast' feature also for Digester.getRoot() method

Modified:
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/Digester.java
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/DigesterImpl.java
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestXmlRuleInfo.java

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/Digester.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/Digester.java?rev=1076176&r1=1076175&r2=1076176&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/Digester.java
(original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/Digester.java
Wed Mar  2 11:39:44 2011
@@ -294,7 +294,7 @@ public interface Digester extends Conten
      * @return the root object that has been created after parsing
      *  or null if the digester has not parsed any XML yet.
      */
-    Object getRoot();
+    <T> T getRoot();
 
     /**
      * This method allows the "root" variable to be reset to null.

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/DigesterImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/DigesterImpl.java?rev=1076176&r1=1076175&r2=1076176&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/DigesterImpl.java
(original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/DigesterImpl.java
Wed Mar  2 11:39:44 2011
@@ -380,8 +380,8 @@ public final class DigesterImpl implemen
     /**
      * {@inheritDoc}
      */
-    public Object getRoot() {
-        return this.root;
+    public <T> T getRoot() {
+        return this.<T>npeSafeCast(this.root);
     }
 
     /**
@@ -1048,7 +1048,7 @@ public final class DigesterImpl implemen
         try {
             this.reader.parse(input);
 
-            return this.<T>npeSafeCast(this.root);
+            return this.<T>getRoot();
         } finally {
             this.cleanup();
         }

Modified: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestXmlRuleInfo.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestXmlRuleInfo.java?rev=1076176&r1=1076175&r2=1076176&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestXmlRuleInfo.java
(original)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/plugins/TestXmlRuleInfo.java
Wed Mar  2 11:39:44 2011
@@ -71,9 +71,7 @@ public class TestXmlRuleInfo extends Abs
 
         digester.parse(new StringReader(input.toString()));
 
-        Object root = digester.getRoot();
-        assertEquals(ObjectTestImpl.class, root.getClass());
-        ObjectTestImpl testObject = (ObjectTestImpl) root;
+        ObjectTestImpl testObject = digester.getRoot();
         assertEquals("xmlrules1", testObject.getValue());
     }
 
@@ -96,9 +94,7 @@ public class TestXmlRuleInfo extends Abs
 
         digester.parse(new StringReader(input.toString()));
 
-        Object root = digester.getRoot();
-        assertEquals(ObjectTestImpl.class, root.getClass());
-        ObjectTestImpl testObject = (ObjectTestImpl) root;
+        ObjectTestImpl testObject = digester.getRoot();
         assertEquals("xmlrules2", testObject.getValue());
     }
 
@@ -119,9 +115,7 @@ public class TestXmlRuleInfo extends Abs
 
         digester.parse(new StringReader(input.toString()));
 
-        Object root = digester.getRoot();
-        assertEquals(ObjectTestImpl.class, root.getClass());
-        ObjectTestImpl testObject = (ObjectTestImpl) root;
+        ObjectTestImpl testObject = digester.getRoot();
         assertEquals("xmlrules-ruleinfo", testObject.getValue());
     }
 



Mime
View raw message