Branch Algorithms
The out-of-the-box branch algorithms are as follows:
Algorithm
Description
wt.rule.algorithm.BooleanBranch
Takes a list of three objects. The first object contained in a Value tag is expected to be an object that returns a Boolean that tells BooleanBranch algorithm which of the other two objects, each contained in an argument to return.
wt.rule.algorithm.CaseBranch
Is similar to BooleanBranch, except that the branch occurs when a case is TRUE. There is an argument for each case plus one additional argument that identifies the default if no cases are TRUE.
The general syntax for the BooleanBranch algorithms is:
<Value algorithm="wt.rule.algorithm.BooleanBranch">
<Value algorithm="xxx">
:
</Value>
<Arg>yyy</Arg>
<Arg>zzz</Arg>
</Value>
The algorithm named in the nested Value tag (identified by xxx in the format) can be any valid algorithm that results in Boolean value. One of the objects in the arguments (identified by the Arg tags and the yyy and zzz strings) is used depending on the result of the xxx algorithm.
The general syntax for a CaseBranch algorithm that has three cases is:
<Value algorithm="wt.rule.algorithm.CaseBranch">

<Value algorithm="xxx1">
:
</Value>
<Arg>yyy1</Arg>

<Value algorithm="xxx2">
:
</Value>
<Arg>yyy2</Arg>

<Value algorithm="xxx3">
:
</Value>
<Arg>yyy3</Arg>
<Arg>yyy4</Arg>

</Value>
A CaseBranch algorithm can have any number of cases. Each case in the CaseBranch algorithm consists of a Value element that can be evaluated as either TRUE or FALSE and an argument that follows directly after the Value element. If the Value element is TRUE, then the argument is used and the remaining tags in the constraint are not evaluated. If the Value element in the first case is FALSE, then the next case is evaluated. The evaluation of each case continues in the order that the cases appear in the file until the current evaluation produces a TRUE result. The argument associated with the case is used. If none of the cases specified are TRUE, then last argument supplied for the CaseBranch algorithm is used.
In the general syntax above, the values you can use in Arg tags are strings. Optionally, the Arg tags can be replaced by Value tags. Using nested Value tags in place of Arg tags allows you to perform additional evaluations within the arguments.
Isto foi útil?