Nut stands for Name based User defineable Tag. A method whose name and signature is of a certain pre-defined pattern is called when a sub-element with corresponding name is interpreted inside the xml tag.
For example, for the following tag:
<ctor class="A"> <arg ind="0" val="1"> </ctor>
Method setClass
is called for the "class" attribute, which is of course same as the standard Java Bean convention. In fact, a Nut class is always a Java Bean because it has to have a default public constructor and some setters to set attributes.
Method addArg
is called for each sub-element. And the parameter type of addArg should be another Nut class to support further "tagging".
For tags simply with a list of sub-elements whose names are irrelevant, the set
method with an array parameter is called.
For example:
<array> <return val="1"> <ctor class="B"> <method class="C" name="f"> </array>
Finally, a Nut class can optionally have a method named "eval"
. If this method exist, it is invoked when the tag is evaluated. If the return type is void or the "eval" method does not exist, the Nut object itself is used as the evaluation result. Otherwise, the return value of the "eval" method is used.
|
|
|
|