RUL-01726 when Defining new Pattern in a Rule

After importing XMLFacts from an XSD, you try to create a new Pattern for a new Rule by comparing a Double (java.lang.Double type) with a double value (e.g. 4.2) , and you get following error in RuleAuthor

'RUL-01726: Data type operator for <, at position 0: java.lang.Double

The reason is that xsd:double type from the XSD was transformed in Rules into the Java class java.lang.Double. When you try to compare it with a double value (e.g. 4.2), this raises an error as you cannot compare a Java Class with a double value.

In order to compare these two data types, you can use the following solution :

1. Go to Definition -> JavaFact and click on Create to create a new JavaFact
2. Expand java.lang tree and select the Double class
3. Click Import . At this moment you should also see a new JavaFact created and named
java.lang.Double
4. Now go to RuleSets -> Rules and try to create a New Pattern
5. Create a new pattern and before clicking apply select the "Advanced Test " option
6. Edit the expression and change it to
myValue.doubleValue() <>The solution is to use the doubleValue() method of the java.lang.Double class. This method returns the double value, so you can compare it now with a number.

Note: Same would apply for other types of variables. For example, if you get an error "java.lang.Integer <>

Posted in Labels: , |

0 comments: