commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1210032 - in /commons/proper/digester/trunk: RELEASE-NOTES.txt src/changes/changes.xml src/main/java/org/apache/commons/digester3/xmlrules/ObjectParamRule.java src/main/java/org/apache/commons/digester3/xmlrules/XmlRulesModule.java
Date Sun, 04 Dec 2011 00:08:27 GMT
Author: simonetripodi
Date: Sun Dec  4 00:08:27 2011
New Revision: 1210032

URL: http://svn.apache.org/viewvc?rev=1210032&view=rev
Log:
[DIGESTER-159] */object-param-rule is not managed in the XML rules

Added:
    commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/ObjectParamRule.java
  (with props)
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/xmlrules/XmlRulesModule.java

Modified: commons/proper/digester/trunk/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/RELEASE-NOTES.txt?rev=1210032&r1=1210031&r2=1210032&view=diff
==============================================================================
--- commons/proper/digester/trunk/RELEASE-NOTES.txt (original)
+++ commons/proper/digester/trunk/RELEASE-NOTES.txt Sun Dec  4 00:08:27 2011
@@ -55,6 +55,7 @@ NEW FEATURES
 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

Modified: commons/proper/digester/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/changes/changes.xml?rev=1210032&r1=1210031&r2=1210032&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/changes/changes.xml (original)
+++ commons/proper/digester/trunk/src/changes/changes.xml Sun Dec  4 00:08:27 2011
@@ -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>

Added: commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/ObjectParamRule.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/ObjectParamRule.java?rev=1210032&view=auto
==============================================================================
--- commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/ObjectParamRule.java
(added)
+++ commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/ObjectParamRule.java
Sun Dec  4 00:08:27 2011
@@ -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 );
+        }
+    }
+
+}

Propchange: commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/ObjectParamRule.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/ObjectParamRule.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/ObjectParamRule.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/XmlRulesModule.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/XmlRulesModule.java?rev=1210032&r1=1210031&r2=1210032&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/XmlRulesModule.java
(original)
+++ commons/proper/digester/trunk/src/main/java/org/apache/commons/digester3/xmlrules/XmlRulesModule.java
Sun Dec  4 00:08:27 2011
@@ -89,6 +89,7 @@ final class XmlRulesModule
             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" )



Mime
View raw message