Package org.apache.commons.digester3
Class BeanPropertySetterRule
java.lang.Object
org.apache.commons.digester3.Rule
org.apache.commons.digester3.BeanPropertySetterRule
Rule implements sets a bean property on the top object to the body text.
The property set:
- can be specified when the rule is created
- or can match the current element when the rule is called.
Using the second method and the ExtendedBaseRules
child match pattern, all the child elements can be
automatically mapped to properties on the parent object.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstruct rule that automatically sets a property from the body text.BeanPropertySetterRule
(String propertyName) Construct rule that sets the given property from the body text. -
Method Summary
Modifier and TypeMethodDescriptionvoid
begin
(String namespace, String name, Attributes attributes) This method is called when the beginning of a matching XML element is encountered.void
This method is called when the body of a matching XML element is encountered.void
This method is called when the end of a matching XML element is encountered.void
finish()
This method is called after all parsing methods have been called, to allow Rules to remove temporary data.protected String
Returns the body text used to set the property.Returns the property name associated to this setter rule.void
setPropertyNameFromAttribute
(String propertyNameFromAttribute) Sets the attribute name from which the property name has to be extracted.toString()
Methods inherited from class org.apache.commons.digester3.Rule
getDigester, getNamespaceURI, setDigester, setNamespaceURI
-
Field Details
-
propertyName
Set this property on the top object. -
propertyNameFromAttribute
Extract the property name from attribute -
bodyText
The body text used to set the property.
-
-
Constructor Details
-
BeanPropertySetterRule
Construct rule that sets the given property from the body text.
- Parameters:
propertyName
- name of property to set
-
BeanPropertySetterRule
public BeanPropertySetterRule()Construct rule that automatically sets a property from the body text.
This construct creates a rule that sets the property on the top object named the same as the current element.
-
-
Method Details
-
getPropertyName
Returns the property name associated to this setter rule.- Returns:
- The property name associated to this setter rule
-
setPropertyNameFromAttribute
Sets the attribute name from which the property name has to be extracted.- Parameters:
propertyNameFromAttribute
- the attribute name from which the property name has to be extracted.- Since:
- 3.0
-
getBodyText
Returns the body text used to set the property.- Returns:
- The body text used to set the property
-
begin
This method is called when the beginning of a matching XML element is encountered.- Overrides:
begin
in classRule
- 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
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 classRule
- 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
This method is called when the end of a matching XML element is encountered.- Overrides:
end
in classRule
- 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:
Exception
- if any error occurs
-
finish
This method is called after all parsing methods have been called, to allow Rules to remove temporary data. -
toString
-