Der Ausdruck property (siehe Eigenschaft, und property) lässt den Aufruf von "sicheren" Java-Methoden zu.
Regelwerke enthalten häufig viele Instanzen von java.util.List.
Die Sicherheitsliste der Methoden für java.util.List ist in CER enthalten.
# Safe list for java.util.List contains.safe=true containsAll.safe=true get.safe=true indexOf.safe=true isEmpty.safe=true lastIndexOf.safe=true size.safe=true subList.safe=true # not exposed hashCode.safe=false listIterator.safe=false iterator.safe=false toArray.safe=false # mutators - unsafe add.safe=false addAll.safe=false clear.safe=false remove.safe=false removeAll.safe=false retainAll.safe=false
Die Beschreibungen dieser Methoden sind im JavaDoc für java.util.List verfügbar. Die besonders nützlichen Eigenschaften sollen hier zur Referenz jedoch kurz beschrieben werden:
Gibt true zurück, wenn diese Liste keine Elemente enthält.
Gibt die Anzahl der Elemente in dieser Liste zurück.
Gibt das Element an der angegebenen Position in dieser Liste zurück. Bitte beachten Sie, dass Sie einen Wert des Typs Number mit intValue in eine Ganzzahl konvertieren müssen, weil CER gerundete numerische Werte als Instanzen des Typs Number übergibt.
Gibt true zurück, falls diese Liste das angegebene Element enthält.
<?xml version="1.0" encoding="UTF-8"?> <RuleSet name="Example_UsefulListOperations" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "http://www.curamsoftware.com/CreoleRulesSchema.xsd"> <Class name="Person"> <!-- Exactly one Person (in each household) will be designated as the head of household --> <Attribute name="isHeadOfHousehold"> <type> <javaclass name="Boolean"/> </type> <derivation> <specified/> </derivation> </Attribute> <!-- The children of this person. --> <Attribute name="children"> <type> <javaclass name="List"> <ruleclass name="Person"/> </javaclass> </type> <derivation> <specified/> </derivation> </Attribute> <!-- Whether this person has any children. Tests the isEmpty property of List. --> <Attribute name="hasChildren"> <type> <javaclass name="Boolean"/> </type> <derivation> <not> <property name="isEmpty"> <object> <reference attribute="children"/> </object> </property> </not> </derivation> </Attribute> <Attribute name="numberOfChildren"> <type> <javaclass name="Number"/> </type> <derivation> <property name="size"> <object> <reference attribute="children"/> </object> </property> </derivation> </Attribute> <!-- This person's second child, if any, otherwise null --> <Attribute name="secondChild"> <type> <ruleclass name="Person"/> </type> <derivation> <!-- We have to check whether the person has two or more children --> <choose> <type> <ruleclass name="Person"/> </type> <when> <condition> <compare comparison=">="> <reference attribute="numberOfChildren"/> <Number value="2"/> </compare> </condition> <value> <!-- Use the "get" property to get the second item in the list - denoted by index 1 (lists in Java are zero-based) --> <property name="get"> <object> <reference attribute="children"/> </object> <arguments> <!-- The number must be converted to an integer (as required by List.subList). --> <property name="intValue"> <object> <Number value="1"/> </object> </property> </arguments> </property> </value> </when> <otherwise> <!-- This person has no second child --> <value> <null/> </value> </otherwise> </choose> </derivation> </Attribute> <Attribute name="isChildOfHeadOfHousehold"> <type> <javaclass name="Boolean"/> </type> <derivation> <property name="contains"> <object> <!-- The children of the head of household --> <reference attribute="children"> <!-- retrieve the single Person rule object which has isHeadOfHousehold equal to true--> <singleitem onEmpty="error" onMultiple="error"> <readall ruleclass="Person"> <match retrievedattribute="isHeadOfHousehold"> <true/> </match> </readall> </singleitem> </reference> </object> <!-- check whether the list of the head of household's children contains THIS Person --> <arguments> <this/> </arguments> </property> </derivation> </Attribute> </Class> </RuleSet>