You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2011/02/11 15:19:33 UTC
svn commit: r1069805 [1/2] - in /commons/sandbox/digester3/trunk/src:
main/java/org/apache/commons/digester3/
main/java/org/apache/commons/digester3/internal/rulesbinder/
main/java/org/apache/commons/digester3/rule/
main/java/org/apache/commons/digeste...
Author: simonetripodi
Date: Fri Feb 11 14:19:30 2011
New Revision: 1069805
URL: http://svn.apache.org/viewvc?rev=1069805&view=rev
Log:
Rule concrete implementations moved into a proper package
Added:
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractMethodRule.java (with props)
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractObjectCreationFactory.java (with props)
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractRulesModule.java (with props)
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/BeanPropertySetterRule.java (with props)
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/CallMethodRule.java (with props)
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/CallParamRule.java (with props)
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/FactoryCreateRule.java (with props)
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/ObjectCreateRule.java (with props)
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/ObjectParamRule.java (with props)
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/PathCallParamRule.java (with props)
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/RulesBinder.java (with props)
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/RulesModule.java (with props)
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/SetNestedPropertiesRule.java (with props)
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/SetNextRule.java (with props)
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/SetPropertiesRule.java (with props)
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/SetPropertyRule.java (with props)
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/SetRootRule.java (with props)
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/SetTopRule.java (with props)
Removed:
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/AbstractMethodRule.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/AbstractObjectCreationFactory.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/AbstractRulesModule.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/BeanPropertySetterRule.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/CallMethodRule.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/CallParamRule.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/ObjectCreateRule.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/ObjectParamRule.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/PathCallParamRule.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/RulesBinder.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/RulesModule.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetNestedPropertiesRule.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetNextRule.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetPropertiesRule.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetPropertyRule.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetRootRule.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/SetTopRule.java
Modified:
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/DigesterLoader.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/AbstractBackToLinkedRuleBuilder.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/AbstractParamTypeBuilder.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/BeanPropertySetterBuilderImpl.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ByRuleBuilderImpl.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ByRuleProviderBuilderImpl.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/CallMethodBuilderImpl.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/CallParamBuilderImpl.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ErrorMessage.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/FactoryCreateBuilderImpl.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/LinkedRuleBuilderImpl.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/NestedPropertiesBuilderImpl.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ObjectCreateBuilderImpl.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ObjectParamBuilderImpl.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/PathCallParamBuilderImpl.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/RulesBinderImpl.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetNextBuilderImpl.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetPropertiesBuilderImpl.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetPropertyBuilderImpl.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetRootBuilderImpl.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetTopBuilderImpl.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rulesbinder/BeanPropertySetterBuilder.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rulesbinder/CallMethodBuilder.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rulesbinder/CallParamBuilder.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rulesbinder/FactoryCreateBuilder.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rulesbinder/LinkedRuleBuilder.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rulesbinder/NestedPropertiesBuilder.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rulesbinder/ObjectCreateBuilder.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rulesbinder/ObjectParamBuilder.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rulesbinder/PathCallParamBuilder.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rulesbinder/SetNextBuilder.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rulesbinder/SetPropertiesBuilder.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rulesbinder/SetPropertyBuilder.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rulesbinder/SetRootBuilder.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rulesbinder/SetTopBuilder.java
commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/spi/ObjectCreationFactory.java
commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/AbstractTestCase.java
commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/BeanPropertySetterRuleTestCase.java
commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/DigesterTestCase.java
commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/EmployeeModule.java
commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/NamespaceSnapshotTestCase.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/ObjectParamRuleTestCase.java
commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/SetNestedPropertiesRuleTestCase.java
commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/SetPropertiesRuleTestCase.java
commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/SetPropertyRuleTestCase.java
commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/TestFactoryCreate.java
commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/URLTestCase.java
commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/rules/BaseRulesTestCase.java
commons/sandbox/digester3/trunk/src/test/java/org/apache/commons/digester3/substitution/VariableExpansionTestCase.java
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/DigesterLoader.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/DigesterLoader.java?rev=1069805&r1=1069804&r2=1069805&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/DigesterLoader.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/DigesterLoader.java Fri Feb 11 14:19:30 2011
@@ -32,6 +32,8 @@ import javax.xml.validation.Schema;
import org.apache.commons.digester3.internal.DigesterImpl;
import org.apache.commons.digester3.internal.rulesbinder.RulesBinderImpl;
+import org.apache.commons.digester3.rule.RulesBinder;
+import org.apache.commons.digester3.rule.RulesModule;
import org.apache.commons.digester3.rules.BaseRules;
import org.apache.commons.digester3.spi.Rules;
import org.apache.commons.digester3.spi.Substitutor;
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/AbstractBackToLinkedRuleBuilder.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/AbstractBackToLinkedRuleBuilder.java?rev=1069805&r1=1069804&r2=1069805&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/AbstractBackToLinkedRuleBuilder.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/AbstractBackToLinkedRuleBuilder.java Fri Feb 11 14:19:30 2011
@@ -18,7 +18,7 @@
package org.apache.commons.digester3.internal.rulesbinder;
import org.apache.commons.digester3.Rule;
-import org.apache.commons.digester3.RulesBinder;
+import org.apache.commons.digester3.rule.RulesBinder;
import org.apache.commons.digester3.rulesbinder.BackToLinkedRuleBuilder;
import org.apache.commons.digester3.rulesbinder.LinkedRuleBuilder;
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/AbstractParamTypeBuilder.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/AbstractParamTypeBuilder.java?rev=1069805&r1=1069804&r2=1069805&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/AbstractParamTypeBuilder.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/AbstractParamTypeBuilder.java Fri Feb 11 14:19:30 2011
@@ -18,7 +18,7 @@
package org.apache.commons.digester3.internal.rulesbinder;
import org.apache.commons.digester3.Rule;
-import org.apache.commons.digester3.RulesBinder;
+import org.apache.commons.digester3.rule.RulesBinder;
import org.apache.commons.digester3.rulesbinder.ParamTypeBuilder;
/**
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/BeanPropertySetterBuilderImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/BeanPropertySetterBuilderImpl.java?rev=1069805&r1=1069804&r2=1069805&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/BeanPropertySetterBuilderImpl.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/BeanPropertySetterBuilderImpl.java Fri Feb 11 14:19:30 2011
@@ -17,8 +17,8 @@
*/
package org.apache.commons.digester3.internal.rulesbinder;
-import org.apache.commons.digester3.BeanPropertySetterRule;
-import org.apache.commons.digester3.RulesBinder;
+import org.apache.commons.digester3.rule.BeanPropertySetterRule;
+import org.apache.commons.digester3.rule.RulesBinder;
import org.apache.commons.digester3.rulesbinder.BeanPropertySetterBuilder;
/**
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ByRuleBuilderImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ByRuleBuilderImpl.java?rev=1069805&r1=1069804&r2=1069805&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ByRuleBuilderImpl.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ByRuleBuilderImpl.java Fri Feb 11 14:19:30 2011
@@ -18,7 +18,7 @@
package org.apache.commons.digester3.internal.rulesbinder;
import org.apache.commons.digester3.Rule;
-import org.apache.commons.digester3.RulesBinder;
+import org.apache.commons.digester3.rule.RulesBinder;
import org.apache.commons.digester3.rulesbinder.ByRuleBuilder;
final class ByRuleBuilderImpl<R extends Rule> extends AbstractBackToLinkedRuleBuilder<R> implements ByRuleBuilder<R> {
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ByRuleProviderBuilderImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ByRuleProviderBuilderImpl.java?rev=1069805&r1=1069804&r2=1069805&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ByRuleProviderBuilderImpl.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ByRuleProviderBuilderImpl.java Fri Feb 11 14:19:30 2011
@@ -18,7 +18,7 @@
package org.apache.commons.digester3.internal.rulesbinder;
import org.apache.commons.digester3.Rule;
-import org.apache.commons.digester3.RulesBinder;
+import org.apache.commons.digester3.rule.RulesBinder;
import org.apache.commons.digester3.rulesbinder.ByRuleProviderBuilder;
import org.apache.commons.digester3.spi.RuleProvider;
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/CallMethodBuilderImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/CallMethodBuilderImpl.java?rev=1069805&r1=1069804&r2=1069805&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/CallMethodBuilderImpl.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/CallMethodBuilderImpl.java Fri Feb 11 14:19:30 2011
@@ -19,8 +19,8 @@ package org.apache.commons.digester3.int
import java.util.Arrays;
-import org.apache.commons.digester3.CallMethodRule;
-import org.apache.commons.digester3.RulesBinder;
+import org.apache.commons.digester3.rule.CallMethodRule;
+import org.apache.commons.digester3.rule.RulesBinder;
import org.apache.commons.digester3.rulesbinder.CallMethodBuilder;
/**
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/CallParamBuilderImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/CallParamBuilderImpl.java?rev=1069805&r1=1069804&r2=1069805&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/CallParamBuilderImpl.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/CallParamBuilderImpl.java Fri Feb 11 14:19:30 2011
@@ -17,8 +17,8 @@
*/
package org.apache.commons.digester3.internal.rulesbinder;
-import org.apache.commons.digester3.CallParamRule;
-import org.apache.commons.digester3.RulesBinder;
+import org.apache.commons.digester3.rule.CallParamRule;
+import org.apache.commons.digester3.rule.RulesBinder;
import org.apache.commons.digester3.rulesbinder.CallParamBuilder;
/**
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ErrorMessage.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ErrorMessage.java?rev=1069805&r1=1069804&r2=1069805&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ErrorMessage.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ErrorMessage.java Fri Feb 11 14:19:30 2011
@@ -20,7 +20,7 @@ package org.apache.commons.digester3.int
/**
* An error message and the context in which it occurred. Messages are usually created internally by
* {@code Digester} and its extensions. Messages can be created explicitly in a module using
- * {@link org.apache.commons.digester3.RulesBinder#addError(Throwable) addError()} statement:
+ * {@link org.apache.commons.digester3.rule.RulesBinder#addError(Throwable) addError()} statement:
* <pre>try {
* bindRulesFromFile();
* } catch (IOException e) {
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/FactoryCreateBuilderImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/FactoryCreateBuilderImpl.java?rev=1069805&r1=1069804&r2=1069805&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/FactoryCreateBuilderImpl.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/FactoryCreateBuilderImpl.java Fri Feb 11 14:19:30 2011
@@ -17,8 +17,8 @@
*/
package org.apache.commons.digester3.internal.rulesbinder;
-import org.apache.commons.digester3.FactoryCreateRule;
-import org.apache.commons.digester3.RulesBinder;
+import org.apache.commons.digester3.rule.FactoryCreateRule;
+import org.apache.commons.digester3.rule.RulesBinder;
import org.apache.commons.digester3.rulesbinder.FactoryCreateBuilder;
import org.apache.commons.digester3.spi.ObjectCreationFactory;
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/LinkedRuleBuilderImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/LinkedRuleBuilderImpl.java?rev=1069805&r1=1069804&r2=1069805&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/LinkedRuleBuilderImpl.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/LinkedRuleBuilderImpl.java Fri Feb 11 14:19:30 2011
@@ -20,7 +20,7 @@ package org.apache.commons.digester3.int
import java.util.Collection;
import org.apache.commons.digester3.Rule;
-import org.apache.commons.digester3.RulesBinder;
+import org.apache.commons.digester3.rule.RulesBinder;
import org.apache.commons.digester3.rulesbinder.BeanPropertySetterBuilder;
import org.apache.commons.digester3.rulesbinder.ByRuleBuilder;
import org.apache.commons.digester3.rulesbinder.ByRuleProviderBuilder;
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/NestedPropertiesBuilderImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/NestedPropertiesBuilderImpl.java?rev=1069805&r1=1069804&r2=1069805&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/NestedPropertiesBuilderImpl.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/NestedPropertiesBuilderImpl.java Fri Feb 11 14:19:30 2011
@@ -20,8 +20,8 @@ package org.apache.commons.digester3.int
import java.util.HashMap;
import java.util.Map;
-import org.apache.commons.digester3.RulesBinder;
-import org.apache.commons.digester3.SetNestedPropertiesRule;
+import org.apache.commons.digester3.rule.RulesBinder;
+import org.apache.commons.digester3.rule.SetNestedPropertiesRule;
import org.apache.commons.digester3.rulesbinder.NestedPropertiesBuilder;
/**
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ObjectCreateBuilderImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ObjectCreateBuilderImpl.java?rev=1069805&r1=1069804&r2=1069805&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ObjectCreateBuilderImpl.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ObjectCreateBuilderImpl.java Fri Feb 11 14:19:30 2011
@@ -17,8 +17,8 @@
*/
package org.apache.commons.digester3.internal.rulesbinder;
-import org.apache.commons.digester3.ObjectCreateRule;
-import org.apache.commons.digester3.RulesBinder;
+import org.apache.commons.digester3.rule.ObjectCreateRule;
+import org.apache.commons.digester3.rule.RulesBinder;
import org.apache.commons.digester3.rulesbinder.ObjectCreateBuilder;
/**
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ObjectParamBuilderImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ObjectParamBuilderImpl.java?rev=1069805&r1=1069804&r2=1069805&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ObjectParamBuilderImpl.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/ObjectParamBuilderImpl.java Fri Feb 11 14:19:30 2011
@@ -17,8 +17,8 @@
*/
package org.apache.commons.digester3.internal.rulesbinder;
-import org.apache.commons.digester3.ObjectParamRule;
-import org.apache.commons.digester3.RulesBinder;
+import org.apache.commons.digester3.rule.ObjectParamRule;
+import org.apache.commons.digester3.rule.RulesBinder;
import org.apache.commons.digester3.rulesbinder.ObjectParamBuilder;
/**
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/PathCallParamBuilderImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/PathCallParamBuilderImpl.java?rev=1069805&r1=1069804&r2=1069805&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/PathCallParamBuilderImpl.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/PathCallParamBuilderImpl.java Fri Feb 11 14:19:30 2011
@@ -17,8 +17,8 @@
*/
package org.apache.commons.digester3.internal.rulesbinder;
-import org.apache.commons.digester3.PathCallParamRule;
-import org.apache.commons.digester3.RulesBinder;
+import org.apache.commons.digester3.rule.PathCallParamRule;
+import org.apache.commons.digester3.rule.RulesBinder;
import org.apache.commons.digester3.rulesbinder.PathCallParamBuilder;
/**
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/RulesBinderImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/RulesBinderImpl.java?rev=1069805&r1=1069804&r2=1069805&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/RulesBinderImpl.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/RulesBinderImpl.java Fri Feb 11 14:19:30 2011
@@ -26,8 +26,8 @@ import java.util.List;
import org.apache.commons.digester3.DigesterLoadingException;
import org.apache.commons.digester3.Rule;
-import org.apache.commons.digester3.RulesBinder;
-import org.apache.commons.digester3.RulesModule;
+import org.apache.commons.digester3.rule.RulesBinder;
+import org.apache.commons.digester3.rule.RulesModule;
import org.apache.commons.digester3.rulesbinder.ConverterBuilder;
import org.apache.commons.digester3.rulesbinder.LinkedRuleBuilder;
import org.apache.commons.digester3.spi.Rules;
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetNextBuilderImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetNextBuilderImpl.java?rev=1069805&r1=1069804&r2=1069805&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetNextBuilderImpl.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetNextBuilderImpl.java Fri Feb 11 14:19:30 2011
@@ -17,8 +17,8 @@
*/
package org.apache.commons.digester3.internal.rulesbinder;
-import org.apache.commons.digester3.RulesBinder;
-import org.apache.commons.digester3.SetNextRule;
+import org.apache.commons.digester3.rule.RulesBinder;
+import org.apache.commons.digester3.rule.SetNextRule;
import org.apache.commons.digester3.rulesbinder.SetNextBuilder;
final class SetNextBuilderImpl extends AbstractParamTypeBuilder<SetNextRule> implements SetNextBuilder {
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetPropertiesBuilderImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetPropertiesBuilderImpl.java?rev=1069805&r1=1069804&r2=1069805&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetPropertiesBuilderImpl.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetPropertiesBuilderImpl.java Fri Feb 11 14:19:30 2011
@@ -20,8 +20,8 @@ package org.apache.commons.digester3.int
import java.util.HashMap;
import java.util.Map;
-import org.apache.commons.digester3.RulesBinder;
-import org.apache.commons.digester3.SetPropertiesRule;
+import org.apache.commons.digester3.rule.RulesBinder;
+import org.apache.commons.digester3.rule.SetPropertiesRule;
import org.apache.commons.digester3.rulesbinder.SetPropertiesBuilder;
/**
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetPropertyBuilderImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetPropertyBuilderImpl.java?rev=1069805&r1=1069804&r2=1069805&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetPropertyBuilderImpl.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetPropertyBuilderImpl.java Fri Feb 11 14:19:30 2011
@@ -17,8 +17,8 @@
*/
package org.apache.commons.digester3.internal.rulesbinder;
-import org.apache.commons.digester3.RulesBinder;
-import org.apache.commons.digester3.SetPropertyRule;
+import org.apache.commons.digester3.rule.RulesBinder;
+import org.apache.commons.digester3.rule.SetPropertyRule;
import org.apache.commons.digester3.rulesbinder.SetPropertyBuilder;
/**
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetRootBuilderImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetRootBuilderImpl.java?rev=1069805&r1=1069804&r2=1069805&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetRootBuilderImpl.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetRootBuilderImpl.java Fri Feb 11 14:19:30 2011
@@ -17,8 +17,8 @@
*/
package org.apache.commons.digester3.internal.rulesbinder;
-import org.apache.commons.digester3.RulesBinder;
-import org.apache.commons.digester3.SetRootRule;
+import org.apache.commons.digester3.rule.RulesBinder;
+import org.apache.commons.digester3.rule.SetRootRule;
import org.apache.commons.digester3.rulesbinder.SetRootBuilder;
final class SetRootBuilderImpl extends AbstractParamTypeBuilder<SetRootRule> implements SetRootBuilder {
Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetTopBuilderImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetTopBuilderImpl.java?rev=1069805&r1=1069804&r2=1069805&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetTopBuilderImpl.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/internal/rulesbinder/SetTopBuilderImpl.java Fri Feb 11 14:19:30 2011
@@ -17,8 +17,8 @@
*/
package org.apache.commons.digester3.internal.rulesbinder;
-import org.apache.commons.digester3.RulesBinder;
-import org.apache.commons.digester3.SetTopRule;
+import org.apache.commons.digester3.rule.RulesBinder;
+import org.apache.commons.digester3.rule.SetTopRule;
import org.apache.commons.digester3.rulesbinder.SetTopBuilder;
final class SetTopBuilderImpl extends AbstractParamTypeBuilder<SetTopRule> implements SetTopBuilder {
Added: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractMethodRule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractMethodRule.java?rev=1069805&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractMethodRule.java (added)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractMethodRule.java Fri Feb 11 14:19:30 2011
@@ -0,0 +1,140 @@
+/* $Id$
+ *
+ * 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.
+ */
+package org.apache.commons.digester3.rule;
+
+import java.util.Formatter;
+
+import org.apache.commons.beanutils.MethodUtils;
+import org.apache.commons.digester3.Rule;
+
+/**
+ * Abstract Rule for setNext(), setRoot() and setTop() rules.
+ */
+abstract class AbstractMethodRule extends Rule {
+
+ /**
+ * The method name to call on the parent object.
+ */
+ private final String methodName;
+
+ /**
+ * The Java class name of the parameter type expected by the method.
+ */
+ private final String paramType;
+
+ /**
+ * Should we use exact matching.
+ */
+ private final boolean useExactMatch;
+
+ /**
+ * The sole constructor
+ *
+ * @param methodName
+ * @param paramType
+ * @param useExactMatch
+ */
+ public AbstractMethodRule(String methodName, String paramType, boolean useExactMatch) {
+ this.methodName = methodName;
+ this.paramType = paramType;
+ this.useExactMatch = useExactMatch;
+ }
+
+ public final String getMethodName() {
+ return this.methodName;
+ }
+
+ public final String getParamType() {
+ return this.paramType;
+ }
+
+ /**
+ * <p>Is exact matching being used.</p>
+ *
+ * <p>This rule uses <code>org.apache.commons.beanutils.MethodUtils</code>
+ * to introspect the relevent objects so that the right method can be called.
+ * Originally, <code>MethodUtils.invokeExactMethod</code> was used.
+ * This matches methods very strictly
+ * and so may not find a matching method when one exists.
+ * This is still the behaviour when exact matching is enabled.</p>
+ *
+ * <p>When exact matching is disabled, <code>MethodUtils.invokeMethod</code> is used.
+ * This method finds more methods but is less precise when there are several methods
+ * with correct signatures.
+ * So, if you want to choose an exact signature you might need to enable this property.</p>
+ *
+ * <p>The default setting is to disable exact matches.</p>
+ *
+ * @return true if exact matching is enabled
+ */
+ public final boolean isExactMatch() {
+ return this.useExactMatch;
+ }
+
+ /**
+ *
+ *
+ * @param target
+ * @param arg
+ * @param logType
+ * @throws Exception
+ */
+ protected final void invoke(Object target, Object arg, String logType) throws Exception {
+ if (this.getDigester().getLog().isDebugEnabled()) {
+ Formatter formatter = new Formatter().format("[%s]{%s}",
+ this.getClass().getSimpleName(),
+ this.getDigester().getMatch());
+
+ if (target == null) {
+ formatter.format(" Call [NULL %s]", logType);
+ } else {
+ formatter.format(" Call %s", target.getClass().getName());
+ }
+
+ formatter.format(".%s(%s)", this.getMethodName(), arg);
+
+ this.getDigester().getLog().debug(formatter.toString());
+ }
+
+ Class<?> paramTypes[] = new Class<?>[1];
+ if (this.getParamType() != null) {
+ paramTypes[0] = this.getDigester().getClassLoader().loadClass(this.getParamType());
+ } else {
+ paramTypes[0] = arg.getClass();
+ }
+
+ if (this.isExactMatch()) {
+ MethodUtils.invokeExactMethod(target, this.getMethodName(), new Object[]{ arg }, paramTypes);
+ } else {
+ MethodUtils.invokeMethod(target, this.getMethodName(), new Object[]{ arg }, paramTypes);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public final String toString() {
+ return String.format("%s[methodName=%s, paramType=%s, useExactMatch=%s]",
+ this.getClass().getSimpleName(),
+ this.methodName,
+ this.paramType,
+ this.useExactMatch);
+ }
+
+}
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractMethodRule.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractMethodRule.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractMethodRule.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractObjectCreationFactory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractObjectCreationFactory.java?rev=1069805&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractObjectCreationFactory.java (added)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractObjectCreationFactory.java Fri Feb 11 14:19:30 2011
@@ -0,0 +1,63 @@
+/* $Id$
+ *
+ * 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.
+ */
+package org.apache.commons.digester3.rule;
+
+import org.apache.commons.digester3.Digester;
+import org.apache.commons.digester3.spi.ObjectCreationFactory;
+import org.xml.sax.Attributes;
+
+/**
+ * Abstract base class for {@link ObjectCreationFactory} implementations.
+ */
+abstract public class AbstractObjectCreationFactory<T> implements ObjectCreationFactory<T> {
+
+ /**
+ * The associated <code>Digester</code> instance that was set up by
+ * {@link FactoryCreateRule} upon initialization.
+ */
+ private Digester digester = null;
+
+ /**
+ * <p>Factory method called by {@link FactoryCreateRule} to supply an
+ * object based on the element's attributes.
+ *
+ * @param attributes the element's attributes
+ *
+ * @throws Exception any exception thrown will be propagated upwards
+ */
+ public abstract T createObject(Attributes attributes) throws Exception;
+
+ /**
+ * <p>Returns the {@link Digester} that was set by the
+ * {@link FactoryCreateRule} upon initialization.
+ */
+ public Digester getDigester() {
+ return this.digester;
+ }
+
+ /**
+ * <p>Set the {@link Digester} to allow the implementation to do logging,
+ * classloading based on the digester's classloader, etc.
+ *
+ * @param digester parent Digester object
+ */
+ public void setDigester(Digester digester) {
+ this.digester = digester;
+ }
+
+}
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractObjectCreationFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractObjectCreationFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractObjectCreationFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractRulesModule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractRulesModule.java?rev=1069805&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractRulesModule.java (added)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractRulesModule.java Fri Feb 11 14:19:30 2011
@@ -0,0 +1,87 @@
+/* $Id$
+ *
+ * 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.
+ */
+package org.apache.commons.digester3.rule;
+
+import org.apache.commons.digester3.rulesbinder.ConverterBuilder;
+import org.apache.commons.digester3.rulesbinder.LinkedRuleBuilder;
+
+/**
+ * A support class for RulesModule which reduces repetition and results in a more readable configuration.
+ */
+public abstract class AbstractRulesModule implements RulesModule {
+
+ private RulesBinder rulesBinder;
+
+ /**
+ * @see RulesBinder#addError(String, Object...)
+ */
+ protected void addError(String messagePattern, Object... arguments) {
+ this.rulesBinder.addError(messagePattern, arguments);
+ }
+
+ /**
+ * @see RulesBinder#addError(Throwable)
+ */
+ protected void addError(Throwable t) {
+ this.rulesBinder.addError(t);
+ }
+
+ /**
+ * @see RulesBinder#install(RulesModule)
+ */
+ protected void install(RulesModule rulesModule) {
+ this.rulesBinder.install(rulesModule);
+ }
+
+ /**
+ * @see RulesBinder#forPattern(String)
+ * @param pattern
+ * @return
+ */
+ protected LinkedRuleBuilder forPattern(String pattern) {
+ return this.rulesBinder.forPattern(pattern);
+ }
+
+ /**
+ * @see RulesBinder#convert(Class)
+ * @param <T>
+ * @param type
+ * @return
+ */
+ protected <T> ConverterBuilder<T> convert(Class<T> type) {
+ return this.rulesBinder.convert(type);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public final void configure(RulesBinder rulesBinder) {
+ this.rulesBinder = rulesBinder;
+ try {
+ this.configure();
+ } finally {
+ this.rulesBinder = null;
+ }
+ }
+
+ /**
+ * Configures a {@link Binder} via the exposed methods.
+ */
+ protected abstract void configure();
+
+}
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractRulesModule.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractRulesModule.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/AbstractRulesModule.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/BeanPropertySetterRule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/BeanPropertySetterRule.java?rev=1069805&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/BeanPropertySetterRule.java (added)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/BeanPropertySetterRule.java Fri Feb 11 14:19:30 2011
@@ -0,0 +1,153 @@
+/* $Id$
+ *
+ * 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.
+ */
+package org.apache.commons.digester3.rule;
+
+import java.beans.PropertyDescriptor;
+
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.beanutils.DynaBean;
+import org.apache.commons.beanutils.DynaProperty;
+import org.apache.commons.beanutils.PropertyUtils;
+import org.apache.commons.digester3.Rule;
+
+/**
+ * <p> Rule implements sets a bean property on the top object
+ * to the body text.</p>
+ *
+ * <p> The property set:</p>
+ * <ul><li>can be specified when the rule is created</li>
+ * <li>or can match the current element when the rule is called.</li></ul>
+ *
+ * <p> Using the second method and the {@link ExtendedBaseRules} child match
+ * pattern, all the child elements can be automatically mapped to properties
+ * on the parent object.</p>
+ */
+public class BeanPropertySetterRule extends Rule {
+
+ /**
+ * Set this property on the top object.
+ */
+ private final String propertyName; // @Nullable
+
+ /**
+ * The body text used to set the property.
+ */
+ private String bodyText = null;
+
+ /**
+ * <p>Construct rule that sets the given property from the body text.</p>
+ *
+ * @param propertyName name of property to set
+ */
+ public BeanPropertySetterRule(String propertyName) {
+ this.propertyName = propertyName;
+ }
+
+ /**
+ * Process the body text of this element.
+ *
+ * @param namespace the namespace URI of the matching element, or an
+ * empty string if the parser is not namespace aware or the element has
+ * no namespace
+ * @param name the local name if the parser is namespace aware, or just
+ * the element name otherwise
+ * @param text The text of the body of this element
+ */
+ @Override
+ public void body(String namespace, String name, String text) throws Exception {
+ // log some debugging information
+ if (this.getDigester().getLog().isDebugEnabled()) {
+ this.getDigester().getLog().debug(String.format("[BeanPropertySetterRule]{%s} Called with text '%s'",
+ this.getDigester().getMatch(),
+ text));
+ }
+
+ this.bodyText = text.trim();
+ }
+
+ /**
+ * Process the end of this element.
+ *
+ * @param namespace the namespace URI of the matching element, or an
+ * empty string if the parser is not namespace aware or the element has
+ * no namespace
+ * @param name the local name if the parser is namespace aware, or just
+ * the element name otherwise
+ *
+ * @exception NoSuchMethodException if the bean does not
+ * have a writeable property of the specified name
+ */
+ @Override
+ public void end(String namespace, String name) throws Exception {
+ String property = this.propertyName;
+
+ if (property == null) {
+ // If we don't have a specific property name,
+ // use the element name.
+ property = name;
+ }
+
+ // Get a reference to the top object
+ Object top = this.getDigester().peek();
+
+ // log some debugging information
+ if (this.getDigester().getLog().isDebugEnabled()) {
+ this.getDigester().getLog().debug(String.format("[BeanPropertySetterRule]{%s} Set %s property %s with text %s",
+ this.getDigester().getMatch(),
+ top.getClass().getName(),
+ property,
+ this.bodyText));
+ }
+
+ // Force an exception if the property does not exist
+ // (BeanUtils.setProperty() silently returns in this case)
+ if (top instanceof DynaBean) {
+ DynaProperty desc = ((DynaBean) top).getDynaClass().getDynaProperty(property);
+ if (desc == null) {
+ throw new NoSuchMethodException("Bean has no property named "
+ + property);
+ }
+ } else /* this is a standard JavaBean */ {
+ PropertyDescriptor desc = PropertyUtils.getPropertyDescriptor(top, property);
+ if (desc == null) {
+ throw new NoSuchMethodException("Bean has no property named "
+ + property);
+ }
+ }
+
+ // Set the property (with conversion as necessary)
+ BeanUtils.setProperty(top, property, this.bodyText);
+ }
+
+ /**
+ * Clean up after parsing is complete.
+ */
+ @Override
+ public void finish() throws Exception {
+ this.bodyText = null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return String.format("BeanPropertySetterRule[%s]", this.propertyName);
+ }
+
+}
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/BeanPropertySetterRule.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/BeanPropertySetterRule.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/BeanPropertySetterRule.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/CallMethodRule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/CallMethodRule.java?rev=1069805&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/CallMethodRule.java (added)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/CallMethodRule.java Fri Feb 11 14:19:30 2011
@@ -0,0 +1,345 @@
+/* $Id$
+ *
+ * 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.
+ */
+package org.apache.commons.digester3.rule;
+
+import java.util.Formatter;
+
+import org.apache.commons.beanutils.ConvertUtils;
+import org.apache.commons.beanutils.MethodUtils;
+import org.apache.commons.digester3.Rule;
+import org.xml.sax.Attributes;
+
+/**
+ * <p>Rule implementation that calls a method on an object on the stack
+ * (normally the top/parent object), passing arguments collected from
+ * subsequent <code>CallParamRule</code> rules or from the body of this
+ * element. </p>
+ *
+ * <p>By using {@link #CallMethodRule(String methodName)}
+ * a method call can be made to a method which accepts no
+ * arguments.</p>
+ *
+ * <p>Incompatible method parameter types are converted
+ * using <code>org.apache.commons.beanutils.ConvertUtils</code>.
+ * </p>
+ *
+ * <p>This rule now uses {@link MethodUtils#invokeMethod} by default.
+ * This increases the kinds of methods successfully and allows primitives
+ * to be matched by passing in wrapper classes.
+ * There are rare cases when {@link MethodUtils#invokeExactMethod}
+ * (the old default) is required.
+ * This method is much stricter in it's reflection.
+ * Setting the <code>UseExactMatch</code> to true reverts to the use of this
+ * method.</p>
+ *
+ * <p>Note that the target method is invoked when the <i>end</i> of
+ * the tag the CallMethodRule fired on is encountered, <i>not</i> when the
+ * last parameter becomes available. This implies that rules which fire on
+ * tags nested within the one associated with the CallMethodRule will
+ * fire before the CallMethodRule invokes the target method. This behaviour is
+ * not configurable. </p>
+ *
+ * <p>Note also that if a CallMethodRule is expecting exactly one parameter
+ * and that parameter is not available (eg CallParamRule is used with an
+ * attribute name but the attribute does not exist) then the method will
+ * not be invoked. If a CallMethodRule is expecting more than one parameter,
+ * then it is always invoked, regardless of whether the parameters were
+ * available or not; missing parameters are converted to the appropriate target
+ * type by calling ConvertUtils.convert. Note that the default ConvertUtils
+ * converters for the String type returns a null when passed a null, meaning
+ * that CallMethodRule will passed null for all String parameters for which
+ * there is no parameter info available from the XML. However parameters of
+ * type Float and Integer will be passed a real object containing a zero value
+ * as that is the output of the default ConvertUtils converters for those
+ * types when passed a null. You can register custom converters to change
+ * this behaviour; see the beautils library documentation for more info.</p>
+ *
+ * <p>Note that when a constructor is used with paramCount=0, indicating that
+ * the body of the element is to be passed to the target method, an empty
+ * element will cause an <i>empty string</i> to be passed to the target method,
+ * not null. And if automatic type conversion is being applied (ie if the
+ * target function takes something other than a string as a parameter) then
+ * the conversion will fail if the converter class does not accept an empty
+ * string as valid input.</p>
+ *
+ * <p>CallMethodRule has a design flaw which can cause it to fail under
+ * certain rule configurations. All CallMethodRule instances share a single
+ * parameter stack, and all CallParamRule instances simply store their data
+ * into the parameter-info structure that is on the top of the stack. This
+ * means that two CallMethodRule instances cannot be associated with the
+ * same pattern without getting scrambled parameter data. This same issue
+ * also applies when a CallMethodRule matches some element X, a different
+ * CallMethodRule matches a child element Y and some of the CallParamRules
+ * associated with the first CallMethodRule match element Y or one of its
+ * child elements. This issue has been present since the very first release
+ * of this.getDigester(). Note, however, that this configuration of CallMethodRule
+ * instances is not commonly required.</p>
+ */
+public class CallMethodRule extends Rule {
+
+ /**
+ * location of the target object for the call, relative to the
+ * top of the digester object stack. The default value of zero
+ * means the target object is the one on top of the stack.
+ */
+ private final int targetOffset;
+
+ /**
+ * The method name to call on the parent object.
+ */
+ private final String methodName;
+
+ /**
+ * The parameter types of the parameters to be collected.
+ */
+ private final Class<?> paramTypes[];
+
+ /**
+ * Should <code>MethodUtils.invokeExactMethod</code> be used for reflection.
+ */
+ private final boolean useExactMatch;
+
+ /**
+ * The body text collected from this element.
+ */
+ private String bodyText = null;
+
+ /**
+ * Construct a "call method" rule with the specified method name and
+ * parameter types. If <code>paramCount</code> is set to zero the rule
+ * will use the body of this element as the single argument of the
+ * method, unless <code>paramTypes</code> is null or empty, in this
+ * case the rule will call the specified method with no arguments.
+ *
+ * @param targetOffset location of the target object. Positive numbers are
+ * relative to the top of the digester object stack. Negative numbers
+ * are relative to the bottom of the stack. Zero implies the top
+ * object on the stack.
+ * @param methodName Method name of the parent method to call
+ * @param paramCount The number of parameters to collect, or
+ * zero for a single argument from the body of ths element
+ * @param paramTypes The Java classes that represent the
+ * parameter types of the method arguments
+ * (if you wish to use a primitive type, specify the corresonding
+ * Java wrapper class instead, such as <code>java.lang.Boolean.TYPE</code>
+ * for a <code>boolean</code> parameter)
+ * @param useExactMatch Should <code>MethodUtils.invokeExactMethod</code>
+ * be used for the reflection.
+ */
+ public CallMethodRule(int targetOffset, String methodName, int paramCount, Class<?>[] paramTypes, boolean useExactMatch) {
+ this.targetOffset = targetOffset;
+ this.methodName = methodName;
+
+ // copy the parameter class into an array
+ this.paramTypes = new Class[paramTypes.length];
+ System.arraycopy(paramTypes, 0, this.paramTypes, 0, paramTypes.length);
+
+ this.useExactMatch = useExactMatch;
+ }
+
+ /**
+ * Process the start of this element.
+ *
+ * @param attributes The attribute list for this element
+ */
+ @Override
+ public void begin(String namespace, String name, Attributes attributes) throws Exception {
+ // Push an array to capture the parameter values if necessary
+ if (this.paramTypes.length > 0) {
+ Object parameters[] = new Object[this.paramTypes.length];
+ for (int i = 0; i < parameters.length; i++) {
+ parameters[i] = null;
+ }
+ this.getDigester().pushParams(parameters);
+ }
+ }
+
+ /**
+ * Process the body text of this element.
+ *
+ * @param bodyText The body text of this element
+ */
+ @Override
+ public void body(String namespace, String name, String text) throws Exception {
+ if (this.paramTypes.length == 1) {
+ this.bodyText = text.trim();
+ }
+ }
+
+ /**
+ * Process the end of this element.
+ */
+ @Override
+ public void end(String namespace, String name) throws Exception {
+ // Retrieve or construct the parameter values array
+ Object parameters[] = null;
+ if (this.paramTypes.length > 0) {
+
+ parameters = (Object[]) this.getDigester().popParams();
+
+ if (this.getDigester().getLog().isTraceEnabled()) {
+ Formatter formatter = new Formatter("[CallMethodRule]");
+
+ for (int i = 0, size = parameters.length; i < size; i++) {
+ if (i > 0) {
+ formatter.format(", ");
+ }
+ formatter.format("(%s) %s", i, parameters[i]);
+ }
+
+ this.getDigester().getLog().trace(formatter.toString());
+ }
+
+ // In the case where the target method takes a single parameter
+ // and that parameter does not exist (the CallParamRule never
+ // executed or the CallParamRule was intended to set the parameter
+ // from an attribute but the attribute wasn't present etc) then
+ // skip the method call.
+ //
+ // This is useful when a class has a "default" value that should
+ // only be overridden if data is present in the XML. I don't
+ // know why this should only apply to methods taking *one*
+ // parameter, but it always has been so we can't change it now.
+ if (this.paramTypes.length == 1 && parameters[0] == null) {
+ return;
+ }
+
+ } else if (this.paramTypes != null && this.paramTypes.length != 0) {
+ // Having paramCount == 0 and paramTypes.length == 1 indicates
+ // that we have the special case where the target method has one
+ // parameter being the body text of the current element.
+
+ // There is no body text included in the source XML file,
+ // so skip the method call
+ if (this.bodyText == null) {
+ return;
+ }
+
+ parameters = new Object[]{ this.bodyText };
+ } else {
+ // When paramCount is zero and paramTypes.length is zero it
+ // means that we truly are calling a method with no parameters.
+ // Nothing special needs to be done here.
+ }
+
+ // Construct the parameter values array we will need
+ // We only do the conversion if the param value is a String and
+ // the specified paramType is not String.
+ Object paramValues[] = new Object[this.paramTypes.length];
+ for (int i = 0; i < this.paramTypes.length; i++) {
+ // convert nulls and convert stringy parameters
+ // for non-stringy param types
+ if (parameters[i] == null
+ || (parameters[i] instanceof String && !String.class.isAssignableFrom(this.paramTypes[i]))) {
+
+ paramValues[i] = ConvertUtils.convert((String) parameters[i], paramTypes[i]);
+ } else {
+ paramValues[i] = parameters[i];
+ }
+ }
+
+ // Determine the target object for the method call
+ Object target;
+ if (this.targetOffset >= 0) {
+ target = this.getDigester().peek(this.targetOffset);
+ } else {
+ target = this.getDigester().peek(this.getDigester().getCount() + this.targetOffset);
+ }
+
+ if (target == null) {
+ throw this.getDigester().createSAXException(
+ String.format("[CallMethodRule]{%s} Call target is null (targetOffset=%s, stackdepth=%s)",
+ this.getDigester().getMatch(),
+ this.targetOffset,
+ this.getDigester().getCount()));
+ }
+
+ // Invoke the required method on the top object
+ if (this.getDigester().getLog().isDebugEnabled()) {
+ Formatter formatter = new Formatter()
+ .format("[CallMethodRule]{%s} Call %s.%s(",
+ this.getDigester().getMatch(),
+ target.getClass().getName(),
+ this.methodName);
+
+ for (int i = 0; i < paramValues.length; i++) {
+ if (i > 0) {
+ formatter.format(", ");
+ }
+
+ formatter.format("%s/%s",
+ (paramValues[i] == null ? "null" : paramValues[i].toString()),
+ (this.paramTypes[i] == null ? "null" : this.paramTypes[i].getName()));
+ }
+
+ formatter.format(")");
+ this.getDigester().getLog().debug(formatter.toString());
+ }
+
+ Object result = null;
+ if (this.useExactMatch) {
+ // invoke using exact match
+ result = MethodUtils.invokeExactMethod(target, this.methodName, paramValues, this.paramTypes);
+ } else {
+ // invoke using fuzzier match
+ result = MethodUtils.invokeMethod(target, this.methodName, paramValues, this.paramTypes);
+ }
+
+ processMethodCallResult(result);
+ }
+
+ /**
+ * Clean up after parsing is complete.
+ */
+ @Override
+ public void finish() throws Exception {
+ this.bodyText = null;
+ }
+
+ /**
+ * Subclasses may override this method to perform additional processing of the
+ * invoked method's result.
+ *
+ * @param result the Object returned by the method invoked, possibly null
+ */
+ protected void processMethodCallResult(Object result) {
+ // do nothing
+ }
+
+ /**
+ * Render a printable version of this Rule.
+ */
+ @Override
+ public String toString() {
+ Formatter formatter = new Formatter().format("CallMethodRule[methodName=%s, paramCount=%s, paramTypes={",
+ this.methodName,
+ this.paramTypes.length);
+
+ if (this.paramTypes != null) {
+ for (int i = 0; i < this.paramTypes.length; i++) {
+ if (i > 0) {
+ formatter.format(", ");
+ }
+ formatter.format(this.paramTypes[i].getName());
+ }
+ }
+
+ return formatter.format("}]").toString();
+ }
+
+}
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/CallMethodRule.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/CallMethodRule.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/CallMethodRule.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/CallParamRule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/CallParamRule.java?rev=1069805&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/CallParamRule.java (added)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/CallParamRule.java Fri Feb 11 14:19:30 2011
@@ -0,0 +1,156 @@
+/* $Id$
+ *
+ * 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.
+ */
+package org.apache.commons.digester3.rule;
+
+import java.util.Stack;
+
+import org.apache.commons.digester3.Rule;
+import org.xml.sax.Attributes;
+
+/**
+ * <p>Rule implementation that saves a parameter for use by a surrounding
+ * <code>CallMethodRule<code>.</p>
+ *
+ * <p>This parameter may be:
+ * <ul>
+ * <li>from an attribute of the current element
+ * See {@link #CallParamRule(int paramIndex, String attributeName)}
+ * <li>from current the element body
+ * See {@link #CallParamRule(int paramIndex)}
+ * <li>from the top object on the stack.
+ * See {@link #CallParamRule(int paramIndex, boolean fromStack)}
+ * <li>the current path being processed (separate <code>Rule</code>).
+ * See {@link PathCallParamRule}
+ * </ul>
+ * </p>
+ */
+public class CallParamRule extends Rule {
+
+ /**
+ * The zero-relative index of the parameter we are saving.
+ */
+ private final int paramIndex;
+
+ /**
+ * The attribute from which to save the parameter value
+ */
+ private final String attributeName; // @Nullable
+
+ /**
+ * Is the parameter to be set from the stack?
+ */
+ private final boolean fromStack;
+
+ /**
+ * The position of the object from the top of the stack
+ */
+ private final int stackIndex;
+
+ /**
+ * Stack is used to allow nested body text to be processed.
+ * Lazy creation.
+ */
+ private final Stack<String> bodyTextStack = new Stack<String>();
+
+ /**
+ * Constructs a "call parameter" rule which sets a parameter from the stack.
+ * If the stack contains too few objects, then the parameter will be set to null.
+ *
+ * @param paramIndex The zero-relative parameter number
+ * @param fromStack Should this parameter be taken from the top of the stack?
+ * @param stackIndex the index of the object which will be passed as a parameter
+ * The zeroth object is the top of the stack, 1 is the next object down and so on
+ * @param attributeName The name of the attribute to save
+ */
+ public CallParamRule(int paramIndex, boolean fromStack, int stackIndex, /* @Nullable */ String attributeName) {
+ this.paramIndex = paramIndex;
+ this.fromStack = fromStack;
+ this.stackIndex = stackIndex;
+ this.attributeName = attributeName;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void begin(String namespace, String name, Attributes attributes) throws Exception {
+ Object param = null;
+
+ if (this.attributeName != null) {
+ param = attributes.getValue(this.attributeName);
+ } else if (this.fromStack) {
+ param = this.getDigester().peek(stackIndex);
+
+ if (this.getDigester().getLog().isDebugEnabled()) {
+ this.getDigester().getLog().debug(
+ String.format("[CallParamRule]{%s} Save from stack; from stack?%s; object=%s",
+ this.getDigester().getMatch(),
+ this.fromStack,
+ param));
+ }
+ }
+
+ // Have to save the param object to the param stack frame here.
+ // Can't wait until end(). Otherwise, the object will be lost.
+ // We can't save the object as instance variables, as
+ // the instance variables will be overwritten
+ // if this CallParamRule is reused in subsequent nesting.
+
+ if (param != null) {
+ Object parameters[] = (Object[]) this.getDigester().peekParams();
+ parameters[this.paramIndex] = param;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void body(String namespace, String name, String text) throws Exception {
+ if (this.attributeName == null && !this.fromStack) {
+ // We must wait to set the parameter until end
+ // so that we can make sure that the right set of parameters
+ // is at the top of the stack
+ this.bodyTextStack.push(text.trim());
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void end(String namespace, String name) {
+ if (this.bodyTextStack != null && !this.bodyTextStack.empty()) {
+ // what we do now is push one parameter onto the top set of parameters
+ Object parameters[] = (Object[]) this.getDigester().peekParams();
+ parameters[this.paramIndex] = this.bodyTextStack.pop();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return String.format("CallParamRule[paramIndex=%s, attributeName=%s, from stack=%s]",
+ this.paramIndex,
+ this.attributeName,
+ this.fromStack);
+ }
+
+}
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/CallParamRule.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/CallParamRule.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/CallParamRule.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/FactoryCreateRule.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/FactoryCreateRule.java?rev=1069805&view=auto
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/FactoryCreateRule.java (added)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/FactoryCreateRule.java Fri Feb 11 14:19:30 2011
@@ -0,0 +1,207 @@
+/* $Id$
+ *
+ * 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.
+ */
+package org.apache.commons.digester3.rule;
+
+import java.util.Stack;
+
+import org.apache.commons.digester3.Rule;
+import org.apache.commons.digester3.spi.ObjectCreationFactory;
+import org.xml.sax.Attributes;
+
+/**
+ * <p>Rule implementation that uses an {@link ObjectCreationFactory} to create
+ * a new object which it pushes onto the object stack. When the element is
+ * complete, the object will be popped.</p>
+ *
+ * <p>This rule is intended in situations where the element's attributes are
+ * needed before the object can be created. A common senario is for the
+ * ObjectCreationFactory implementation to use the attributes as parameters
+ * in a call to either a factory method or to a non-empty constructor.
+ */
+public class FactoryCreateRule extends Rule {
+
+ /** Should exceptions thrown by the factory be ignored? */
+ private boolean ignoreCreateExceptions;
+
+ /** Stock to manage */
+ private Stack<Boolean> exceptionIgnoredStack;
+
+ /**
+ * The attribute containing an override class name if it is present.
+ */
+ private String attributeName = null;
+
+ /**
+ * The Java class name of the ObjectCreationFactory to be created.
+ * This class must have a no-arguments constructor.
+ */
+ private String className = null;
+
+ /**
+ * The object creation factory we will use to instantiate objects
+ * as required based on the attributes specified in the matched XML
+ * element.
+ */
+ private ObjectCreationFactory<?> creationFactory = null;
+
+ /**
+ * Construct a factory create rule that will use the specified
+ * class name (possibly overridden by the specified attribute if present)
+ * to create an {@link ObjectCreationFactory}, which will then be used
+ * to instantiate an object instance and push it onto the stack.
+ *
+ * @param className Default Java class name of the factory class
+ * @param attributeName Attribute name which, if present, contains an
+ * override of the class name of the object creation factory to create.
+ *
+ * @param ignoreCreateExceptions if true, exceptions thrown by the object
+ * creation factory will be ignored.
+ */
+ public <T> FactoryCreateRule(String className, String attributeName, ObjectCreationFactory<T> creationFactory, boolean ignoreCreateExceptions) {
+ this.className = className;
+ this.attributeName = attributeName;
+ this.creationFactory = creationFactory;
+ this.ignoreCreateExceptions = ignoreCreateExceptions;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void begin(String namespace, String name, Attributes attributes) throws Exception {
+ if (this.ignoreCreateExceptions) {
+ if (this.exceptionIgnoredStack == null) {
+ this.exceptionIgnoredStack = new Stack<Boolean>();
+ }
+
+ try {
+ Object instance = getFactory(attributes).createObject(attributes);
+
+ if (this.getDigester().getLog().isDebugEnabled()) {
+ this.getDigester().getLog().debug(String.format("[FactoryCreateRule]{%s} New %s",
+ this.getDigester().getMatch(),
+ (instance == null ? "null object" : instance.getClass().getName())));
+ }
+
+ this.getDigester().push(instance);
+ this.exceptionIgnoredStack.push(Boolean.FALSE);
+ } catch (Exception e) {
+ // log message and error
+ if (this.getDigester().getLog().isInfoEnabled()) {
+ this.getDigester().getLog().info("[FactoryCreateRule] Create exception ignored: "
+ + ((e.getMessage() == null) ? e.getClass().getName() : e.getMessage()));
+
+ if (this.getDigester().getLog().isDebugEnabled()) {
+ this.getDigester().getLog().debug("[FactoryCreateRule] Ignored exception:", e);
+ }
+ }
+ this.exceptionIgnoredStack.push(Boolean.TRUE);
+ }
+ } else {
+ Object instance = getFactory(attributes).createObject(attributes);
+
+ if (this.getDigester().getLog().isDebugEnabled()) {
+ this.getDigester().getLog().debug(String.format("[FactoryCreateRule]{%s} New %s",
+ this.getDigester().getMatch(),
+ (instance == null ? "null object" : instance.getClass().getName())));
+ }
+
+ this.getDigester().push(instance);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void end(String namespace, String name) throws Exception {
+ // check if object was created
+ // this only happens if an exception was thrown and we're ignoring them
+ if (this.ignoreCreateExceptions
+ && this.exceptionIgnoredStack != null
+ && !this.exceptionIgnoredStack.empty()) {
+
+ if (this.exceptionIgnoredStack.pop().booleanValue()) {
+ // creation exception was ignored
+ // nothing was put onto the stack
+ if (this.getDigester().getLog().isTraceEnabled()) {
+ this.getDigester().getLog().trace("[FactoryCreateRule] No creation so no push so no pop");
+ }
+ return;
+ }
+ }
+
+ Object top = this.getDigester().pop();
+ if (this.getDigester().getLog().isDebugEnabled()) {
+ this.getDigester().getLog().debug(String.format("[FactoryCreateRule]{%s} Pop %s",
+ this.getDigester().getMatch(),
+ top.getClass().getName()));
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void finish() throws Exception {
+ if (this.attributeName != null) {
+ this.creationFactory = null;
+ }
+ }
+
+ /**
+ * Render a printable version of this Rule.
+ */
+ @Override
+ public String toString() {
+ return String.format("FactoryCreateRule[className=%s, attributeName=%s, creationFactory=%s]",
+ this.className,
+ this.attributeName,
+ this.creationFactory);
+ }
+
+ /**
+ * Return an instance of our associated object creation factory,
+ * creating one if necessary.
+ *
+ * @param attributes Attributes passed to our factory creation element
+ *
+ * @exception Exception if any error occurs
+ */
+ protected ObjectCreationFactory<?> getFactory(Attributes attributes) throws Exception {
+ if (this.creationFactory == null) {
+ String realClassName = this.className;
+ if (this.attributeName != null) {
+ String value = attributes.getValue(this.attributeName);
+ if (value != null) {
+ realClassName = value;
+ }
+ }
+ if (this.getDigester().getLog().isDebugEnabled()) {
+ this.getDigester().getLog().debug(String.format("[FactoryCreateRule]{%s} New factory %s",
+ this.getDigester().getMatch(),
+ realClassName));
+ }
+ Class<?> clazz = this.getDigester().getClassLoader().loadClass(realClassName);
+ this.creationFactory = (ObjectCreationFactory<?>) clazz.newInstance();
+ this.creationFactory.setDigester(this.getDigester());
+ }
+ return this.creationFactory;
+ }
+
+}
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/FactoryCreateRule.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/FactoryCreateRule.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/rule/FactoryCreateRule.java
------------------------------------------------------------------------------
svn:mime-type = text/plain