| Reference > Rule Languages > ILOG Rule Language > IRL Keywords > match |
match |
PREVIOUS NEXT |
Predicates to deal with hierarchical property values. This keyword is used in any expression involving IlrRule.
rule property access valuematchstring value; rule property access valuematch upstring value; rule property access valuematch updownstring value; rule property access valuematch downstring value;
The match predicates have two arguments: the left argument is an access to a rule hierarchical property. To make this possible, the rule property should have been defined in a propertydefinition section. The right argument is a string.
Let Geography be a hierarchical property defined as follows:
hierarchy Geography { "North"
{ "USA" { "California" { "San Francisco" } "Texas" { "Houston" "Paris" } }
"Europe" { "France" { } "Germany" } }
}
location be a rule property whose type is Geography,
and ?rule :
?rule.?location match "California" returns true if the location value is equal to "California".
?rule.?location match up "California" returns true if the location value is one of the values from the hierarchy root to "California" node.
?rule.?location match down "California" returns true if the location value is one of the values from the "California" node to the hierarchy leaves (children of "California" node).
?rule.?location match updown "California" returns true if the location value either match up or match down "California".
Given the sample code:
hierarchy Geography { "North"
{ "USA" { "California" { "San Francisco" } "Texas" { "Houston" "Paris" } }
"Europe" { "France" { } "Germany" } }
}
propertydefinition { Geography location; }
rule usa { property location = "USA"; when { ... } then { ... } }
rule california { property location = "California"; when { ... } then { ... } }
rule france { property location = "France"; when { ... } then { ... } }
ruletask main
{
body = dynamicselect()
{
Collection rules = collect IlrRule(?this.?location match up "California")
in getRuleset().getAllRules();
return rules;
}
}
In the above example the ruletask selects all the rules except the rule France.
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |