commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1197969 - in /commons/proper/digester/trunk: ./ src/changes/ src/main/java/org/apache/commons/digester3/annotations/handlers/ src/main/java/org/apache/commons/digester3/binder/ src/main/java/org/apache/commons/digester3/xmlrules/ src/test/...
Date Sat, 05 Nov 2011 15:15:10 GMT
Author: simonetripodi
Date: Sat Nov  5 15:15:10 2011
New Revision: 1197969

URL: http://svn.apache.org/viewvc?rev=1197969&view=rev
Log:
[DIGESTER-156] Make (Nested|Set)PropertiesBuilder#addAlias() fluent

Modified:
    commons/proper/digester/trunk/RELEASE-NOTES.txt
    commons/proper/digester/trunk/src/changes/changes.xml
    commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/annotations/handlers/SetPropertiesHandler.java
    commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/binder/NestedPropertiesBuilder.java
    commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/binder/SetPropertiesBuilder.java
    commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/SetNestedPropertiesAliasRule.java
    commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/SetPropertiesAliasRule.java
    commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/SetNestedPropertiesRuleTestCase.java
    commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/SetPropertiesRuleTestCase.java

Modified: commons/proper/digester/trunk/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/RELEASE-NOTES.txt?rev=1197969&r1=1197968&r2=1197969&view=diff
==============================================================================
--- commons/proper/digester/trunk/RELEASE-NOTES.txt (original)
+++ commons/proper/digester/trunk/RELEASE-NOTES.txt Sat Nov  5 15:15:10 2011
@@ -60,6 +60,7 @@ BUGS FIXED SINCE PREVIOUS RELEASE
 IMPROVEMENTS OVER PREVIOUS RELEASE
 ===================================
 
+ * [DIGESTER-156] Make (Nested|Set)PropertiesBuilder#addAlias() fluent.
  * [DIGESTER-152] The DigesterLoader doesn't allow binding a default Locator
  * [DIGESTER-151] The DigesterLoader doesn't allow binding a default ErrorHandler.
 

Modified: commons/proper/digester/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/changes/changes.xml?rev=1197969&r1=1197968&r2=1197969&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/changes/changes.xml (original)
+++ commons/proper/digester/trunk/src/changes/changes.xml Sat Nov  5 15:15:10 2011
@@ -23,6 +23,9 @@
   </properties>
   <body>
   <release version="3.2" date="201?-??-??" description="Maintenance release.">
+    <action dev="simonetripodi" type="fix" issue="DIGESTER-156">
+      Make (Nested|Set)PropertiesBuilder#addAlias() fluent.
+    </action>
     <action dev="simonetripodi" type="fix" issue="DIGESTER-155">
       ClassLoader reference set to DigesterLoader not set in produced Digester instances
     </action>

Modified: commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/annotations/handlers/SetPropertiesHandler.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/annotations/handlers/SetPropertiesHandler.java?rev=1197969&r1=1197968&r2=1197969&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/annotations/handlers/SetPropertiesHandler.java
(original)
+++ commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/annotations/handlers/SetPropertiesHandler.java
Sat Nov  5 15:15:10 2011
@@ -48,7 +48,7 @@ public final class SetPropertiesHandler
         if ( annotation.attributeName() != null && annotation.attributeName().length()
> 0
             && !element.getName().equals( annotation.attributeName() ) )
         {
-            builder.addAlias( annotation.attributeName(), element.getName() );
+            builder.addAlias( annotation.attributeName() ).forProperty( element.getName()
);
         }
     }
 

Modified: commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/binder/NestedPropertiesBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/binder/NestedPropertiesBuilder.java?rev=1197969&r1=1197968&r2=1197969&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/binder/NestedPropertiesBuilder.java
(original)
+++ commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/binder/NestedPropertiesBuilder.java
Sat Nov  5 15:15:10 2011
@@ -57,11 +57,7 @@ public final class NestedPropertiesBuild
         {
             reportError( "setNestedProperties().ignoreElement( String )", "empty 'elementName'
not allowed" );
         }
-        else
-        {
-            addAlias( elementName, null );
-        }
-        return this;
+        return addAlias( elementName ).forProperty( null );
     }
 
     /**
@@ -70,18 +66,28 @@ public final class NestedPropertiesBuild
      * @param elementName The child xml element to match
      * @param propertyName The java bean property to be assigned the value
      * @return this builder instance
+     * @deprecated
      */
+    @Deprecated
     public NestedPropertiesBuilder addAlias( String elementName, String propertyName )
     {
+        return addAlias( elementName ).forProperty( propertyName );
+    }
+
+    /**
+     * Allows element2property mapping to be overridden.
+     *
+     * @param elementName
+     * @return the property alias builder
+     * @since 3.2
+     */
+    public AddAliasBuilder<NestedPropertiesBuilder> addAlias( String elementName )
+    {
         if ( elementName == null )
         {
-            reportError( "setNestedProperties().addAlias( String,String )", "empty 'elementName'
not allowed" );
+            reportError( "setProperties().addAlias( String )", "empty 'elementName' not allowed"
);
         }
-        else
-        {
-            elementNames.put( elementName, propertyName );
-        }
-        return this;
+        return new AddAliasBuilder<NestedPropertiesBuilder>( this, elementNames, elementName
);
     }
 
     /**

Modified: commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/binder/SetPropertiesBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/binder/SetPropertiesBuilder.java?rev=1197969&r1=1197968&r2=1197969&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/binder/SetPropertiesBuilder.java
(original)
+++ commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/binder/SetPropertiesBuilder.java
Sat Nov  5 15:15:10 2011
@@ -47,18 +47,28 @@ public final class SetPropertiesBuilder
      * @param attributeName The attribute to match
      * @param propertyName The java bean property to be assigned the value
      * @return this builder instance
+     * @deprecated
      */
+    @Deprecated
     public SetPropertiesBuilder addAlias( String attributeName, String propertyName )
     {
+        return addAlias( attributeName ).forProperty( propertyName );
+    }
+
+    /**
+     * Add an additional attribute name to property name mapping.
+     *
+     * @param attributeName The attribute to match
+     * @return the property alias builder
+     * @since 3.2
+     */
+    public AddAliasBuilder<SetPropertiesBuilder> addAlias( String attributeName )
+    {
         if ( attributeName == null )
         {
-            reportError( "setProperties().addAlias( String,String )", "empty 'attributeName'
not allowed" );
+            reportError( "setProperties().addAlias( String )", "empty 'attributeName' not
allowed" );
         }
-        else
-        {
-            aliases.put( attributeName, propertyName );
-        }
-        return this;
+        return new AddAliasBuilder<SetPropertiesBuilder>( this, aliases, attributeName
);
     }
 
     /**
@@ -73,16 +83,12 @@ public final class SetPropertiesBuilder
         {
             reportError( "setProperties().ignoreAttribute( String )", "empty 'attributeName'
not allowed" );
         }
-        else
-        {
-            addAlias( attributeName, null );
-        }
-        return this;
+        return addAlias( attributeName ).forProperty( null );
     }
 
     /**
      * Sets whether attributes found in the XML without matching properties should be ignored.
-     * 
+     *
      * If set to false, the parsing will throw an {@code NoSuchMethodException}
      * if an unmatched attribute is found.
      * This allows to trap misspellings in the XML file.

Modified: commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/SetNestedPropertiesAliasRule.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/SetNestedPropertiesAliasRule.java?rev=1197969&r1=1197968&r2=1197969&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/SetNestedPropertiesAliasRule.java
(original)
+++ commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/SetNestedPropertiesAliasRule.java
Sat Nov  5 15:15:10 2011
@@ -24,7 +24,7 @@ import org.apache.commons.digester3.bind
 import org.xml.sax.Attributes;
 
 /**
- * 
+ *
  */
 final class SetNestedPropertiesAliasRule
     extends AbstractXmlRule
@@ -45,7 +45,7 @@ final class SetNestedPropertiesAliasRule
         String elementName = attributes.getValue( "attr-name" );
         String propertyName = attributes.getValue( "prop-name" );
 
-        linkedRuleBuilder.setNestedProperties().addAlias( elementName, propertyName );
+        linkedRuleBuilder.setNestedProperties().addAlias( elementName ).forProperty( propertyName
);
     }
 
 }

Modified: commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/SetPropertiesAliasRule.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/SetPropertiesAliasRule.java?rev=1197969&r1=1197968&r2=1197969&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/SetPropertiesAliasRule.java
(original)
+++ commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/SetPropertiesAliasRule.java
Sat Nov  5 15:15:10 2011
@@ -24,7 +24,7 @@ import org.apache.commons.digester3.bind
 import org.xml.sax.Attributes;
 
 /**
- * 
+ *
  */
 final class SetPropertiesAliasRule
     extends AbstractXmlRule
@@ -45,7 +45,7 @@ final class SetPropertiesAliasRule
         String attributeName = attributes.getValue( "attr-name" );
         String propertyName = attributes.getValue( "prop-name" );
 
-        linkedRuleBuilder.setProperties().addAlias( attributeName, propertyName );
+        linkedRuleBuilder.setProperties().addAlias( attributeName ).forProperty( propertyName
);
     }
 
 }

Modified: commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/SetNestedPropertiesRuleTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/SetNestedPropertiesRuleTestCase.java?rev=1197969&r1=1197968&r2=1197969&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/SetNestedPropertiesRuleTestCase.java
(original)
+++ commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/SetNestedPropertiesRuleTestCase.java
Sat Nov  5 15:15:10 2011
@@ -142,9 +142,9 @@ public class SetNestedPropertiesRuleTest
                 forPattern( "root" ).createObject().ofType( "org.apache.commons.digester3.SimpleTestBean"
)
                     .then()
                     .setNestedProperties()
-                        .addAlias( "alpha", null )
-                        .addAlias( "gamma-alt", "gamma" )
-                        .addAlias( "delta", null );
+                        .addAlias( "alpha" ).forProperty( null )
+                        .addAlias( "gamma-alt" ).forProperty( "gamma" )
+                        .addAlias( "delta" ).forProperty(  null );
             }
 
         }).newDigester();
@@ -184,7 +184,7 @@ public class SetNestedPropertiesRuleTest
                 forPattern( "root" ).createObject().ofType( "org.apache.commons.digester3.SimpleTestBean"
)
                     .then()
                     .setNestedProperties()
-                        .addAlias( "alpha", null );
+                        .addAlias( "alpha" ).forProperty( null );
             }
 
         }).newDigester();
@@ -224,7 +224,7 @@ public class SetNestedPropertiesRuleTest
                 forPattern( "root" ).createObject().ofType( "org.apache.commons.digester3.SimpleTestBean"
)
                     .then()
                     .setNestedProperties()
-                        .addAlias( "alpha-alt", "alpha" );
+                        .addAlias( "alpha-alt" ).forProperty( "alpha" );
             }
 
         }).newDigester();

Modified: commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/SetPropertiesRuleTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/SetPropertiesRuleTestCase.java?rev=1197969&r1=1197968&r2=1197969&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/SetPropertiesRuleTestCase.java
(original)
+++ commons/proper/digester/trunk/src/test/java/org/apache/commons/digester3/SetPropertiesRuleTestCase.java
Sat Nov  5 15:15:10 2011
@@ -198,7 +198,7 @@ public class SetPropertiesRuleTestCase
                 forPattern( "root" ).createObject().ofType( "org.apache.commons.digester3.SimpleTestBean"
)
                     .then()
                     .setProperties()
-                        .addAlias( "ignore", null )
+                        .addAlias( "ignore" ).forProperty( null )
                         .ignoreMissingProperty( false );
             }
 



Mime
View raw message