[jboss-svn-commits] JBL Code SVN: r24192 - in labs/jbossrules/trunk/drools-core/src: test/java/org/drools/base and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Dec 1 22:27:51 EST 2008
Author: tirelli
Date: 2008-12-01 22:27:51 -0500 (Mon, 01 Dec 2008)
New Revision: 24192
Modified:
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/AfterEvaluatorDefinition.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/BeforeEvaluatorDefinition.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/TimeIntervalParser.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/TemporalEvaluatorFactoryTest.java
Log:
JBRULES-1873: fixing and documenting operators
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/AfterEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/AfterEvaluatorDefinition.java 2008-12-02 03:10:07 UTC (rev 24191)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/AfterEvaluatorDefinition.java 2008-12-02 03:27:51 UTC (rev 24192)
@@ -58,9 +58,8 @@
*
* <ul><li>If two values are defined (like in the example bellow), the interval starts on the
* first value and finishes on the second.</li>
- * <li>If only one value is defined, we have two cases. If the value is negative, then the interval
- * starts on the value and finishes on -1ms. If the value is positive, then the interval starts on
- * +1ms and finishes on the value.</li>
+ * <li>If only one value is defined, the interval starts on the value and finishes on the positive
+ * infinity.</li>
* <li>If no value is defined, it is assumed that the initial value is 1ms and the final value
* is the positive infinity.</li></ul>
*
@@ -334,15 +333,8 @@
this.initRange = 1;
this.finalRange = Long.MAX_VALUE;
} else if ( parameters.length == 1 ) {
- if ( parameters[0].longValue() >= 0 ) {
- // up to that value
- this.initRange = 1;
- this.finalRange = parameters[0].longValue();
- } else {
- // from that value up to now
- this.initRange = parameters[0].longValue();
- this.finalRange = -1;
- }
+ this.initRange = parameters[0].longValue();
+ this.finalRange = Long.MAX_VALUE;
} else if ( parameters.length == 2 ) {
if ( parameters[0].longValue() <= parameters[1].longValue() ) {
this.initRange = parameters[0].longValue();
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/BeforeEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/BeforeEvaluatorDefinition.java 2008-12-02 03:10:07 UTC (rev 24191)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/BeforeEvaluatorDefinition.java 2008-12-02 03:27:51 UTC (rev 24192)
@@ -58,9 +58,8 @@
*
* <ul><li>If two values are defined (like in the example bellow), the interval starts on the
* first value and finishes on the second.</li>
- * <li>If only one value is defined, we have two cases. If the value is negative, then the interval
- * starts on the value and finishes on -1ms. If the value is positive, then the interval starts on
- * +1ms and finishes on the value.</li>
+ * <li>If only one value is defined, then the interval starts on the value and finishes on
+ * the positive infinity.</li>
* <li>If no value is defined, it is assumed that the initial value is 1ms and the final value
* is the positive infinity.</li></ul>
*
@@ -335,15 +334,8 @@
this.finalRange = Long.MAX_VALUE;
return;
} else if ( parameters.length == 1 ) {
- if ( parameters[0].longValue() >= 0 ) {
- // up to that value
- this.initRange = 1;
- this.finalRange = parameters[0].longValue();
- } else {
- // from that value up to now
- this.initRange = parameters[0].longValue();
- this.finalRange = -1;
- }
+ this.initRange = parameters[0].longValue();
+ this.finalRange = Long.MAX_VALUE;
} else if ( parameters.length == 2 ) {
if ( parameters[0].longValue() <= parameters[1].longValue() ) {
this.initRange = parameters[0].longValue();
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/TimeIntervalParser.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/TimeIntervalParser.java 2008-12-02 03:10:07 UTC (rev 24191)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/TimeIntervalParser.java 2008-12-02 03:27:51 UTC (rev 24192)
@@ -77,6 +77,12 @@
r = -r;
}
result[index] = new Long( r );
+ } else if( "*".equals( trimmed ) || "+*".equals( trimmed ) ) {
+ // positive infinity
+ result[index] = Long.MAX_VALUE;
+ } else if( "-*".equals( trimmed ) ) {
+ // negative infinity
+ result[index] = Long.MIN_VALUE;
} else {
throw new RuntimeDroolsException( "Error parsing interval value: " + param );
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/TemporalEvaluatorFactoryTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/TemporalEvaluatorFactoryTest.java 2008-12-02 03:10:07 UTC (rev 24191)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/TemporalEvaluatorFactoryTest.java 2008-12-02 03:27:51 UTC (rev 24192)
@@ -85,11 +85,11 @@
{drool, "not after", foo, Boolean.FALSE},
{drool, "not after", bar, Boolean.TRUE},
{bar, "after[1]", foo, Boolean.TRUE},
- {bar, "after[0]", foo, Boolean.FALSE},
+ {bar, "after[0]", foo, Boolean.TRUE},
{bar, "after[-3]", drool, Boolean.TRUE},
{bar, "after[-4]", drool, Boolean.TRUE},
{drool, "after[2]", foo, Boolean.TRUE},
- {drool, "after[1]", foo, Boolean.FALSE},
+ {drool, "after[1]", foo, Boolean.TRUE},
{drool, "after[-2]", bar, Boolean.TRUE},
{drool, "after[-3]", bar, Boolean.TRUE},
{foo, "after[-6]", drool, Boolean.TRUE},
@@ -97,11 +97,11 @@
{foo, "after[-6]", bar, Boolean.TRUE},
{foo, "after[-7]", bar, Boolean.TRUE},
{bar, "not after[1]", foo, Boolean.FALSE},
- {bar, "not after[0]", foo, Boolean.TRUE},
+ {bar, "not after[0]", foo, Boolean.FALSE},
{bar, "not after[-3]", drool, Boolean.FALSE},
{bar, "not after[-4]", drool, Boolean.FALSE},
{drool, "not after[2]", foo, Boolean.FALSE},
- {drool, "not after[1]", foo, Boolean.TRUE},
+ {drool, "not after[1]", foo, Boolean.FALSE},
{drool, "not after[-2]", bar, Boolean.FALSE},
{drool, "not after[-3]", bar, Boolean.FALSE},
{foo, "not after[-6]", drool, Boolean.FALSE},
@@ -170,11 +170,11 @@
{bar, "not before", drool, Boolean.FALSE},
{bar, "not before", foo, Boolean.TRUE},
{foo, "before[2]", drool, Boolean.TRUE},
- {foo, "before[3]", drool, Boolean.TRUE},
+ {foo, "before[3]", drool, Boolean.FALSE},
{foo, "before[-1]", bar, Boolean.TRUE},
{foo, "before[-2]", bar, Boolean.TRUE},
{bar, "before[1]", drool, Boolean.TRUE},
- {bar, "before[2]", drool, Boolean.TRUE},
+ {bar, "before[2]", drool, Boolean.FALSE},
{bar, "before[-3]", foo, Boolean.TRUE},
{bar, "before[-2]", foo, Boolean.FALSE},
{drool, "before[-6]", bar, Boolean.TRUE},
@@ -182,11 +182,11 @@
{drool, "before[-7]", foo, Boolean.TRUE},
{drool, "before[-8]", foo, Boolean.TRUE},
{foo, "not before[2]", drool, Boolean.FALSE},
- {foo, "not before[3]", drool, Boolean.FALSE},
+ {foo, "not before[3]", drool, Boolean.TRUE},
{foo, "not before[-1]", bar, Boolean.FALSE},
{foo, "not before[-2]", bar, Boolean.FALSE},
{bar, "not before[1]", drool, Boolean.FALSE},
- {bar, "not before[2]", drool, Boolean.FALSE},
+ {bar, "not before[2]", drool, Boolean.TRUE},
{bar, "not before[-3]", foo, Boolean.FALSE},
{bar, "not before[-2]", foo, Boolean.TRUE},
{drool, "not before[-6]", bar, Boolean.FALSE},
More information about the jboss-svn-commits
mailing list