|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.digester3.Rule
org.apache.commons.digester3.CallParamRule
public class CallParamRule
Rule implementation that saves a parameter for use by a surrounding CallMethodRule
.
This parameter may be:
- from an attribute of the current element See
CallParamRule(int paramIndex, String attributeName)
- from current the element body See
CallParamRule(int paramIndex)
- from the top object on the stack. See
CallParamRule(int paramIndex, boolean fromStack)
- the current path being processed (separate
Rule
). See PathCallParamRule
Field Summary
protected String
attributeName
The attribute from which to save the parameter value
protected Stack<String>
bodyTextStack
Stack is used to allow nested body text to be processed.
protected boolean
fromStack
Is the parameter to be set from the stack?
protected int
paramIndex
The zero-relative index of the parameter we are saving.
protected int
stackIndex
The position of the object from the top of the stack
Constructor Summary
CallParamRule(int paramIndex)
Construct a "call parameter" rule that will save the body text of this element as the parameter value.
CallParamRule(int paramIndex,
boolean fromStack)
Construct a "call parameter" rule.
CallParamRule(int paramIndex,
int stackIndex)
Constructs a "call parameter" rule which sets a parameter from the stack.
CallParamRule(int paramIndex,
String attributeName)
Construct a "call parameter" rule that will save the value of the specified attribute as the parameter value.
Method Summary
void
begin(String namespace,
String name,
Attributes attributes)
This method is called when the beginning of a matching XML element is encountered.
void
body(String namespace,
String name,
String text)
This method is called when the body of a matching XML element is encountered.
void
end(String namespace,
String name)
This method is called when the end of a matching XML element is encountered.
void
setAttributeName(String attributeName)
Set the attribute from which to save the parameter value.
String
toString()
Methods inherited from class org.apache.commons.digester3.Rule
finish, getDigester, getNamespaceURI, setDigester, setNamespaceURI
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Field Detail
attributeName
protected String attributeName
- The attribute from which to save the parameter value
paramIndex
protected int paramIndex
- The zero-relative index of the parameter we are saving.
fromStack
protected boolean fromStack
- Is the parameter to be set from the stack?
stackIndex
protected int stackIndex
- The position of the object from the top of the stack
bodyTextStack
protected Stack<String> bodyTextStack
- Stack is used to allow nested body text to be processed. Lazy creation.
Constructor Detail
CallParamRule
public CallParamRule(int paramIndex)
- Construct a "call parameter" rule that will save the body text of this element as the parameter value.
Note that if the element is empty the an empty string is passed to the target method, not null. And if
automatic type conversion is being applied (ie if the target function takes something other than a string as a
parameter) then the conversion will fail if the converter class does not accept an empty string as valid input.
- Parameters:
paramIndex
- The zero-relative parameter number
CallParamRule
public CallParamRule(int paramIndex,
String attributeName)
- Construct a "call parameter" rule that will save the value of the specified attribute as the parameter value.
- Parameters:
paramIndex
- The zero-relative parameter numberattributeName
- The name of the attribute to save
CallParamRule
public CallParamRule(int paramIndex,
boolean fromStack)
- Construct a "call parameter" rule.
- Parameters:
paramIndex
- The zero-relative parameter numberfromStack
- should this parameter be taken from the top of the stack?
CallParamRule
public CallParamRule(int paramIndex,
int stackIndex)
- Constructs a "call parameter" rule which sets a parameter from the stack. If the stack contains too few objects,
then the parameter will be set to null.
- Parameters:
paramIndex
- The zero-relative parameter numberstackIndex
- the index of the object which will be passed as a parameter. The zeroth object is the top of
the stack, 1 is the next object down and so on.
Method Detail
setAttributeName
public void setAttributeName(String attributeName)
- Set the attribute from which to save the parameter value.
- Parameters:
attributeName
- The attribute from which to save the parameter value- Since:
- 3.0
begin
public void begin(String namespace,
String name,
Attributes attributes)
throws Exception
- This method is called when the beginning of a matching XML element is encountered.
- Overrides:
begin
in 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 namespacename
- the local name if the parser is namespace aware, or just the element name otherwiseattributes
- The attribute list of this element
- Throws:
Exception
- if any error occurs
body
public void body(String namespace,
String name,
String text)
throws Exception
- This method is called when the body of a matching XML element is encountered. If the element has no body, this
method is called with an empty string as the body text.
- Overrides:
body
in 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 namespacename
- the local name if the parser is namespace aware, or just the element name otherwisetext
- The text of the body of this element
- Throws:
Exception
- if any error occurs
end
public void end(String namespace,
String name)
- This method is called when the end of a matching XML element is encountered.
- Overrides:
end
in 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 namespacename
- the local name if the parser is namespace aware, or just the element name otherwise
toString
public String toString()
-
- Overrides:
toString
in class Object
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Copyright © 2001-2011 The Apache Software Foundation. All Rights Reserved.