Class CallMethodRule
Rule implementation that calls a method on an object on the stack
 (normally the top/parent object), passing arguments collected from
 subsequent CallParamRule rules or from the body of this
 element. 
By using CallMethodRule(String methodName)
 a method call can be made to a method which accepts no
 arguments.
Incompatible method parameter types are converted
 using org.apache.commons.beanutils.ConvertUtils.
 
This rule now uses
 
 org.apache.commons.beanutils.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 org.apache.commons.beanutils.MethodUtils#invokeExactMethod
 (the old default) is required.
 This method is much stricter in its reflection.
 Setting the UseExactMatch to true reverts to the use of this
 method.
Note that the target method is invoked when the end of the tag the CallMethodRule fired on is encountered, not 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.
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 passed as null values).
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected StringThe body text collected from this element.protected final StringThe method name to call on the parent object.protected final intThe number of parameters to collect fromMethodParamrules.protected Class<?>[]The parameter types of the parameters to be collected.protected final intlocation of the target object for the call, relative to the top of the digester object stack.protected booleanShouldMethodUtils.invokeExactMethodbe used for reflection.Fields inherited from class org.apache.tomcat.util.digester.Ruledigester, namespaceURI, sm
- 
Constructor SummaryConstructorsConstructorDescriptionCallMethodRule(int targetOffset, String methodName, int paramCount) Construct a "call method" rule with the specified method name.CallMethodRule(int targetOffset, String methodName, int paramCount, Class<?>[] paramTypes) Construct a "call method" rule with the specified method name and parameter types.CallMethodRule(String methodName) Construct a "call method" rule with the specified method name.CallMethodRule(String methodName, int paramCount) Construct a "call method" rule with the specified method name.
- 
Method SummaryModifier and TypeMethodDescriptionvoidbegin(String namespace, String name, Attributes attributes) Process the start of this element.voidProcess the body text of this element.voidProcess the end of this element.voidfinish()Clean up after parsing is complete.booleanShouldMethodUtils.invokeExactMethodbe used for the reflection.protected voidprocessMethodCallResult(Object result) Subclasses may override this method to perform additional processing of the invoked method's result.voidsetUseExactMatch(boolean useExactMatch) Set whetherMethodUtils.invokeExactMethodshould be used for the reflection.toString()Render a printable version of this Rule.Methods inherited from class org.apache.tomcat.util.digester.RulegetDigester, getNamespaceURI, setDigester, setNamespaceURI
- 
Field Details- 
bodyTextThe body text collected from this element.
- 
targetOffsetprotected final int targetOffsetlocation 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.
- 
methodNameThe method name to call on the parent object.
- 
paramCountprotected final int paramCountThe number of parameters to collect fromMethodParamrules. If this value is zero, a single parameter will be collected from the body of this element.
- 
paramTypesThe parameter types of the parameters to be collected.
- 
useExactMatchprotected boolean useExactMatchShouldMethodUtils.invokeExactMethodbe used for reflection.
 
- 
- 
Constructor Details- 
CallMethodRuleConstruct a "call method" rule with the specified method name. The parameter types (if any) default to java.lang.String.- Parameters:
- methodName- Method name of the parent method to call
- paramCount- The number of parameters to collect, or zero for a single argument from the body of this element.
 
- 
CallMethodRuleConstruct a "call method" rule with the specified method name. The parameter types (if any) default to java.lang.String.- Parameters:
- 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.
- methodName- Method name of the parent method to call
- paramCount- The number of parameters to collect, or zero for a single argument from the body of this element.
 
- 
CallMethodRuleConstruct a "call method" rule with the specified method name. The method should accept no parameters.- Parameters:
- methodName- Method name of the parent method to call
 
- 
CallMethodRuleConstruct a "call method" rule with the specified method name and parameter types. IfparamCountis set to zero the rule will use the body of this element as the single argument of the method, unlessparamTypesis null or empty, in this case the rule will call the specified method with no arguments.- Parameters:
- 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.
- methodName- Method name of the parent method to call
- paramCount- The number of parameters to collect, or zero for a single argument from the body of this element
- paramTypes- The Java classes that represent the parameter types of the method arguments (if you wish to use a primitive type, specify the corresponding Java wrapper class instead, such as- java.lang.Boolean.TYPEfor a- booleanparameter)
 
 
- 
- 
Method Details- 
getUseExactMatchpublic boolean getUseExactMatch()ShouldMethodUtils.invokeExactMethodbe used for the reflection.- Returns:
- trueif invokeExactMethod is used
 
- 
setUseExactMatchpublic void setUseExactMatch(boolean useExactMatch) Set whetherMethodUtils.invokeExactMethodshould be used for the reflection.- Parameters:
- useExactMatch- The flag value
 
- 
beginProcess the start of this element.- Overrides:
- beginin class- Rule
- Parameters:
- 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
- name- the local name if the parser is namespace aware, or just the element name otherwise
- attributes- The attribute list for this element
- Throws:
- Exception- if an error occurs while processing the event
 
- 
bodyProcess the body text of this element.- Overrides:
- bodyin class- Rule
- Parameters:
- 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
- name- the local name if the parser is namespace aware, or just the element name otherwise
- bodyText- The body text of this element
- Throws:
- Exception- if an error occurs while processing the event
 
- 
endProcess the end of this element.- Overrides:
- endin class- Rule
- Parameters:
- 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
- name- the local name if the parser is namespace aware, or just the element name otherwise
- Throws:
- Exception- if an error occurs while processing the event
 
- 
finishClean up after parsing is complete.
- 
processMethodCallResultSubclasses may override this method to perform additional processing of the invoked method's result.- Parameters:
- result- the Object returned by the method invoked, possibly null
 
- 
toStringRender a printable version of this Rule.
 
-