|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.digester.Rule | +--org.apache.commons.digester.CallMethodRule
Rule implementation that calls a method on 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 MethodUtils.invokeMethod(java.lang.Object, java.lang.String, java.lang.Object)
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 MethodUtils.invokeExactMethod(java.lang.Object, java.lang.String, java.lang.Object)
(the old defualt) is required.
This method is much stricter in it's reflection.
Setting the UseExactMatch
to true reverts to the use of this
method.
Field Summary | |
protected java.lang.String |
bodyText
The body text collected from this element. |
protected java.lang.String |
methodName
The method name to call on the parent object. |
private java.lang.String[] |
paramClassNames
The names of the classes of the parameters to be collected. |
protected int |
paramCount
The number of parameters to collect from MethodParam rules. |
protected java.lang.Class[] |
paramTypes
The parameter types of the parameters to be collected. |
protected boolean |
useExactMatch
Should MethodUtils.invokeExactMethod be used for reflection. |
Fields inherited from class org.apache.commons.digester.Rule |
digester, namespaceURI |
Constructor Summary | |
CallMethodRule(Digester digester,
java.lang.String methodName,
int paramCount)
Deprecated. The digester instance is now set in the Digester.addRule(java.lang.String, org.apache.commons.digester.Rule) method.
Use CallMethodRule(String methodName,int paramCount) instead. |
|
CallMethodRule(Digester digester,
java.lang.String methodName,
int paramCount,
java.lang.Class[] paramTypes)
Deprecated. The digester instance is now set in the Digester.addRule(java.lang.String, org.apache.commons.digester.Rule) method.
Use CallMethodRule(String methodName,int paramCount, Class [] paramTypes) instead. |
|
CallMethodRule(Digester digester,
java.lang.String methodName,
int paramCount,
java.lang.String[] paramTypes)
Deprecated. The digester instance is now set in the Digester.addRule(java.lang.String, org.apache.commons.digester.Rule) method.
Use CallMethodRule(String methodName,int paramCount, String [] paramTypes) instead. |
|
CallMethodRule(java.lang.String methodName)
Construct a "call method" rule with the specified method name. |
|
CallMethodRule(java.lang.String methodName,
int paramCount)
Construct a "call method" rule with the specified method name. |
|
CallMethodRule(java.lang.String methodName,
int paramCount,
java.lang.Class[] paramTypes)
Construct a "call method" rule with the specified method name and parameter types. |
|
CallMethodRule(java.lang.String methodName,
int paramCount,
java.lang.String[] paramTypes)
Construct a "call method" rule with the specified method name and parameter types. |
Method Summary | |
void |
begin(org.xml.sax.Attributes attributes)
Process the start of this element. |
void |
body(java.lang.String bodyText)
Process the body text of this element. |
void |
end()
Process the end of this element. |
void |
finish()
Clean up after parsing is complete. |
boolean |
getUseExactMatch()
Should MethodUtils.invokeExactMethod
be used for the reflection. |
void |
setDigester(Digester digester)
Set the associated digester. |
void |
setUseExactMatch(boolean useExactMatch)
Set whether MethodUtils.invokeExactMethod
should be used for the reflection. |
java.lang.String |
toString()
Render a printable version of this Rule. |
Methods inherited from class org.apache.commons.digester.Rule |
begin, body, end, getDigester, getNamespaceURI, setNamespaceURI |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.lang.String bodyText
protected java.lang.String methodName
protected int paramCount
MethodParam
rules.
If this value is zero, a single parameter will be collected from the
body of this element.
protected java.lang.Class[] paramTypes
private java.lang.String[] paramClassNames
protected boolean useExactMatch
MethodUtils.invokeExactMethod
be used for reflection.
Constructor Detail |
public CallMethodRule(Digester digester, java.lang.String methodName, int paramCount)
Digester.addRule(java.lang.String, org.apache.commons.digester.Rule)
method.
Use CallMethodRule(String methodName,int paramCount)
instead.
digester
- The associated DigestermethodName
- Method name of the parent method to callparamCount
- The number of parameters to collect, or
zero for a single argument from the body of this element.public CallMethodRule(Digester digester, java.lang.String methodName, int paramCount, java.lang.String[] paramTypes)
Digester.addRule(java.lang.String, org.apache.commons.digester.Rule)
method.
Use CallMethodRule(String methodName,int paramCount, String [] paramTypes)
instead.
digester
- The associated DigestermethodName
- Method name of the parent method to callparamCount
- The number of parameters to collect, or
zero for a single argument from the body of ths elementparamTypes
- The Java class names of the arguments
(if you wish to use a primitive type, specify the corresonding
Java wrapper class instead, such as java.lang.Boolean
for a boolean
parameter)public CallMethodRule(Digester digester, java.lang.String methodName, int paramCount, java.lang.Class[] paramTypes)
Digester.addRule(java.lang.String, org.apache.commons.digester.Rule)
method.
Use CallMethodRule(String methodName,int paramCount, Class [] paramTypes)
instead.
digester
- The associated DigestermethodName
- Method name of the parent method to callparamCount
- The number of parameters to collect, or
zero for a single argument from the body of ths elementparamTypes
- 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 java.lang.Boolean.TYPE
for a boolean
parameter)public CallMethodRule(java.lang.String methodName, int paramCount)
methodName
- Method name of the parent method to callparamCount
- The number of parameters to collect, or
zero for a single argument from the body of this element.public CallMethodRule(java.lang.String methodName)
methodName
- Method name of the parent method to callpublic CallMethodRule(java.lang.String methodName, int paramCount, java.lang.String[] paramTypes)
paramCount
is set to zero the rule
will use the body of this element as the single argument of the
method, unless paramTypes
is null or empty, in this
case the rule will call the specified method with no arguments.
methodName
- Method name of the parent method to callparamCount
- The number of parameters to collect, or
zero for a single argument from the body of ths elementparamTypes
- The Java class names of the arguments
(if you wish to use a primitive type, specify the corresonding
Java wrapper class instead, such as java.lang.Boolean
for a boolean
parameter)public CallMethodRule(java.lang.String methodName, int paramCount, java.lang.Class[] paramTypes)
paramCount
is set to zero the rule
will use the body of this element as the single argument of the
method, unless paramTypes
is null or empty, in this
case the rule will call the specified method with no arguments.
methodName
- Method name of the parent method to callparamCount
- The number of parameters to collect, or
zero for a single argument from the body of ths elementparamTypes
- 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 java.lang.Boolean.TYPE
for a boolean
parameter)Method Detail |
public boolean getUseExactMatch()
MethodUtils.invokeExactMethod
be used for the reflection.
public void setUseExactMatch(boolean useExactMatch)
MethodUtils.invokeExactMethod
should be used for the reflection.
public void setDigester(Digester digester)
setDigester
in class Rule
public void begin(org.xml.sax.Attributes attributes) throws java.lang.Exception
begin
in class Rule
attributes
- The attribute list for this element
java.lang.Exception
public void body(java.lang.String bodyText) throws java.lang.Exception
body
in class Rule
bodyText
- The body text of this element
java.lang.Exception
public void end() throws java.lang.Exception
end
in class Rule
java.lang.Exception
public void finish() throws java.lang.Exception
finish
in class Rule
java.lang.Exception
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |