[DIGESTER-159] */object-param-rule is not managed in the XML rules
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/digester/trunk@1210032 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index cd94138..ee6f451 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -55,6 +55,7 @@
BUGS FIXED SINCE PREVIOUS RELEASE
===========================
+ * [DIGESTER-159] */object-param-rule is not managed in the XML rules.
* [DIGESTER-155] ClassLoader reference set to DigesterLoader not set in produced Digester instances
IMPROVEMENTS OVER PREVIOUS RELEASE
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index bad048c..d17ebdf 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -23,6 +23,9 @@
</properties>
<body>
<release version="3.2" date="201?-??-??" description="Maintenance release.">
+ <action dev="simonetripodi" type="fix" issue="DIGESTER-159">
+ */object-param-rule is not managed in the XML rules
+ </action>
<action dev="simonetripodi" type="fix" issue="DIGESTER-157">
Improve Set(Nested)PropertiesRuleAlias performances in the XML ruleset while binding rules.
</action>
diff --git a/src/main/java/org/apache/commons/digester3/xmlrules/ObjectParamRule.java b/src/main/java/org/apache/commons/digester3/xmlrules/ObjectParamRule.java
new file mode 100644
index 0000000..b2f17e8
--- /dev/null
+++ b/src/main/java/org/apache/commons/digester3/xmlrules/ObjectParamRule.java
@@ -0,0 +1,81 @@
+package org.apache.commons.digester3.xmlrules;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static java.lang.Integer.parseInt;
+import static org.apache.commons.beanutils.ConvertUtils.convert;
+
+import org.apache.commons.digester3.binder.LinkedRuleBuilder;
+import org.apache.commons.digester3.binder.ObjectParamBuilder;
+import org.apache.commons.digester3.binder.RulesBinder;
+import org.xml.sax.Attributes;
+
+/**
+ * @since 3.2
+ */
+final class ObjectParamRule
+ extends AbstractXmlRule
+{
+
+ /**
+ * @param targetRulesBinder
+ * @param patternStack
+ */
+ public ObjectParamRule( RulesBinder targetRulesBinder, PatternStack patternStack )
+ {
+ super( targetRulesBinder, patternStack );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void bindRule( LinkedRuleBuilder linkedRuleBuilder, Attributes attributes )
+ throws Exception
+ {
+ // create callparamrule
+ String paramNumber = attributes.getValue( "paramnumber" );
+ String attributeName = attributes.getValue( "attrname" );
+ String type = attributes.getValue( "type" );
+ String value = attributes.getValue( "value" );
+
+ int paramIndex = parseInt( paramNumber );
+
+ // create object instance
+ Class<?> clazz = getDigester().getClassLoader().loadClass( type );
+ Object param;
+ if ( value != null )
+ {
+ param = convert( value, clazz );
+ }
+ else
+ {
+ param = clazz.newInstance();
+ }
+
+ ObjectParamBuilder<?> builder = linkedRuleBuilder.objectParam( param ).ofIndex( paramIndex );
+
+ if ( attributeName != null )
+ {
+ builder.matchingAttribute( attributeName );
+ }
+ }
+
+}
diff --git a/src/main/java/org/apache/commons/digester3/xmlrules/XmlRulesModule.java b/src/main/java/org/apache/commons/digester3/xmlrules/XmlRulesModule.java
index 8d572ef..bdcfbc0 100644
--- a/src/main/java/org/apache/commons/digester3/xmlrules/XmlRulesModule.java
+++ b/src/main/java/org/apache/commons/digester3/xmlrules/XmlRulesModule.java
@@ -89,6 +89,7 @@
forPattern( "*/factory-create-rule" ).addRule( new FactoryCreateRule( targetRulesBinder, patternStack ) );
forPattern( "*/node-create-rule" ).addRule( new NodeCreateRule( targetRulesBinder, patternStack ) );
forPattern( "*/object-create-rule" ).addRule( new ObjectCreateRule( targetRulesBinder, patternStack ) );
+ forPattern( "*/object-param-rule" ).addRule( new ObjectParamRule( targetRulesBinder, patternStack ) );
forPattern( "*/set-properties-rule" ).addRule( new SetPropertiesRule( targetRulesBinder, patternStack ) );
forPattern( "*/set-properties-rule/alias" )