Class LinkedRuleBuilder
- java.lang.Object
-
- org.apache.commons.digester3.binder.LinkedRuleBuilder
-
public final class LinkedRuleBuilder extends java.lang.Object
Builder invoked to bind one or more rules to a pattern.- Since:
- 3.0
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.ClassLoader
classLoader
private FromBinderRuleSet
fromBinderRuleSet
private java.lang.String
keyPattern
private RulesBinder
mainBinder
private java.lang.String
namespaceURI
-
Constructor Summary
Constructors Constructor Description LinkedRuleBuilder(RulesBinder mainBinder, FromBinderRuleSet fromBinderRuleSet, java.lang.ClassLoader classLoader, java.lang.String keyPattern)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private <R extends Rule,RB extends AbstractBackToLinkedRuleBuilder<R>>
RBaddProvider(RB provider)
Add a provider in the data structure where storing the providers binding.<R extends Rule>
ByRuleBuilder<R>addRule(R rule)
Add a custom user rule in the specified pattern.<R extends Rule>
ByRuleProviderBuilder<R>addRuleCreatedBy(RuleProvider<R> provider)
Add a custom user rule in the specified pattern built by the given provider.CallMethodBuilder
callMethod(java.lang.String methodName)
Calls a method on an object on the stack (normally the top/parent object), passing arguments collected from subsequentcallParam()
rule or from the body of this element.CallParamBuilder
callParam()
Saves a parameter for use by a surroundingcallMethod(String)
.PathCallParamBuilder
callParamPath()
Construct a "call parameter" rule that will save the body text of this element as the parameter value.NodeCreateRuleProvider
createNode()
A rule implementation that creates a DOM Node containing the XML at the element that matched the rule.ObjectCreateBuilder
createObject()
Construct an object.PluginCreateRuleBuilder
createPlugin()
A Digester rule which allows the user to declare a plugin.PluginDeclarationRuleBuilder
declarePlugin()
A Digester rule which allows the user to pre-declare a class which is to be referenced later at a plugin point by a PluginCreateRule.FactoryCreateBuilder
factoryCreate()
Uses anObjectCreationFactory
to create a new object which it pushes onto the object stack.<T> ObjectParamBuilder<T>
objectParam(T paramObj)
Saves a parameter for use by a surroundingcallMethod(String)
.BeanPropertySetterBuilder
setBeanProperty()
Construct rule that automatically sets a property from the body text, taking the property name the same as the current element.NestedPropertiesBuilder
setNestedProperties()
Sets properties on the object at the top of the stack, based on child elements with names matching properties on that object.SetNextBuilder
setNext(java.lang.String methodName)
Calls a method on the (top-1) (parent) object, passing the top object (child) as an argument, commonly used to establish parent-child relationships.SetPropertiesBuilder
setProperties()
Sets properties on the object at the top of the stack, based on attributes with corresponding names.SetPropertyBuilder
setProperty(java.lang.String attributePropertyName)
Sets an individual property on the object at the top of the stack, based on attributes with specified names.SetRootBuilder
setRoot(java.lang.String methodName)
Calls a method on the root object on the stack, passing the top object (child) as an argument.SetTopBuilder
setTop(java.lang.String methodName)
Calls a "set top" method on the top (child) object, passing the (top-1) (parent) object as an argument.LinkedRuleBuilder
withNamespaceURI(java.lang.String namespaceURI)
Sets the namespace URI for the current rule pattern.
-
-
-
Field Detail
-
mainBinder
private final RulesBinder mainBinder
-
fromBinderRuleSet
private final FromBinderRuleSet fromBinderRuleSet
-
classLoader
private final java.lang.ClassLoader classLoader
-
keyPattern
private final java.lang.String keyPattern
-
namespaceURI
private java.lang.String namespaceURI
-
-
Constructor Detail
-
LinkedRuleBuilder
LinkedRuleBuilder(RulesBinder mainBinder, FromBinderRuleSet fromBinderRuleSet, java.lang.ClassLoader classLoader, java.lang.String keyPattern)
-
-
Method Detail
-
setBeanProperty
public BeanPropertySetterBuilder setBeanProperty()
Construct rule that automatically sets a property from the body text, taking the property name the same as the current element.- Returns:
- a new
BeanPropertySetterBuilder
instance.
-
callMethod
public CallMethodBuilder callMethod(java.lang.String methodName)
Calls a method on an object on the stack (normally the top/parent object), passing arguments collected from subsequentcallParam()
rule or from the body of this element.- Parameters:
methodName
- Method name of the parent object to call- Returns:
- a new
CallMethodBuilder
instance.
-
callParam
public CallParamBuilder callParam()
Saves a parameter for use by a surroundingcallMethod(String)
.- Returns:
- a new
CallParamBuilder
instance.
-
callParamPath
public PathCallParamBuilder callParamPath()
Construct a "call parameter" rule that will save the body text of this element as the parameter value.- Returns:
- a new
PathCallParamBuilder
instance.
-
factoryCreate
public FactoryCreateBuilder factoryCreate()
Uses anObjectCreationFactory
to create a new object which it pushes onto the object stack. When the element is complete, the object will be popped.- Returns:
- a new
FactoryCreateBuilder
instance.
-
createObject
public ObjectCreateBuilder createObject()
Construct an object.- Returns:
- a new
ObjectCreateBuilder
instance.
-
objectParam
public <T> ObjectParamBuilder<T> objectParam(T paramObj)
Saves a parameter for use by a surroundingcallMethod(String)
.- Type Parameters:
T
- The parameter type to pass along- Parameters:
paramObj
- The parameter to pass along- Returns:
- a new
ObjectParamBuilder
instance.
-
setNestedProperties
public NestedPropertiesBuilder setNestedProperties()
Sets properties on the object at the top of the stack, based on child elements with names matching properties on that object.- Returns:
- a new
NestedPropertiesBuilder
instance.
-
setNext
public SetNextBuilder setNext(java.lang.String methodName)
Calls a method on the (top-1) (parent) object, passing the top object (child) as an argument, commonly used to establish parent-child relationships.- Parameters:
methodName
- Method name of the parent method to call- Returns:
- a new
SetNextBuilder
instance.
-
setProperties
public SetPropertiesBuilder setProperties()
Sets properties on the object at the top of the stack, based on attributes with corresponding names.- Returns:
- a new
SetPropertiesBuilder
instance.
-
setProperty
public SetPropertyBuilder setProperty(java.lang.String attributePropertyName)
Sets an individual property on the object at the top of the stack, based on attributes with specified names.- Parameters:
attributePropertyName
- Name of the attribute that will contain the name of the property to be set- Returns:
- a new
SetPropertyBuilder
instance.
-
setRoot
public SetRootBuilder setRoot(java.lang.String methodName)
Calls a method on the root object on the stack, passing the top object (child) as an argument.- Parameters:
methodName
- Method name of the parent method to call- Returns:
- a new
SetRootBuilder
instance.
-
setTop
public SetTopBuilder setTop(java.lang.String methodName)
Calls a "set top" method on the top (child) object, passing the (top-1) (parent) object as an argument.- Parameters:
methodName
- Method name of the "set parent" method to call- Returns:
- a new
SetTopBuilder
instance.
-
declarePlugin
public PluginDeclarationRuleBuilder declarePlugin()
A Digester rule which allows the user to pre-declare a class which is to be referenced later at a plugin point by a PluginCreateRule. NOTE: when using this rule, make sureDigester
instances will be created usingPluginRules
rules strategy.- Returns:
- a new
PluginDeclarationRuleBuilder
instance.
-
createPlugin
public PluginCreateRuleBuilder createPlugin()
A Digester rule which allows the user to declare a plugin. NOTE: when using this rule, make sureDigester
instances will be created usingPluginRules
rules strategy.- Returns:
- a new
PluginDeclarationRuleBuilder
instance.
-
createNode
public NodeCreateRuleProvider createNode()
A rule implementation that creates a DOM Node containing the XML at the element that matched the rule.- Returns:
- a new
NodeCreateRuleProvider
instance.
-
addRule
public <R extends Rule> ByRuleBuilder<R> addRule(R rule)
Add a custom user rule in the specified pattern. WARNING keep away from this method as much as you can, since there's the risk same inputRule
instance is plugged to more than one Digester; useaddRuleCreatedBy(RuleProvider)
instead!!!- Type Parameters:
R
- The rule type- Parameters:
rule
- The custom user rule- Returns:
- a new
ByRuleBuilder
instance. - See Also:
addRuleCreatedBy(RuleProvider)
,Rule.setDigester(org.apache.commons.digester3.Digester)
-
addRuleCreatedBy
public <R extends Rule> ByRuleProviderBuilder<R> addRuleCreatedBy(RuleProvider<R> provider)
Add a custom user rule in the specified pattern built by the given provider.- Type Parameters:
R
- The rule type- Parameters:
provider
- The rule provider- Returns:
- a new
ByRuleProviderBuilder
instance.
-
withNamespaceURI
public LinkedRuleBuilder withNamespaceURI(java.lang.String namespaceURI)
Sets the namespace URI for the current rule pattern.- Parameters:
namespaceURI
- the namespace URI associated to the rule pattern.- Returns:
- this
LinkedRuleBuilder
instance
-
addProvider
private <R extends Rule,RB extends AbstractBackToLinkedRuleBuilder<R>> RB addProvider(RB provider)
Add a provider in the data structure where storing the providers binding.- Type Parameters:
R
- The rule will be created by the given provider- Parameters:
provider
- The provider has to be stored in the data structure- Returns:
- The provider itself has to be stored in the data structure
-
-