commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1066193 - /commons/sandbox/digester3/trunk/src/main/java/org/apache/commons/digester3/RulesBinderImpl.java
Date Tue, 01 Feb 2011 20:38:54 GMT
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;
+                    }
+
+                });
             }
 
             /**



Mime
View raw message