ObjectParamRulepublic class ObjectParamRule extends Rule Rule implementation that saves a parameter for use by a surrounding
CallMethodRule.
This parameter may be:
- an arbitrary Object defined programatically, assigned when the element pattern associated with the Rule is matched
See {@link #ObjectParamRule(int paramIndex, Object param)}
- an arbitrary Object defined programatically, assigned if the element pattern AND specified attribute name are matched
See {@link #ObjectParamRule(int paramIndex, String attributeName, Object param)}
|
Fields Summary |
---|
protected String | attributeNameThe attribute which we are attempting to match | protected int | paramIndexThe zero-relative index of the parameter we are saving. | protected Object | paramThe parameter we wish to pass to the method call |
Constructors Summary |
---|
public ObjectParamRule(int paramIndex, Object param)Construct a "call parameter" rule that will save the given Object as
the parameter value.
this(paramIndex, null, param);
| public ObjectParamRule(int paramIndex, String attributeName, Object param)Construct a "call parameter" rule that will save the given Object as
the parameter value, provided that the specified attribute exists.
this.paramIndex = paramIndex;
this.attributeName = attributeName;
this.param = param;
|
Methods Summary |
---|
public void | begin(java.lang.String namespace, java.lang.String name, org.xml.sax.Attributes attributes)Process the start of this element.
// --------------------------------------------------------- Public Methods
Object anAttribute = null;
Object parameters[] = (Object[]) digester.peekParams();
if (attributeName != null) {
anAttribute = attributes.getValue(attributeName);
if(anAttribute != null) {
parameters[paramIndex] = param;
}
// note -- if attributeName != null and anAttribute == null, this rule
// will pass null as its parameter!
}else{
parameters[paramIndex] = param;
}
| public java.lang.String | toString()Render a printable version of this Rule.
StringBuffer sb = new StringBuffer("ObjectParamRule[");
sb.append("paramIndex=");
sb.append(paramIndex);
sb.append(", attributeName=");
sb.append(attributeName);
sb.append(", param=");
sb.append(param);
sb.append("]");
return (sb.toString());
|
|