match

The match keyword deals with hierarchical property values.

Purpose

The match predicates are used to handle hierarchical property values.

Context

Any expression involving objects

Syntax

rule property access value 
match 
string value; 
rule property access value
 match up 
string value; 
rule property access value match updown 
string value; 
rule property access value match down 
string value; 

Description

The match predicates have two arguments: the first argument is an access to a rule hierarchical property. To make this access possible, you must define the rule property in a propertydefinition section. The second argument is a string.

Example

This example uses the following element:

You can use the following keywords:

match

?rule.?location match "California" returns true if the location value is equal to California.

match up

?rule.?location match up "California" returns true if the location value is one of the values from the hierarchy root to California node.

match down

?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).

match updown

?rule.?location match updown "California" returns true if the location value either matches up or matches down California.

In this example, the rule task selects all the rules except the rule France.

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; 
  } 
}