commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1102425 - in /commons/sandbox/digester3/trunk/src: main/java/org/apache/commons/digester3/ main/java/org/apache/commons/digester3/annotations/providers/ main/java/org/apache/commons/digester3/annotations/rules/ test/java/org/apache/commons...
Date Thu, 12 May 2011 19:03:34 GMT
Author: simonetripodi
Date: Thu May 12 19:03:34 2011
New Revision: 1102425

URL: http://svn.apache.org/viewvc?rev=1102425&view=rev
Log:
added Generics to ObjectCreationFactory

Modified:
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/AbstractObjectCreationFactory.java
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/Digester.java
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/FactoryCreateRule.java
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/ObjectCreationFactory.java
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/providers/FactoryCreateRuleProvider.java
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/rules/FactoryCreate.java
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/ObjectCreationFactoryTestImpl.java
    commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/annotations/catalog/BookFactory.java

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/AbstractObjectCreationFactory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/AbstractObjectCreationFactory.java?rev=1102425&r1=1102424&r2=1102425&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/AbstractObjectCreationFactory.java
(original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/AbstractObjectCreationFactory.java
Thu May 12 19:03:34 2011
@@ -24,8 +24,8 @@ import org.xml.sax.Attributes;
  * Abstract base class for <code>ObjectCreationFactory</code> implementations.
  * </p>
  */
-abstract public class AbstractObjectCreationFactory
-    implements ObjectCreationFactory
+abstract public class AbstractObjectCreationFactory<T>
+    implements ObjectCreationFactory<T>
 {
 
     // ----------------------------------------------------- Instance Variables
@@ -44,7 +44,7 @@ abstract public class AbstractObjectCrea
      * @param attributes the element's attributes
      * @throws Exception any exception thrown will be propagated upwards
      */
-    public abstract Object createObject( Attributes attributes )
+    public abstract T createObject( Attributes attributes )
         throws Exception;
 
     /**

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=1102425&r1=1102424&r2=1102425&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
Thu May 12 19:03:34 2011
@@ -2171,7 +2171,7 @@ public class Digester
      * @param clazz Java class of the object creation factory class
      * @see FactoryCreateRule
      */
-    public void addFactoryCreate( String pattern, Class<?> clazz )
+    public void addFactoryCreate( String pattern, Class<? extends ObjectCreationFactory<?>>
clazz )
     {
 
         addFactoryCreate( pattern, clazz, false );
@@ -2218,7 +2218,7 @@ public class Digester
      * @param creationFactory Previously instantiated ObjectCreationFactory to be utilized
      * @see FactoryCreateRule
      */
-    public void addFactoryCreate( String pattern, ObjectCreationFactory creationFactory )
+    public void addFactoryCreate( String pattern, ObjectCreationFactory<?> creationFactory
)
     {
 
         addFactoryCreate( pattern, creationFactory, false );
@@ -2250,7 +2250,8 @@ public class Digester
      *            ignored.
      * @see FactoryCreateRule
      */
-    public void addFactoryCreate( String pattern, Class<?> clazz, boolean ignoreCreateExceptions
)
+    public void addFactoryCreate( String pattern, Class<? extends ObjectCreationFactory<?>>
clazz,
+                                  boolean ignoreCreateExceptions )
     {
 
         addRule( pattern, new FactoryCreateRule( clazz, ignoreCreateExceptions ) );
@@ -2300,7 +2301,7 @@ public class Digester
      *            ignored.
      * @see FactoryCreateRule
      */
-    public void addFactoryCreate( String pattern, ObjectCreationFactory creationFactory,
boolean ignoreCreateExceptions )
+    public void addFactoryCreate( String pattern, ObjectCreationFactory<?> creationFactory,
boolean ignoreCreateExceptions )
     {
 
         creationFactory.setDigester( this );

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/FactoryCreateRule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/FactoryCreateRule.java?rev=1102425&r1=1102424&r2=1102425&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/FactoryCreateRule.java
(original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/FactoryCreateRule.java
Thu May 12 19:03:34 2011
@@ -76,7 +76,7 @@ public class FactoryCreateRule
      * 
      * @param clazz Java class name of the object creation factory class
      */
-    public FactoryCreateRule( Class<?> clazz )
+    public FactoryCreateRule( Class<? extends ObjectCreationFactory<?>> clazz
)
     {
 
         this( clazz, false );
@@ -118,7 +118,7 @@ public class FactoryCreateRule
      * @param attributeName Attribute name which, if present, contains an override of the
class name of the object
      *            creation factory to create.
      */
-    public FactoryCreateRule( Class<?> clazz, String attributeName )
+    public FactoryCreateRule( Class<? extends ObjectCreationFactory<?>> clazz,
String attributeName )
     {
 
         this( clazz, attributeName, false );
@@ -135,7 +135,7 @@ public class FactoryCreateRule
      * 
      * @param creationFactory called on to create the object.
      */
-    public FactoryCreateRule( ObjectCreationFactory creationFactory )
+    public FactoryCreateRule( ObjectCreationFactory<?> creationFactory )
     {
 
         this( creationFactory, false );
@@ -163,7 +163,7 @@ public class FactoryCreateRule
      * @param clazz Java class name of the object creation factory class
      * @param ignoreCreateExceptions if true, exceptions thrown by the object creation factory
will be ignored.
      */
-    public FactoryCreateRule( Class<?> clazz, boolean ignoreCreateExceptions )
+    public FactoryCreateRule( Class<? extends ObjectCreationFactory<?>> clazz,
boolean ignoreCreateExceptions )
     {
 
         this( clazz, null, ignoreCreateExceptions );
@@ -212,7 +212,7 @@ public class FactoryCreateRule
      * @param creationFactory called on to create the object.
      * @param ignoreCreateExceptions if true, exceptions thrown by the object creation factory
will be ignored.
      */
-    public FactoryCreateRule( ObjectCreationFactory creationFactory, boolean ignoreCreateExceptions
)
+    public FactoryCreateRule( ObjectCreationFactory<?> creationFactory, boolean ignoreCreateExceptions
)
     {
 
         this.creationFactory = creationFactory;
@@ -235,7 +235,7 @@ public class FactoryCreateRule
      * The object creation factory we will use to instantiate objects as required based on
the attributes specified in
      * the matched XML element.
      */
-    protected ObjectCreationFactory creationFactory = null;
+    protected ObjectCreationFactory<?> creationFactory = null;
 
     // --------------------------------------------------------- Public Methods
 
@@ -385,7 +385,7 @@ public class FactoryCreateRule
      * @param attributes Attributes passed to our factory creation element
      * @exception Exception if any error occurs
      */
-    protected ObjectCreationFactory getFactory( Attributes attributes )
+    protected ObjectCreationFactory<?> getFactory( Attributes attributes )
         throws Exception
     {
 
@@ -406,7 +406,7 @@ public class FactoryCreateRule
                                                      + realClassName );
             }
             Class<?> clazz = getDigester().getClassLoader().loadClass( realClassName
);
-            creationFactory = (ObjectCreationFactory) clazz.newInstance();
+            creationFactory = (ObjectCreationFactory<?>) clazz.newInstance();
             creationFactory.setDigester( getDigester() );
         }
         return ( creationFactory );

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/ObjectCreationFactory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/ObjectCreationFactory.java?rev=1102425&r1=1102424&r2=1102425&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/ObjectCreationFactory.java
(original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/ObjectCreationFactory.java
Thu May 12 19:03:34 2011
@@ -29,7 +29,7 @@ import org.xml.sax.Attributes;
  * {@link AbstractObjectCreationFactory} is an abstract implementation suitable for creating
anonymous
  * <code>ObjectCreationFactory</code> implementations.
  */
-public interface ObjectCreationFactory
+public interface ObjectCreationFactory<T>
 {
 
     /**
@@ -39,7 +39,7 @@ public interface ObjectCreationFactory
      * @param attributes the element's attributes
      * @throws Exception any exception thrown will be propagated upwards
      */
-    Object createObject( Attributes attributes )
+    T createObject( Attributes attributes )
         throws Exception;
 
     /**

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/providers/FactoryCreateRuleProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/providers/FactoryCreateRuleProvider.java?rev=1102425&r1=1102424&r2=1102425&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/providers/FactoryCreateRuleProvider.java
(original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/providers/FactoryCreateRuleProvider.java
Thu May 12 19:03:34 2011
@@ -18,6 +18,7 @@
 package org.apache.commons.digester3.annotations.providers;
 
 import org.apache.commons.digester3.FactoryCreateRule;
+import org.apache.commons.digester3.ObjectCreationFactory;
 import org.apache.commons.digester3.annotations.AnnotationRuleProvider;
 import org.apache.commons.digester3.annotations.rules.FactoryCreate;
 
@@ -30,7 +31,7 @@ public final class FactoryCreateRuleProv
     implements AnnotationRuleProvider<FactoryCreate, Class<?>, FactoryCreateRule>
 {
 
-    private Class<?> factoryClass;
+    private Class<? extends ObjectCreationFactory<?>> factoryClass;
 
     private boolean ignoreCreateExceptions;
 

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/rules/FactoryCreate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/rules/FactoryCreate.java?rev=1102425&r1=1102424&r2=1102425&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/rules/FactoryCreate.java
(original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/annotations/rules/FactoryCreate.java
Thu May 12 19:03:34 2011
@@ -49,7 +49,7 @@ public @interface FactoryCreate
      * 
      * @return the Java class of the object creation factory class.
      */
-    Class<? extends AbstractObjectCreationFactory> factoryClass();
+    Class<? extends AbstractObjectCreationFactory<?>> factoryClass();
 
     /**
      * The element matching pattern.

Modified: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/ObjectCreationFactoryTestImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/ObjectCreationFactoryTestImpl.java?rev=1102425&r1=1102424&r2=1102425&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/ObjectCreationFactoryTestImpl.java
(original)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/ObjectCreationFactoryTestImpl.java
Thu May 12 19:03:34 2011
@@ -29,7 +29,7 @@ import org.xml.sax.helpers.AttributesImp
  */
 
 public class ObjectCreationFactoryTestImpl
-    extends AbstractObjectCreationFactory
+    extends AbstractObjectCreationFactory<Object>
 {
     public boolean called = false;
 

Modified: commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/annotations/catalog/BookFactory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/annotations/catalog/BookFactory.java?rev=1102425&r1=1102424&r2=1102425&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/annotations/catalog/BookFactory.java
(original)
+++ commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/annotations/catalog/BookFactory.java
Thu May 12 19:03:34 2011
@@ -24,13 +24,13 @@ import org.xml.sax.Attributes;
  * @since 2.1
  */
 public final class BookFactory
-    extends AbstractObjectCreationFactory
+    extends AbstractObjectCreationFactory<Book>
 {
 
     private final static String ISBN = "isbn";
 
     @Override
-    public Object createObject( Attributes attributes )
+    public Book createObject( Attributes attributes )
         throws Exception
     {
         String isbn = attributes.getValue( ISBN );



Mime
View raw message