Class CmsSetNextRule
- java.lang.Object
-
- org.apache.commons.digester3.Rule
-
- org.opencms.configuration.CmsSetNextRule
-
public class CmsSetNextRule extends org.apache.commons.digester3.Rule
Rule implementation that invokes a method on the (top-1) (parent) object, passing as implicit first argument of typeand as a further argument the top stack instance.CmsObjectIf no subsequent
CallParamRuleare matched forCmsObjectwhich is the case in the OpenCms usage the first argumentCmsObjectwill be null at method invocation time.This is an alternative for
if a parent to child-property configuration has been done but the setter for that property requires additional arguments that are only available at real runtime of the application.SetNextRuleThe top stack element (child) that has to be set is matched against the constructor given
: It is used as argument on the position where theClass[]Class[]has an instance of the same type as it's ownClass.- Since:
- 6.0.0
- See Also:
CallMethodRule,SetNextRule
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Stringm_bodyTextThe body text collected from this element.protected java.lang.Stringm_methodNameThe method name to call on the parent object.protected intm_paramCountThe number of parameters to collect fromMethodParamrules.protected java.lang.Class<?>[]m_paramTypesThe parameter types of the parameters to be collected.protected booleanm_useExactMatchShouldMethodUtils.invokeExactMethodbe used for reflection.
-
Constructor Summary
Constructors Constructor Description CmsSetNextRule(java.lang.String methodName, java.lang.Class<?> clazz)Construct a "call method" rule with the specified method name.CmsSetNextRule(java.lang.String methodName, java.lang.Class<?>[] clazzes)Construct a "call method" rule with the specified method name and additional parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbegin(java.lang.String namespace, java.lang.String name, org.xml.sax.Attributes attributes)Process the start of this element.voidbody(java.lang.String namespace, java.lang.String name, java.lang.String bodyText)Process the body text of this element.voidend(java.lang.String namespace, java.lang.String name)Process the end of this element.voidfinish(java.lang.String namespace, java.lang.String name)Clean up after parsing is complete.booleangetUseExactMatch()Returns true ifMethodUtils.invokeExactMethodshall be used for the reflection.protected voidprocessMethodCallResult(java.lang.Object result)Subclasses may override this method to perform additional processing of the invoked method's result.voidsetDigester(org.apache.commons.digester3.Digester aDigester)Set the associated digester.voidsetUseExactMatch(boolean useExactMatch)Set the value to use forMethodUtils.invokeExactMethodto use.java.lang.StringtoString()Returns a printable version of this Rule.
-
-
-
Field Detail
-
m_bodyText
protected java.lang.String m_bodyText
The body text collected from this element.
-
m_methodName
protected java.lang.String m_methodName
The method name to call on the parent object.
-
m_paramCount
protected int m_paramCount
The number of parameters to collect fromMethodParamrules. If this value is zero, a single parameter will be collected from the body of this element.
-
m_paramTypes
protected java.lang.Class<?>[] m_paramTypes
The parameter types of the parameters to be collected.
-
m_useExactMatch
protected boolean m_useExactMatch
ShouldMethodUtils.invokeExactMethodbe used for reflection.
-
-
Constructor Detail
-
CmsSetNextRule
public CmsSetNextRule(java.lang.String methodName, java.lang.Class<?> clazz)
Construct a "call method" rule with the specified method name.The 1st argument of the method will be of type
. It's value will remain null (except subsequentCmsObjectwould put a value which currently is impossible at initialization time within OpenCms).CallParamRuleThe 2nd argument will be the top-stack element at digestion time. That instance has to be of the same type as the
clazzargument to succeed.- Parameters:
methodName- Method name of the parent method to callclazz- The class of the top-stack element (child) that will be present at digestion-time
-
CmsSetNextRule
public CmsSetNextRule(java.lang.String methodName, java.lang.Class<?>[] clazzes)
Construct a "call method" rule with the specified method name and additional parameters.The 1st argument of the method will be of type
. It's value will remain null (except subsequentCmsObjectwould put a value which currently is impossible at initialization time within OpenCms).CallParamRuleThe further arguments will be filled by the subsequent
matches. If the firstCallParamRuleClassin the given array matches the top stack element (child) that value will be used. If at digestion time no parameters are found for the given types their values for invocation of the method remain null.- Parameters:
methodName- Method name of the parent method to callclazzes- an array with all parameter types for the method to invoke at digestion time
-
-
Method Detail
-
begin
public void begin(java.lang.String namespace, java.lang.String name, org.xml.sax.Attributes attributes) throws java.lang.Exception
Process the start of this element.- Overrides:
beginin classorg.apache.commons.digester3.Rule- Parameters:
attributes- The attribute list for this elementnamespace- the namespace URI of the matching element, or an empty string if the parser is not namespace aware or the element has no namespacename- the local name if the parser is namespace aware, or just the element name otherwise- Throws:
java.lang.Exception- if something goes wrong
-
body
public void body(java.lang.String namespace, java.lang.String name, java.lang.String bodyText) throws java.lang.Exception
Process the body text of this element.- Overrides:
bodyin classorg.apache.commons.digester3.Rule- Parameters:
bodyText- The body text of this elementnamespace- the namespace URI of the matching element, or an empty string if the parser is not namespace aware or the element has no namespacename- the local name if the parser is namespace aware, or just the element name otherwise- Throws:
java.lang.Exception- if something goes wrong
-
end
public void end(java.lang.String namespace, java.lang.String name) throws java.lang.Exception
Process the end of this element.- Overrides:
endin classorg.apache.commons.digester3.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 namespacename- the local name if the parser is namespace aware, or just the element name otherwise- Throws:
java.lang.Exception- if something goes wrong
-
finish
public void finish(java.lang.String namespace, java.lang.String name) throws java.lang.Exception
Clean up after parsing is complete.- 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 namespacename- the local name if the parser is namespace aware, or just the element name otherwise- Throws:
java.lang.Exception- if something goes wrong
-
getUseExactMatch
public boolean getUseExactMatch()
Returns true ifMethodUtils.invokeExactMethodshall be used for the reflection.- Returns:
- true if
MethodUtils.invokeExactMethodshall be used for the reflection.
-
setDigester
public void setDigester(org.apache.commons.digester3.Digester aDigester)
Set the associated digester.The digester gets assigned to use the OpenCms conform logging If needed, this class loads the parameter classes from their names.
- Overrides:
setDigesterin classorg.apache.commons.digester3.Rule- Parameters:
aDigester- the associated digester to set
-
setUseExactMatch
public void setUseExactMatch(boolean useExactMatch)
Set the value to use forMethodUtils.invokeExactMethodto use.- Parameters:
useExactMatch- the value to use forMethodUtils.invokeExactMethodto use
-
toString
public java.lang.String toString()
Returns a printable version of this Rule.- Overrides:
toStringin classjava.lang.Object- Returns:
- a printable version of this Rule
-
processMethodCallResult
protected void processMethodCallResult(java.lang.Object result)
Subclasses 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
-
-