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/01/31 22:43:20 UTC

svn commit: r1065810 - /commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/RulesBinderImpl.java

Author: simonetripodi
Date: Mon Jan 31 21:43:19 2011
New Revision: 1065810

URL: http://svn.apache.org/viewvc?rev=1065810&view=rev
Log:
added setProperty() method implementation

Modified:
    commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/RulesBinderImpl.java

Modified: commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/RulesBinderImpl.java
URL: http://svn.apache.org/viewvc/commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/RulesBinderImpl.java?rev=1065810&r1=1065809&r2=1065810&view=diff
==============================================================================
--- commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/RulesBinderImpl.java (original)
+++ commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/RulesBinderImpl.java Mon Jan 31 21:43:19 2011
@@ -195,8 +195,39 @@ final class RulesBinderImpl implements R
                 });
             }
 
-            public SetPropertyBuilder setProperty(String attributePropertyName) {
-                return null;
+            /**
+             * 
+             */
+            public SetPropertyBuilder setProperty(final String attributePropertyName) {
+                if (attributePropertyName == null || attributePropertyName.length() == 0) {
+                    addError("{forPattern(\"%s\").setProperty(String)} empty 'attributePropertyName' not allowed",
+                            keyPattern);
+                }
+
+                return this.addProvider(new SetPropertyBuilder() {
+
+                    private String valueAttributeName;
+
+                    public SetPropertyRule get() {
+                        return setNamespaceAndReturn(new SetPropertyRule(attributePropertyName, valueAttributeName));
+                    }
+
+                    public LinkedRuleBuilder then() {
+                        return mainBuilder;
+                    }
+
+                    public SetPropertyBuilder extractingValueFromAttribute(String valueAttributeName) {
+                        if (attributePropertyName == null || attributePropertyName.length() == 0) {
+                            addError("{forPattern(\"%s\").setProperty(\"%s\")} empty 'valueAttributeName' not allowed",
+                                    keyPattern,
+                                    attributePropertyName);
+                        }
+
+                        this.valueAttributeName = valueAttributeName;
+                        return this;
+                    }
+
+                });
             }
 
             /**