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/01 21:38:54 UTC

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

Author: simonetripodi
Date: Tue Feb  1 20:38:53 2011
New Revision: 1066193

URL: http://svn.apache.org/viewvc?rev=1066193&view=rev
Log:
added callMethod() 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=1066193&r1=1066192&r2=1066193&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 Tue Feb  1 20:38:53 2011
@@ -582,8 +582,58 @@ final class RulesBinderImpl implements R
                 });
             }
 
-            public CallMethodBuilder callMethod(String methodName) {
-                return null;
+            /**
+             * 
+             */
+            public CallMethodBuilder callMethod(final String methodName) {
+                if (methodName == null || methodName.length() == 0) {
+                    addError("{forPattern(\"%s\").callMethod(String)} empty 'methodName' not allowed", keyPattern);
+                }
+
+                return this.addProvider(new CallMethodBuilder() {
+
+                    private int targetOffset;
+
+                    private int paramCount;
+
+                    private Class<?>[] paramTypes;
+
+                    private boolean useExactMatch;
+
+                    public CallMethodRule get() {
+                        return setNamespaceAndReturn(new CallMethodRule(targetOffset, methodName, paramCount, paramTypes, useExactMatch));
+                    }
+
+                    public LinkedRuleBuilder then() {
+                        return mainBuilder;
+                    }
+
+                    public CallMethodBuilder useExactMatch(boolean useExactMatch) {
+                        this.useExactMatch = useExactMatch;
+                        return this;
+                    }
+
+                    public CallMethodBuilder withTargetOffset(int targetOffset) {
+                        this.targetOffset = targetOffset;
+                        return this;
+                    }
+
+                    public CallMethodBuilder withParamCount(int paramCount) {
+                        if (paramCount < 0) {
+                            addError("{forPattern(\"%s\").callMethod().withParamCount(int)} negative parameters counter not allowed",
+                                    keyPattern);
+                        }
+
+                        this.paramCount = paramCount;
+                        return null;
+                    }
+
+                    public CallMethodBuilder withParamTypes(/* @Nullable */Class<?>... paramTypes) {
+                        this.paramTypes = paramTypes;
+                        return this;
+                    }
+
+                });
             }
 
             /**