[jboss-svn-commits] JBL Code SVN: r24377 - in labs/jbossrules/trunk: drools-compiler/src/test/java/org/drools and 7 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Dec 15 00:10:02 EST 2008
Author: tirelli
Date: 2008-12-15 00:10:01 -0500 (Mon, 15 Dec 2008)
New Revision: 24377
Added:
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_CEP_TemporalOperatorsDates.drl
Modified:
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/PatternBuilder.java
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/StockTick.java
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/CepEspTest.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/BaseClassFieldReader.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/BaseEvaluator.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ValueType.java
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/CoincidesEvaluatorDefinition.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ComparableEvaluatorsDefinition.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/DuringEvaluatorDefinition.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/EqualityEvaluatorsDefinition.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorDefinition.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/FinishedByEvaluatorDefinition.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/FinishesEvaluatorDefinition.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/IncludesEvaluatorDefinition.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/MatchesEvaluatorsDefinition.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/MeetsEvaluatorDefinition.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/MetByEvaluatorDefinition.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/OverlappedByEvaluatorDefinition.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/OverlapsEvaluatorDefinition.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/SetEvaluatorsDefinition.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/SoundslikeEvaluatorsDefinition.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/StartedByEvaluatorDefinition.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/StartsEvaluatorDefinition.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseObjectClassFieldReader.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/SelfReferenceClassFieldReader.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/VariableRestriction.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Evaluator.java
Log:
JBRULES-1894: adding support to arbitrary date fields on temporal evaluators
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/PatternBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/PatternBuilder.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/PatternBuilder.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -27,6 +27,7 @@
import org.drools.base.FieldFactory;
import org.drools.base.ValueType;
import org.drools.base.evaluators.EvaluatorDefinition;
+import org.drools.base.evaluators.EvaluatorDefinition.Target;
import org.drools.base.field.ObjectFieldImpl;
import org.drools.compiler.DescrBuildError;
import org.drools.compiler.Dialect;
@@ -748,12 +749,19 @@
}
}
+ Target right = ( Date.class.isAssignableFrom( extractor.getExtractToClass() ) ||
+ Number.class.isAssignableFrom( extractor.getExtractToClass() ) ) ? Target.FACT : Target.HANDLE;
+ Target left = ( declaration.isPatternDeclaration() && !
+ ( Date.class.isAssignableFrom( declaration.getExtractor().getExtractToClass() ) ||
+ Number.class.isAssignableFrom( declaration.getExtractor().getExtractToClass() ) ) )? Target.HANDLE : Target.FACT;
final Evaluator evaluator = getEvaluator( context,
variableRestrictionDescr,
extractor.getValueType(),
variableRestrictionDescr.getEvaluator(),
variableRestrictionDescr.isNegated(),
- variableRestrictionDescr.getParameterText() );
+ variableRestrictionDescr.getParameterText(),
+ left,
+ right );
if ( evaluator == null ) {
return null;
}
@@ -788,12 +796,17 @@
return null;
}
+ Target right = ( Date.class.isAssignableFrom( extractor.getExtractToClass() ) ||
+ Number.class.isAssignableFrom( extractor.getExtractToClass() ) ) ? Target.FACT : Target.HANDLE;
+ Target left = Target.FACT;
final Evaluator evaluator = getEvaluator( context,
literalRestrictionDescr,
extractor.getValueType(),
literalRestrictionDescr.getEvaluator(),
literalRestrictionDescr.isNegated(),
- literalRestrictionDescr.getParameterText() );
+ literalRestrictionDescr.getParameterText(),
+ left,
+ right );
if ( evaluator == null ) {
return null;
}
@@ -837,12 +850,19 @@
}
if ( implicit != null ) {
+ Target right = ( Date.class.isAssignableFrom( extractor.getExtractToClass() ) ||
+ Number.class.isAssignableFrom( extractor.getExtractToClass() ) ) ? Target.FACT : Target.HANDLE;
+ Target left = ( implicit.isPatternDeclaration() && !
+ ( Date.class.isAssignableFrom( implicit.getExtractor().getExtractToClass() ) ||
+ Number.class.isAssignableFrom( implicit.getExtractor().getExtractToClass() ) ) )? Target.HANDLE : Target.FACT;
final Evaluator evaluator = getEvaluator( context,
qiRestrictionDescr,
extractor.getValueType(),
qiRestrictionDescr.getEvaluator(),
qiRestrictionDescr.isNegated(),
- qiRestrictionDescr.getParameterText() );
+ qiRestrictionDescr.getParameterText(),
+ left,
+ right );
if ( evaluator == null ) {
return null;
}
@@ -879,12 +899,17 @@
return null;
}
+ Target right = ( Date.class.isAssignableFrom( extractor.getExtractToClass() ) ||
+ Number.class.isAssignableFrom( extractor.getExtractToClass() ) ) ? Target.FACT : Target.HANDLE;
+ Target left = Target.FACT;
final Evaluator evaluator = getEvaluator( context,
qiRestrictionDescr,
extractor.getValueType(),
qiRestrictionDescr.getEvaluator(),
qiRestrictionDescr.isNegated(),
- qiRestrictionDescr.getParameterText() );
+ qiRestrictionDescr.getParameterText(),
+ left,
+ right );
if ( evaluator == null ) {
return null;
}
@@ -921,12 +946,17 @@
analysis.getNotBoundedIdentifiers(),
factDeclarations );
+ Target right = ( Date.class.isAssignableFrom( extractor.getExtractToClass() ) ||
+ Number.class.isAssignableFrom( extractor.getExtractToClass() ) ) ? Target.FACT : Target.HANDLE;
+ Target left = Target.FACT;
final Evaluator evaluator = getEvaluator( context,
returnValueRestrictionDescr,
extractor.getValueType(),
returnValueRestrictionDescr.getEvaluator(),
returnValueRestrictionDescr.isNegated(),
- returnValueRestrictionDescr.getParameterText() );
+ returnValueRestrictionDescr.getParameterText(),
+ left,
+ right );
if ( evaluator == null ) {
return null;
}
@@ -1005,7 +1035,9 @@
final ValueType valueType,
final String evaluatorString,
final boolean isNegated,
- final String parameterText) {
+ final String parameterText,
+ final Target left,
+ final Target right ) {
final EvaluatorDefinition def = context.getConfiguration().getEvaluatorRegistry().getEvaluatorDefinition( evaluatorString );
if ( def == null ) {
@@ -1018,7 +1050,9 @@
final Evaluator evaluator = def.getEvaluator( valueType,
evaluatorString,
isNegated,
- parameterText );
+ parameterText,
+ left,
+ right );
if ( evaluator == null ) {
context.getErrors().add( new DescrBuildError( context.getParentDescr(),
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/StockTick.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/StockTick.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/StockTick.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -4,6 +4,8 @@
import java.util.Date;
public class StockTick implements Serializable {
+ private static final long serialVersionUID = -1702366432018395425L;
+
private long seq;
private String company;
private double price;
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/CepEspTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/CepEspTest.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/CepEspTest.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -55,6 +55,7 @@
final RuleBaseConfiguration conf) throws IOException,
DroolsParserException,
Exception {
+ final PackageBuilder builder = new PackageBuilder();
final DrlParser parser = new DrlParser();
final PackageDescr packageDescr = parser.parse( reader );
if ( parser.hasErrors() ) {
@@ -62,7 +63,6 @@
Assert.fail( "Error messages in parser, need to sort this our (or else collect error messages)" );
}
// pre build the package
- final PackageBuilder builder = new PackageBuilder();
builder.addPackage( packageDescr );
final Package pkg = builder.getPackage();
@@ -500,6 +500,51 @@
}
+ public void testTemporalOperatorsOnArbitraryDates() throws Exception {
+ // read in the source
+ final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_CEP_TemporalOperatorsDates.drl" ) );
+ final RuleBaseConfiguration rbconf = new RuleBaseConfiguration();
+ final RuleBase ruleBase = loadRuleBase( reader,
+ rbconf );
+
+ SessionConfiguration conf = new SessionConfiguration();
+ conf.setClockType( ClockType.PSEUDO_CLOCK );
+ StatefulSession wm = ruleBase.newStatefulSession( conf );
+
+ final List<?> results = new ArrayList<Object>();
+
+ wm.setGlobal( "results",
+ results );
+
+ StockTick tick1 = new StockTick( 1,
+ "DROO",
+ 50,
+ 100000, // arbitrary timestamp
+ 3 );
+ StockTick tick2 = new StockTick( 2,
+ "ACME",
+ 10,
+ 104000, // 4 seconds after DROO
+ 3 );
+
+ InternalFactHandle handle1 = (InternalFactHandle) wm.insert( tick1 );
+ InternalFactHandle handle2 = (InternalFactHandle) wm.insert( tick2 );
+
+ assertNotNull( handle1 );
+ assertNotNull( handle2 );
+
+ assertFalse( handle1.isEvent() );
+ assertFalse( handle2.isEvent() );
+
+ // wm = SerializationHelper.serializeObject(wm);
+ wm.fireAllRules();
+
+ assertEquals( 1,
+ results.size() );
+ assertEquals( tick2,
+ results.get( 0 ) );
+ }
+
// @FIXME: we need to decide on the semantics of expiration
public void FIXME_testSimpleTimeWindow() throws Exception {
// read in the source
Added: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_CEP_TemporalOperatorsDates.drl
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_CEP_TemporalOperatorsDates.drl (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_CEP_TemporalOperatorsDates.drl 2008-12-15 05:10:01 UTC (rev 24377)
@@ -0,0 +1,14 @@
+package org.drools;
+
+import org.drools.StockTick;
+
+global java.util.List results;
+
+rule "after operator on date"
+when
+ $a : StockTick( company == "DROO" )
+ $b : StockTick( company == "ACME", dateTimestamp after[1s,10s] $a.dateTimestamp )
+then
+ results.add( $b );
+end
+
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/BaseClassFieldReader.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/BaseClassFieldReader.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/BaseClassFieldReader.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -46,8 +46,8 @@
* @param valueType
*/
protected BaseClassFieldReader(final int index,
- final Class fieldType,
- final ValueType valueType) {
+ final Class< ? > fieldType,
+ final ValueType valueType) {
this.index = index;
this.fieldType = fieldType;
this.valueType = valueType;
@@ -59,37 +59,37 @@
* @param clazz
* @param fieldName
*/
- public BaseClassFieldReader(final Class clazz,
- final String fieldName) {
+ public BaseClassFieldReader(final Class< ? > clazz,
+ final String fieldName) {
try {
final ClassFieldInspector inspector = new ClassFieldInspector( clazz );
this.index = ((Integer) inspector.getFieldNames().get( fieldName )).intValue();
- this.fieldType = (Class) inspector.getFieldTypes().get( fieldName );
+ this.fieldType = (Class< ? >) inspector.getFieldTypes().get( fieldName );
this.valueType = ValueType.determineValueType( this.fieldType );
} catch ( final Exception e ) {
throw new RuntimeDroolsException( e );
}
}
-// public void readExternal(ObjectInput in) throws IOException,
-// ClassNotFoundException {
-// index = in.readInt();
-// fieldType = (Class) in.readObject();
-// valueType = (ValueType) in.readObject();
-// if ( valueType != null ) valueType = ValueType.determineValueType( valueType.getClassType() );
-// }
-//
-// public void writeExternal(ObjectOutput out) throws IOException {
-// out.writeInt( index );
-// out.writeObject( fieldType );
-// out.writeObject( valueType );
-// }
+ // public void readExternal(ObjectInput in) throws IOException,
+ // ClassNotFoundException {
+ // index = in.readInt();
+ // fieldType = (Class) in.readObject();
+ // valueType = (ValueType) in.readObject();
+ // if ( valueType != null ) valueType = ValueType.determineValueType( valueType.getClassType() );
+ // }
+ //
+ // public void writeExternal(ObjectOutput out) throws IOException {
+ // out.writeInt( index );
+ // out.writeObject( fieldType );
+ // out.writeObject( valueType );
+ // }
public int getIndex() {
return this.index;
}
- public Class getExtractToClass() {
+ public Class< ? > getExtractToClass() {
return this.fieldType;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/BaseEvaluator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/BaseEvaluator.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/BaseEvaluator.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -73,10 +73,26 @@
return this.type;
}
- public Object prepareObject(InternalFactHandle handle) {
+ /**
+ * Most evaluators operate on the fact attributes,
+ * so, by default, the implementation unwraps it,
+ * but subclasses can override this behaviour.
+ */
+ public Object prepareLeftObject(InternalFactHandle handle) {
return handle.getObject();
}
+ /**
+ * Most evaluators operate o symmetrical types of object
+ * on both sides, i.e., either they operate on facts on
+ * both sides, or fact handles on both sides. But eventually,
+ * some operators (like 'after') may differ in behaviour and
+ * so, they are allowed to override this method.
+ */
+ public Object prepareRightObject(InternalFactHandle handle) {
+ return prepareLeftObject( handle );
+ }
+
public boolean isTemporal() {
return false;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ValueType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ValueType.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ValueType.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -9,6 +9,7 @@
import java.util.Date;
import org.drools.RuntimeDroolsException;
+import org.drools.common.EventFactHandle;
import org.drools.facttemplates.FactTemplate;
public class ValueType
@@ -92,9 +93,12 @@
public static final ValueType BIG_INTEGER_TYPE = new ValueType( "BigInteger",
BigInteger.class,
SimpleValueType.OBJECT );
+ public static final ValueType EVENT_TYPE = new ValueType( "Event",
+ EventFactHandle.class,
+ SimpleValueType.OBJECT );
private String name;
- private Class classType;
+ private Class<?> classType;
private int simpleType;
public ValueType() {
@@ -102,7 +106,7 @@
}
private ValueType(final String name,
- final Class classType,
+ final Class<?> classType,
final int simpleType) {
this.name = name;
this.classType = classType;
@@ -111,7 +115,7 @@
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
name = (String)in.readObject();
- classType = (Class)in.readObject();
+ classType = (Class<?>)in.readObject();
simpleType = in.readInt();
}
@@ -129,7 +133,7 @@
return this.name;
}
- public Class getClassType() {
+ public Class<?> getClassType() {
return this.classType;
}
@@ -137,7 +141,7 @@
return this.simpleType;
}
- public static ValueType determineValueType(final Class clazz) {
+ public static ValueType determineValueType(final Class<?> clazz) {
if ( clazz == null ) {
return ValueType.NULL_TYPE;
}
@@ -187,6 +191,8 @@
return ValueType.BIG_INTEGER_TYPE;
} else if ( clazz == String.class ) {
return ValueType.STRING_TYPE;
+ } else if ( clazz == EventFactHandle.class ) {
+ return ValueType.EVENT_TYPE;
} else if ( clazz instanceof Object ) {
return ValueType.OBJECT_TYPE;
}
@@ -234,5 +240,9 @@
public boolean isChar() {
return this.simpleType == SimpleValueType.CHAR;
}
+
+ public boolean isEvent() {
+ return this.classType == EventFactHandle.class;
+ }
}
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-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/AfterEvaluatorDefinition.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -21,6 +21,7 @@
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Collections;
+import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@@ -112,7 +113,9 @@
return this.getEvaluator( type,
operator.getOperatorString(),
operator.isNegated(),
- null );
+ null,
+ Target.HANDLE,
+ Target.HANDLE );
}
/**
@@ -124,7 +127,9 @@
return this.getEvaluator( type,
operator.getOperatorString(),
operator.isNegated(),
- parameterText );
+ parameterText,
+ Target.HANDLE,
+ Target.HANDLE );
}
/**
@@ -134,6 +139,24 @@
final String operatorId,
final boolean isNegated,
final String parameterText) {
+ return this.getEvaluator( type,
+ operatorId,
+ isNegated,
+ parameterText,
+ Target.HANDLE,
+ Target.HANDLE );
+
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Evaluator getEvaluator(final ValueType type,
+ final String operatorId,
+ final boolean isNegated,
+ final String parameterText,
+ final Target left,
+ final Target right) {
if ( this.cache == Collections.EMPTY_MAP ) {
this.cache = new HashMap<String, Evaluator>();
}
@@ -144,7 +167,9 @@
eval = new AfterEvaluator( type,
isNegated,
params,
- parameterText );
+ parameterText,
+ left == Target.FACT,
+ right == Target.FACT );
this.cache.put( key,
eval );
}
@@ -168,8 +193,8 @@
/**
* @inheritDoc
*/
- public boolean operatesOnFactHandles() {
- return true;
+ public Target getTarget() {
+ return Target.BOTH;
}
/**
@@ -190,6 +215,8 @@
private long initRange;
private long finalRange;
private String paramText;
+ private boolean unwrapLeft;
+ private boolean unwrapRight;
public AfterEvaluator() {
}
@@ -197,10 +224,14 @@
public AfterEvaluator(final ValueType type,
final boolean isNegated,
final Long[] parameters,
- final String paramText) {
+ final String paramText,
+ final boolean unwrapLeft,
+ final boolean unwrapRight) {
super( type,
isNegated ? NOT_AFTER : AFTER );
this.paramText = paramText;
+ this.unwrapLeft = unwrapLeft;
+ this.unwrapRight = unwrapRight;
this.setParameters( parameters );
}
@@ -209,6 +240,8 @@
super.readExternal( in );
initRange = in.readLong();
finalRange = in.readLong();
+ unwrapLeft = in.readBoolean();
+ unwrapRight = in.readBoolean();
paramText = (String) in.readObject();
}
@@ -216,15 +249,22 @@
super.writeExternal( out );
out.writeLong( initRange );
out.writeLong( finalRange );
+ out.writeBoolean( unwrapLeft );
+ out.writeBoolean( unwrapRight );
out.writeObject( paramText );
}
@Override
- public Object prepareObject(InternalFactHandle handle) {
- return handle;
+ public Object prepareLeftObject(InternalFactHandle handle) {
+ return unwrapLeft ? handle.getObject() : handle;
}
@Override
+ public Object prepareRightObject(InternalFactHandle handle) {
+ return unwrapRight ? handle.getObject() : handle;
+ }
+
+ @Override
public boolean isTemporal() {
return true;
}
@@ -265,7 +305,12 @@
if ( context.rightNull ) {
return false;
}
- long dist = ((EventFactHandle) ((ObjectVariableContextEntry) context).right).getStartTimestamp() - ((EventFactHandle) left).getEndTimestamp();
+ long rightTS = this.unwrapRight ? ((Date) ((ObjectVariableContextEntry) context).right).getTime() : ((EventFactHandle) ((ObjectVariableContextEntry) context).right).getStartTimestamp();
+
+ long leftTS = this.unwrapLeft ? context.declaration.getExtractor().getLongValue( workingMemory,
+ left ) : ((EventFactHandle) left).getEndTimestamp();
+
+ long dist = rightTS - leftTS;
return this.getOperator().isNegated() ^ (dist >= this.initRange && dist <= this.finalRange);
}
@@ -276,8 +321,13 @@
right ) ) {
return false;
}
- long dist = ((EventFactHandle) right).getStartTimestamp() - ((EventFactHandle) ((ObjectVariableContextEntry) context).left).getEndTimestamp();
+ long rightTS = this.unwrapRight ? context.extractor.getLongValue( workingMemory,
+ right ) : ((EventFactHandle) right).getStartTimestamp();
+ long leftTS = this.unwrapLeft ? ((Date) ((ObjectVariableContextEntry) context).left).getTime() : ((EventFactHandle) ((ObjectVariableContextEntry) context).left).getEndTimestamp();
+
+ long dist = rightTS - leftTS;
+
return this.getOperator().isNegated() ^ (dist >= this.initRange && dist <= this.finalRange);
}
@@ -290,7 +340,15 @@
object1 ) ) {
return false;
}
- long dist = ((EventFactHandle) object1).getStartTimestamp() - ((EventFactHandle) object2).getEndTimestamp();
+ long rightTS = this.unwrapRight ?
+ extractor1.getLongValue( workingMemory, object1 ) :
+ ((EventFactHandle) object1).getStartTimestamp();
+
+ long leftTS = this.unwrapLeft ?
+ extractor2.getLongValue( workingMemory, object2 ) :
+ ((EventFactHandle) object2).getEndTimestamp();
+
+ long dist = rightTS - leftTS;
return this.getOperator().isNegated() ^ (dist >= this.initRange && dist <= this.finalRange);
}
@@ -298,28 +356,32 @@
return this.getOperator().toString() + "[" + paramText + "]";
}
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode() {
- final int PRIME = 31;
+ final int prime = 31;
int result = super.hashCode();
- result = PRIME * result + (int) (finalRange ^ (finalRange >>> 32));
- result = PRIME * result + (int) (initRange ^ (initRange >>> 32));
+ result = prime * result + (int) (finalRange ^ (finalRange >>> 32));
+ result = prime * result + (int) (initRange ^ (initRange >>> 32));
+ result = prime * result + ((paramText == null) ? 0 : paramText.hashCode());
+ result = prime * result + (unwrapLeft ? 1231 : 1237);
+ result = prime * result + (unwrapRight ? 1231 : 1237);
return result;
}
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(Object obj) {
if ( this == obj ) return true;
if ( !super.equals( obj ) ) return false;
if ( getClass() != obj.getClass() ) return false;
- final AfterEvaluator other = (AfterEvaluator) obj;
- return finalRange == other.finalRange && initRange == other.initRange;
+ AfterEvaluator other = (AfterEvaluator) obj;
+ if ( finalRange != other.finalRange ) return false;
+ if ( initRange != other.initRange ) return false;
+ if ( paramText == null ) {
+ if ( other.paramText != null ) return false;
+ } else if ( !paramText.equals( other.paramText ) ) return false;
+ if ( unwrapLeft != other.unwrapLeft ) return false;
+ if ( unwrapRight != other.unwrapRight ) return false;
+ return true;
}
/**
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-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/BeforeEvaluatorDefinition.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -27,6 +27,7 @@
import org.drools.RuntimeDroolsException;
import org.drools.base.BaseEvaluator;
import org.drools.base.ValueType;
+import org.drools.base.evaluators.EvaluatorDefinition.Target;
import org.drools.common.EventFactHandle;
import org.drools.common.InternalFactHandle;
import org.drools.common.InternalWorkingMemory;
@@ -133,7 +134,25 @@
public Evaluator getEvaluator(final ValueType type,
final String operatorId,
final boolean isNegated,
- final String parameterText) {
+ final String parameterText ) {
+ return this.getEvaluator( type,
+ operatorId,
+ isNegated,
+ parameterText,
+ Target.HANDLE,
+ Target.HANDLE );
+
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Evaluator getEvaluator(final ValueType type,
+ final String operatorId,
+ final boolean isNegated,
+ final String parameterText,
+ final Target left,
+ final Target right ) {
if ( this.cache == Collections.EMPTY_MAP ) {
this.cache = new HashMap<String, BeforeEvaluator>();
}
@@ -168,8 +187,8 @@
/**
* @inheritDoc
*/
- public boolean operatesOnFactHandles() {
- return true;
+ public Target getTarget() {
+ return Target.BOTH;
}
/**
@@ -220,7 +239,7 @@
}
@Override
- public Object prepareObject(InternalFactHandle handle) {
+ public Object prepareLeftObject(InternalFactHandle handle) {
return handle;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/CoincidesEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/CoincidesEvaluatorDefinition.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/CoincidesEvaluatorDefinition.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -126,7 +126,25 @@
public Evaluator getEvaluator(final ValueType type,
final String operatorId,
final boolean isNegated,
- final String parameterText) {
+ final String parameterText ) {
+ return this.getEvaluator( type,
+ operatorId,
+ isNegated,
+ parameterText,
+ Target.HANDLE,
+ Target.HANDLE );
+
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Evaluator getEvaluator(final ValueType type,
+ final String operatorId,
+ final boolean isNegated,
+ final String parameterText,
+ final Target left,
+ final Target right ) {
if ( this.cache == Collections.EMPTY_MAP ) {
this.cache = new HashMap<String, CoincidesEvaluator>();
}
@@ -161,8 +179,8 @@
/**
* @inheritDoc
*/
- public boolean operatesOnFactHandles() {
- return true;
+ public Target getTarget() {
+ return Target.BOTH;
}
/**
@@ -213,7 +231,7 @@
}
@Override
- public Object prepareObject(InternalFactHandle handle) {
+ public Object prepareLeftObject(InternalFactHandle handle) {
return handle;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ComparableEvaluatorsDefinition.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ComparableEvaluatorsDefinition.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/ComparableEvaluatorsDefinition.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -157,6 +157,24 @@
final String operatorId,
final boolean isNegated,
final String parameterText) {
+ return this.getEvaluator( type,
+ operatorId,
+ isNegated,
+ parameterText,
+ Target.FACT,
+ Target.FACT );
+
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Evaluator getEvaluator(final ValueType type,
+ final String operatorId,
+ final boolean isNegated,
+ final String parameterText,
+ final Target left,
+ final Target right ) {
return this.evaluators.getEvaluator( type,
Operator.determineOperator( operatorId,
isNegated ) );
@@ -170,8 +188,8 @@
return false;
}
- public boolean operatesOnFactHandles() {
- return false;
+ public Target getTarget() {
+ return Target.FACT;
}
public boolean supportsType(ValueType type) {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/DuringEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/DuringEvaluatorDefinition.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/DuringEvaluatorDefinition.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -149,6 +149,24 @@
final String operatorId,
final boolean isNegated,
final String parameterText) {
+ return this.getEvaluator( type,
+ operatorId,
+ isNegated,
+ parameterText,
+ Target.HANDLE,
+ Target.HANDLE );
+
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Evaluator getEvaluator(final ValueType type,
+ final String operatorId,
+ final boolean isNegated,
+ final String parameterText,
+ final Target left,
+ final Target right ) {
if ( this.cache == Collections.EMPTY_MAP ) {
this.cache = new HashMap<String, DuringEvaluator>();
}
@@ -183,8 +201,8 @@
/**
* @inheritDoc
*/
- public boolean operatesOnFactHandles() {
- return true;
+ public Target getTarget() {
+ return Target.HANDLE;
}
/**
@@ -239,7 +257,7 @@
}
@Override
- public Object prepareObject(InternalFactHandle handle) {
+ public Object prepareLeftObject(InternalFactHandle handle) {
return handle;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/EqualityEvaluatorsDefinition.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/EqualityEvaluatorsDefinition.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/EqualityEvaluatorsDefinition.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -129,6 +129,24 @@
final String operatorId,
final boolean isNegated,
final String parameterText) {
+ return this.getEvaluator( type,
+ operatorId,
+ isNegated,
+ parameterText,
+ Target.FACT,
+ Target.FACT );
+
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Evaluator getEvaluator(final ValueType type,
+ final String operatorId,
+ final boolean isNegated,
+ final String parameterText,
+ final Target left,
+ final Target right ) {
return this.evaluators.getEvaluator( type, Operator.determineOperator( operatorId, isNegated ) );
}
@@ -140,8 +158,8 @@
return false;
}
- public boolean operatesOnFactHandles() {
- return false;
+ public Target getTarget() {
+ return Target.FACT;
}
public boolean supportsType(ValueType type) {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorDefinition.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorDefinition.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/EvaluatorDefinition.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -26,7 +26,7 @@
* An evaluator definition interface that allows for pluggable
* evaluator implementation.
*
- * This interface is the registry entry point for all available
+ * This interface is the register entry point for all available
* evaluators and describes all evaluator capabilities
*
* @author etirelli
@@ -71,15 +71,24 @@
* @param parameterText some evaluators support parameters and these
* parameters are defined as a String that is
* parsed by the evaluator itself.
+ *
+ * @param leftTarget the target of the evaluator on the Left side,
+ * i.e., on Rete terms, the previous binding or
+ * the actual value on the right side of the operator.
+ *
+ * @param rightTarget the target of the evaluator on the Right side,
+ * i.e., on Rete terms, the current pattern field.
*
* @return an Evaluator instance capable of evaluating expressions
* between values of the given type, or null in case the type
* is not supported.
*/
- public Evaluator getEvaluator(ValueType type,
- String operatorId,
- boolean isNegated,
- String parameterText);
+ public Evaluator getEvaluator(final ValueType type,
+ final String operatorId,
+ final boolean isNegated,
+ final String parameterText,
+ final Target leftTarget,
+ final Target rightTarget );
/**
* Returns the evaluator instance for the given type and the
@@ -91,6 +100,34 @@
* types it is evaluating. It is also possible that
* this evaluator does not support a given type.
*
+ * @param operatorId the string identifier of the evaluator
+ *
+ * @param isNegated true if the evaluator instance to be returned is
+ * the negated version of the evaluator.
+ *
+ * @param parameterText some evaluators support parameters and these
+ * parameters are defined as a String that is
+ * parsed by the evaluator itself.
+ *
+ * @return an Evaluator instance capable of evaluating expressions
+ * between values of the given type, or null in case the type
+ * is not supported.
+ */
+ public Evaluator getEvaluator(final ValueType type,
+ final String operatorId,
+ final boolean isNegated,
+ final String parameterText );
+
+ /**
+ * Returns the evaluator instance for the given type and the
+ * defined parameterText
+ *
+ * @param type the type of the attributes this evaluator will
+ * operate on. This is important because the evaluator
+ * may do optimisations and type coercion based on the
+ * types it is evaluating. It is also possible that
+ * this evaluator does not support a given type.
+ *
* @param operator the operator implemented by the evaluator
*
* @param parameterText some evaluators support parameters and these
@@ -134,12 +171,21 @@
public boolean supportsType(ValueType type);
/**
- * There are evaluators that operate on *fact handle* attributes and
- * evaluators that operate on *fact* attributes.
+ * There are evaluators that operate on *fact* attributes,
+ * evaluators that operate on *fact handle* attributes, and
+ * evaluators that operate on both. This method returns
+ * the target of the current evaluator.
*
* @return true if this evaluator operates on fact handle attributes
* and false if it operates on fact attributes
*/
- public boolean operatesOnFactHandles();
+ public Target getTarget();
+
+ /**
+ * An enum for the target of the evaluator
+ */
+ public static enum Target {
+ FACT, HANDLE, BOTH;
+ }
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/FinishedByEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/FinishedByEvaluatorDefinition.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/FinishedByEvaluatorDefinition.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -128,6 +128,24 @@
final String operatorId,
final boolean isNegated,
final String parameterText) {
+ return this.getEvaluator( type,
+ operatorId,
+ isNegated,
+ parameterText,
+ Target.HANDLE,
+ Target.HANDLE );
+
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Evaluator getEvaluator(final ValueType type,
+ final String operatorId,
+ final boolean isNegated,
+ final String parameterText,
+ final Target left,
+ final Target right ) {
if ( this.cache == Collections.EMPTY_MAP ) {
this.cache = new HashMap<String, FinishedByEvaluator>();
}
@@ -162,8 +180,8 @@
/**
* @inheritDoc
*/
- public boolean operatesOnFactHandles() {
- return true;
+ public Target getTarget() {
+ return Target.HANDLE;
}
/**
@@ -211,7 +229,7 @@
}
@Override
- public Object prepareObject(InternalFactHandle handle) {
+ public Object prepareLeftObject(InternalFactHandle handle) {
return handle;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/FinishesEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/FinishesEvaluatorDefinition.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/FinishesEvaluatorDefinition.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -128,6 +128,24 @@
final String operatorId,
final boolean isNegated,
final String parameterText) {
+ return this.getEvaluator( type,
+ operatorId,
+ isNegated,
+ parameterText,
+ Target.HANDLE,
+ Target.HANDLE );
+
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Evaluator getEvaluator(final ValueType type,
+ final String operatorId,
+ final boolean isNegated,
+ final String parameterText,
+ final Target left,
+ final Target right ) {
if ( this.cache == Collections.EMPTY_MAP ) {
this.cache = new HashMap<String, FinishesEvaluator>();
}
@@ -162,8 +180,8 @@
/**
* @inheritDoc
*/
- public boolean operatesOnFactHandles() {
- return true;
+ public Target getTarget() {
+ return Target.HANDLE;
}
/**
@@ -211,7 +229,7 @@
}
@Override
- public Object prepareObject(InternalFactHandle handle) {
+ public Object prepareLeftObject(InternalFactHandle handle) {
return handle;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/IncludesEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/IncludesEvaluatorDefinition.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/IncludesEvaluatorDefinition.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -150,6 +150,24 @@
final String operatorId,
final boolean isNegated,
final String parameterText) {
+ return this.getEvaluator( type,
+ operatorId,
+ isNegated,
+ parameterText,
+ Target.HANDLE,
+ Target.HANDLE );
+
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Evaluator getEvaluator(final ValueType type,
+ final String operatorId,
+ final boolean isNegated,
+ final String parameterText,
+ final Target left,
+ final Target right ) {
if ( this.cache == Collections.EMPTY_MAP ) {
this.cache = new HashMap<String, IncludesEvaluator>();
}
@@ -184,8 +202,8 @@
/**
* @inheritDoc
*/
- public boolean operatesOnFactHandles() {
- return true;
+ public Target getTarget() {
+ return Target.HANDLE;
}
/**
@@ -238,7 +256,7 @@
}
@Override
- public Object prepareObject(InternalFactHandle handle) {
+ public Object prepareLeftObject(InternalFactHandle handle) {
return handle;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/MatchesEvaluatorsDefinition.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/MatchesEvaluatorsDefinition.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/MatchesEvaluatorsDefinition.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -83,6 +83,24 @@
final String operatorId,
final boolean isNegated,
final String parameterText) {
+ return this.getEvaluator( type,
+ operatorId,
+ isNegated,
+ parameterText,
+ Target.FACT,
+ Target.FACT );
+
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Evaluator getEvaluator(final ValueType type,
+ final String operatorId,
+ final boolean isNegated,
+ final String parameterText,
+ final Target left,
+ final Target right ) {
return this.evaluators.getEvaluator( type, Operator.determineOperator( operatorId, isNegated ) );
}
@@ -94,8 +112,8 @@
return true;
}
- public boolean operatesOnFactHandles() {
- return false;
+ public Target getTarget() {
+ return Target.FACT;
}
public boolean supportsType(ValueType type) {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/MeetsEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/MeetsEvaluatorDefinition.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/MeetsEvaluatorDefinition.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -126,6 +126,24 @@
final String operatorId,
final boolean isNegated,
final String parameterText) {
+ return this.getEvaluator( type,
+ operatorId,
+ isNegated,
+ parameterText,
+ Target.HANDLE,
+ Target.HANDLE );
+
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Evaluator getEvaluator(final ValueType type,
+ final String operatorId,
+ final boolean isNegated,
+ final String parameterText,
+ final Target left,
+ final Target right ) {
if ( this.cache == Collections.EMPTY_MAP ) {
this.cache = new HashMap<String, MeetsEvaluator>();
}
@@ -160,8 +178,8 @@
/**
* @inheritDoc
*/
- public boolean operatesOnFactHandles() {
- return true;
+ public Target getTarget() {
+ return Target.HANDLE;
}
/**
@@ -209,7 +227,7 @@
}
@Override
- public Object prepareObject(InternalFactHandle handle) {
+ public Object prepareLeftObject(InternalFactHandle handle) {
return handle;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/MetByEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/MetByEvaluatorDefinition.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/MetByEvaluatorDefinition.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -126,6 +126,24 @@
final String operatorId,
final boolean isNegated,
final String parameterText) {
+ return this.getEvaluator( type,
+ operatorId,
+ isNegated,
+ parameterText,
+ Target.HANDLE,
+ Target.HANDLE );
+
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Evaluator getEvaluator(final ValueType type,
+ final String operatorId,
+ final boolean isNegated,
+ final String parameterText,
+ final Target left,
+ final Target right ) {
if ( this.cache == Collections.EMPTY_MAP ) {
this.cache = new HashMap<String, MetByEvaluator>();
}
@@ -160,8 +178,8 @@
/**
* @inheritDoc
*/
- public boolean operatesOnFactHandles() {
- return true;
+ public Target getTarget() {
+ return Target.HANDLE;
}
/**
@@ -209,7 +227,7 @@
}
@Override
- public Object prepareObject(InternalFactHandle handle) {
+ public Object prepareLeftObject(InternalFactHandle handle) {
return handle;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/OverlappedByEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/OverlappedByEvaluatorDefinition.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/OverlappedByEvaluatorDefinition.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -135,6 +135,24 @@
final String operatorId,
final boolean isNegated,
final String parameterText) {
+ return this.getEvaluator( type,
+ operatorId,
+ isNegated,
+ parameterText,
+ Target.HANDLE,
+ Target.HANDLE );
+
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Evaluator getEvaluator(final ValueType type,
+ final String operatorId,
+ final boolean isNegated,
+ final String parameterText,
+ final Target left,
+ final Target right ) {
if ( this.cache == Collections.EMPTY_MAP ) {
this.cache = new HashMap<String, OverlappedByEvaluator>();
}
@@ -169,8 +187,8 @@
/**
* @inheritDoc
*/
- public boolean operatesOnFactHandles() {
- return true;
+ public Target getTarget() {
+ return Target.HANDLE;
}
/**
@@ -219,7 +237,7 @@
}
@Override
- public Object prepareObject(InternalFactHandle handle) {
+ public Object prepareLeftObject(InternalFactHandle handle) {
return handle;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/OverlapsEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/OverlapsEvaluatorDefinition.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/OverlapsEvaluatorDefinition.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -136,6 +136,24 @@
final String operatorId,
final boolean isNegated,
final String parameterText) {
+ return this.getEvaluator( type,
+ operatorId,
+ isNegated,
+ parameterText,
+ Target.HANDLE,
+ Target.HANDLE );
+
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Evaluator getEvaluator(final ValueType type,
+ final String operatorId,
+ final boolean isNegated,
+ final String parameterText,
+ final Target left,
+ final Target right ) {
if ( this.cache == Collections.EMPTY_MAP ) {
this.cache = new HashMap<String, OverlapsEvaluator>();
}
@@ -170,8 +188,8 @@
/**
* @inheritDoc
*/
- public boolean operatesOnFactHandles() {
- return true;
+ public Target getTarget() {
+ return Target.HANDLE;
}
/**
@@ -221,7 +239,7 @@
}
@Override
- public Object prepareObject(InternalFactHandle handle) {
+ public Object prepareLeftObject(InternalFactHandle handle) {
return handle;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/SetEvaluatorsDefinition.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/SetEvaluatorsDefinition.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/SetEvaluatorsDefinition.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -249,6 +249,24 @@
final String operatorId,
final boolean isNegated,
final String parameterText) {
+ return this.getEvaluator( type,
+ operatorId,
+ isNegated,
+ parameterText,
+ Target.FACT,
+ Target.FACT );
+
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Evaluator getEvaluator(final ValueType type,
+ final String operatorId,
+ final boolean isNegated,
+ final String parameterText,
+ final Target left,
+ final Target right ) {
return this.evaluators.getEvaluator( type,
Operator.determineOperator( operatorId,
isNegated ) );
@@ -262,8 +280,8 @@
return true;
}
- public boolean operatesOnFactHandles() {
- return false;
+ public Target getTarget() {
+ return Target.FACT;
}
public boolean supportsType(ValueType type) {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/SoundslikeEvaluatorsDefinition.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/SoundslikeEvaluatorsDefinition.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/SoundslikeEvaluatorsDefinition.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -83,6 +83,24 @@
final String operatorId,
final boolean isNegated,
final String parameterText) {
+ return this.getEvaluator( type,
+ operatorId,
+ isNegated,
+ parameterText,
+ Target.FACT,
+ Target.FACT );
+
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Evaluator getEvaluator(final ValueType type,
+ final String operatorId,
+ final boolean isNegated,
+ final String parameterText,
+ final Target left,
+ final Target right ) {
return this.evaluators.getEvaluator( type,
Operator.determineOperator( operatorId,
isNegated ) );
@@ -96,8 +114,8 @@
return true;
}
- public boolean operatesOnFactHandles() {
- return false;
+ public Target getTarget() {
+ return Target.FACT;
}
public boolean supportsType(ValueType type) {
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/StartedByEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/StartedByEvaluatorDefinition.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/StartedByEvaluatorDefinition.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -127,6 +127,24 @@
final String operatorId,
final boolean isNegated,
final String parameterText) {
+ return this.getEvaluator( type,
+ operatorId,
+ isNegated,
+ parameterText,
+ Target.HANDLE,
+ Target.HANDLE );
+
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Evaluator getEvaluator(final ValueType type,
+ final String operatorId,
+ final boolean isNegated,
+ final String parameterText,
+ final Target left,
+ final Target right ) {
if ( this.cache == Collections.EMPTY_MAP ) {
this.cache = new HashMap<String, StartedByEvaluator>();
}
@@ -161,8 +179,8 @@
/**
* @inheritDoc
*/
- public boolean operatesOnFactHandles() {
- return true;
+ public Target getTarget() {
+ return Target.HANDLE;
}
/**
@@ -209,7 +227,7 @@
}
@Override
- public Object prepareObject(InternalFactHandle handle) {
+ public Object prepareLeftObject(InternalFactHandle handle) {
return handle;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/StartsEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/StartsEvaluatorDefinition.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/StartsEvaluatorDefinition.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -128,6 +128,24 @@
final String operatorId,
final boolean isNegated,
final String parameterText) {
+ return this.getEvaluator( type,
+ operatorId,
+ isNegated,
+ parameterText,
+ Target.HANDLE,
+ Target.HANDLE );
+
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Evaluator getEvaluator(final ValueType type,
+ final String operatorId,
+ final boolean isNegated,
+ final String parameterText,
+ final Target left,
+ final Target right ) {
if ( this.cache == Collections.EMPTY_MAP ) {
this.cache = new HashMap<String, StartsEvaluator>();
}
@@ -162,8 +180,8 @@
/**
* @inheritDoc
*/
- public boolean operatesOnFactHandles() {
- return true;
+ public Target getTarget() {
+ return Target.HANDLE;
}
/**
@@ -211,7 +229,7 @@
}
@Override
- public Object prepareObject(InternalFactHandle handle) {
+ public Object prepareLeftObject(InternalFactHandle handle) {
return handle;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseObjectClassFieldReader.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseObjectClassFieldReader.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/BaseObjectClassFieldReader.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -17,25 +17,28 @@
}
protected BaseObjectClassFieldReader(final int index,
- final Class fieldType,
- final ValueType valueType) {
+ final Class< ? > fieldType,
+ final ValueType valueType) {
super( index,
fieldType,
valueType );
}
- public BaseObjectClassFieldReader(final Class clazz,
- final String fieldName) {
+ public BaseObjectClassFieldReader(final Class< ? > clazz,
+ final String fieldName) {
super( clazz,
fieldName );
}
- public abstract Object getValue(InternalWorkingMemory workingMemory, Object object);
+ public abstract Object getValue(InternalWorkingMemory workingMemory,
+ Object object);
- public boolean getBooleanValue(InternalWorkingMemory workingMemory, final Object object) {
+ public boolean getBooleanValue(InternalWorkingMemory workingMemory,
+ final Object object) {
// this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
- final Object value = getValue( workingMemory, object );
+ final Object value = getValue( workingMemory,
+ object );
if ( value instanceof Boolean ) {
return ((Boolean) value).booleanValue();
@@ -43,102 +46,118 @@
throw new RuntimeDroolsException( "Conversion to boolean not supported from " + value.getClass().getName() );
}
- public byte getByteValue(InternalWorkingMemory workingMemory, final Object object) {
+ public byte getByteValue(InternalWorkingMemory workingMemory,
+ final Object object) {
// this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
- final Object value = getValue( workingMemory, object );
+ final Object value = getValue( workingMemory,
+ object );
if ( value instanceof Number ) {
return ((Number) value).byteValue();
- } else if( value instanceof Date ) {
+ } else if ( value instanceof Date ) {
return (byte) ((Date) value).getTime();
}
throw new RuntimeDroolsException( "Conversion to byte not supported from " + value.getClass().getName() );
}
- public char getCharValue(InternalWorkingMemory workingMemory, final Object object) {
+ public char getCharValue(InternalWorkingMemory workingMemory,
+ final Object object) {
// this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
- final Object value = getValue( workingMemory, object );
+ final Object value = getValue( workingMemory,
+ object );
if ( value instanceof Character ) {
return ((Character) value).charValue();
- } else if( value instanceof String && ((String)value).length() == 1 ) {
- return ((String)value).charAt( 0 );
+ } else if ( value instanceof String && ((String) value).length() == 1 ) {
+ return ((String) value).charAt( 0 );
}
throw new RuntimeDroolsException( "Conversion to char not supported from " + value.getClass().getName() );
}
- public double getDoubleValue(InternalWorkingMemory workingMemory, final Object object) {
+ public double getDoubleValue(InternalWorkingMemory workingMemory,
+ final Object object) {
// this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
- final Object value = getValue( workingMemory, object );
+ final Object value = getValue( workingMemory,
+ object );
if ( value instanceof Number ) {
return ((Number) value).doubleValue();
- } else if( value instanceof Date ) {
+ } else if ( value instanceof Date ) {
return (double) ((Date) value).getTime();
}
throw new RuntimeDroolsException( "Conversion to double not supported from " + value.getClass().getName() );
}
- public float getFloatValue(InternalWorkingMemory workingMemory, final Object object) {
+ public float getFloatValue(InternalWorkingMemory workingMemory,
+ final Object object) {
// this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
- final Object value = getValue( workingMemory, object );
+ final Object value = getValue( workingMemory,
+ object );
if ( value instanceof Number ) {
return ((Number) value).floatValue();
- } else if( value instanceof Date ) {
+ } else if ( value instanceof Date ) {
return (float) ((Date) value).getTime();
}
throw new RuntimeDroolsException( "Conversion to float not supported from " + value.getClass().getName() );
}
- public int getIntValue(InternalWorkingMemory workingMemory, final Object object) {
+ public int getIntValue(InternalWorkingMemory workingMemory,
+ final Object object) {
// this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
- final Object value = getValue( workingMemory, object );
+ final Object value = getValue( workingMemory,
+ object );
if ( value instanceof Number ) {
return ((Number) value).intValue();
- } else if( value instanceof Date ) {
+ } else if ( value instanceof Date ) {
return (int) ((Date) value).getTime();
}
throw new RuntimeDroolsException( "Conversion to int not supported from " + value.getClass().getName() );
}
- public long getLongValue(InternalWorkingMemory workingMemory, final Object object) {
+ public long getLongValue(InternalWorkingMemory workingMemory,
+ final Object object) {
// this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
- final Object value = getValue( workingMemory, object );
+ final Object value = getValue( workingMemory,
+ object );
if ( value instanceof Number ) {
return ((Number) value).longValue();
- } else if( value instanceof Date ) {
+ } else if ( value instanceof Date ) {
return ((Date) value).getTime();
}
throw new RuntimeDroolsException( "Conversion to long not supported from " + value.getClass().getName() );
}
- public short getShortValue(InternalWorkingMemory workingMemory, final Object object) {
+ public short getShortValue(InternalWorkingMemory workingMemory,
+ final Object object) {
// this can be improved by generating specific
// bytecode generation in the subclass, avoiding the if instanceof
- final Object value = getValue( workingMemory, object );
+ final Object value = getValue( workingMemory,
+ object );
if ( value instanceof Number ) {
return ((Number) value).shortValue();
- } else if( value instanceof Date ) {
+ } else if ( value instanceof Date ) {
return (short) ((Date) value).getTime();
}
throw new RuntimeDroolsException( "Conversion to short not supported from " + value.getClass().getName() );
}
- public boolean isNullValue(InternalWorkingMemory workingMemory, final Object object) {
- if (object == null) {
+ public boolean isNullValue(InternalWorkingMemory workingMemory,
+ final Object object) {
+ if ( object == null ) {
return true;
} else {
- return getValue( workingMemory, object ) == null;
+ return getValue( workingMemory,
+ object ) == null;
}
}
@@ -152,8 +171,10 @@
}
}
- public int getHashCode(InternalWorkingMemory workingMemory, final Object object) {
- final Object value = getValue( workingMemory, object );
+ public int getHashCode(InternalWorkingMemory workingMemory,
+ final Object object) {
+ final Object value = getValue( workingMemory,
+ object );
return (value != null) ? value.hashCode() : 0;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/SelfReferenceClassFieldReader.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/SelfReferenceClassFieldReader.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/extractors/SelfReferenceClassFieldReader.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -28,8 +28,8 @@
private static final long serialVersionUID = 400L;
- public SelfReferenceClassFieldReader(final Class clazz,
- final String fieldName) {
+ public SelfReferenceClassFieldReader(final Class<?> clazz,
+ final String fieldName) {
super( -1, // index
clazz, // fieldType
ValueType.determineValueType( clazz ) ); // value type
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/VariableRestriction.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/VariableRestriction.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/VariableRestriction.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -99,23 +99,23 @@
final ContextEntry context ) {
return this.evaluator.evaluate( workingMemory,
this.readAccessor,
- this.evaluator.prepareObject( handle ),
+ this.evaluator.prepareLeftObject( handle ),
this.declaration.getExtractor(),
- this.evaluator.prepareObject( handle ) );
+ this.evaluator.prepareLeftObject( handle ) );
}
public boolean isAllowedCachedLeft(final ContextEntry context,
final InternalFactHandle handle) {
return this.evaluator.evaluateCachedLeft( ((VariableContextEntry) context).workingMemory,
(VariableContextEntry) context,
- this.evaluator.prepareObject( handle ) );
+ this.evaluator.prepareLeftObject( handle ) );
}
public boolean isAllowedCachedRight(final LeftTuple tuple,
final ContextEntry context) {
return this.evaluator.evaluateCachedRight( ((VariableContextEntry) context).workingMemory,
(VariableContextEntry) context,
- this.evaluator.prepareObject( tuple.get( this.declaration ) ) );
+ this.evaluator.prepareLeftObject( tuple.get( this.declaration ) ) );
}
public boolean isTemporal() {
@@ -318,19 +318,19 @@
this.reteTuple = tuple;
this.workingMemory = workingMemory;
this.leftNull = this.declaration.getExtractor().isNullValue( workingMemory,
- evaluator.prepareObject( tuple.get( this.declaration ) ) );
+ evaluator.prepareLeftObject( tuple.get( this.declaration ) ) );
this.left = this.declaration.getExtractor().getValue( workingMemory,
- evaluator.prepareObject( tuple.get( this.declaration ) ) );
+ evaluator.prepareLeftObject( tuple.get( this.declaration ) ) );
}
public void updateFromFactHandle(final InternalWorkingMemory workingMemory,
final InternalFactHandle handle) {
- this.object = evaluator.prepareObject( handle );
+ this.object = evaluator.prepareLeftObject( handle );
this.workingMemory = workingMemory;
this.rightNull = this.extractor.isNullValue( workingMemory,
- evaluator.prepareObject( handle ) );
+ evaluator.prepareLeftObject( handle ) );
this.right = this.extractor.getValue( workingMemory,
- evaluator.prepareObject( handle ) );
+ evaluator.prepareLeftObject( handle ) );
}
public void resetTuple() {
@@ -379,11 +379,11 @@
this.reteTuple = tuple;
this.workingMemory = workingMemory;
this.leftNull = this.declaration.getExtractor().isNullValue( workingMemory,
- evaluator.prepareObject( tuple.get( this.declaration ) ) );
+ evaluator.prepareLeftObject( tuple.get( this.declaration ) ) );
if ( !leftNull ) {
this.left = this.declaration.getExtractor().getLongValue( workingMemory,
- evaluator.prepareObject( tuple.get( this.declaration ) ) );
+ evaluator.prepareLeftObject( tuple.get( this.declaration ) ) );
} else {
this.left = 0;
}
@@ -391,14 +391,14 @@
public void updateFromFactHandle(final InternalWorkingMemory workingMemory,
final InternalFactHandle handle) {
- this.object = evaluator.prepareObject( handle );
+ this.object = evaluator.prepareLeftObject( handle );
this.workingMemory = workingMemory;
this.rightNull = this.extractor.isNullValue( workingMemory,
- evaluator.prepareObject( handle ) );
+ evaluator.prepareLeftObject( handle ) );
if ( !rightNull ) { // avoid a NullPointerException
this.right = this.extractor.getLongValue( workingMemory,
- evaluator.prepareObject( handle ) );
+ evaluator.prepareLeftObject( handle ) );
} else {
this.right = 0;
}
@@ -440,11 +440,11 @@
this.reteTuple = tuple;
this.workingMemory = workingMemory;
this.leftNull = this.declaration.getExtractor().isNullValue( workingMemory,
- evaluator.prepareObject( tuple.get( this.declaration ) ) );
+ evaluator.prepareLeftObject( tuple.get( this.declaration ) ) );
if ( !leftNull ) {
this.left = this.declaration.getExtractor().getCharValue( workingMemory,
- evaluator.prepareObject( tuple.get( this.declaration ) ) );
+ evaluator.prepareLeftObject( tuple.get( this.declaration ) ) );
} else {
this.left = 0;
}
@@ -452,14 +452,14 @@
public void updateFromFactHandle(final InternalWorkingMemory workingMemory,
final InternalFactHandle handle) {
- this.object = evaluator.prepareObject( handle );
+ this.object = evaluator.prepareLeftObject( handle );
this.workingMemory = workingMemory;
this.rightNull = this.extractor.isNullValue( workingMemory,
- evaluator.prepareObject( handle ) );
+ evaluator.prepareLeftObject( handle ) );
if ( !rightNull ) { // avoid a NullPointerException
this.right = this.extractor.getCharValue( workingMemory,
- evaluator.prepareObject( handle ) );
+ evaluator.prepareLeftObject( handle ) );
} else {
this.right = 0;
}
@@ -501,11 +501,11 @@
this.reteTuple = tuple;
this.workingMemory = workingMemory;
this.leftNull = this.declaration.getExtractor().isNullValue( workingMemory,
- evaluator.prepareObject( tuple.get( this.declaration ) ) );
+ evaluator.prepareLeftObject( tuple.get( this.declaration ) ) );
if ( !leftNull ) {
this.left = this.declaration.getExtractor().getDoubleValue( workingMemory,
- evaluator.prepareObject( tuple.get( this.declaration ) ) );
+ evaluator.prepareLeftObject( tuple.get( this.declaration ) ) );
} else {
this.left = 0;
}
@@ -513,14 +513,14 @@
public void updateFromFactHandle(final InternalWorkingMemory workingMemory,
final InternalFactHandle handle) {
- this.object = evaluator.prepareObject( handle );
+ this.object = evaluator.prepareLeftObject( handle );
this.workingMemory = workingMemory;
this.rightNull = this.extractor.isNullValue( workingMemory,
- evaluator.prepareObject( handle ) );
+ evaluator.prepareLeftObject( handle ) );
if ( !rightNull ) { // avoid a NullPointerException
this.right = this.extractor.getDoubleValue( workingMemory,
- evaluator.prepareObject( handle ) );
+ evaluator.prepareLeftObject( handle ) );
} else {
this.right = 0;
}
@@ -561,11 +561,11 @@
this.reteTuple = tuple;
this.workingMemory = workingMemory;
this.leftNull = this.declaration.getExtractor().isNullValue( workingMemory,
- evaluator.prepareObject( tuple.get( this.declaration ) ) );
+ evaluator.prepareLeftObject( tuple.get( this.declaration ) ) );
if ( !leftNull ) {
this.left = this.declaration.getExtractor().getBooleanValue( workingMemory,
- evaluator.prepareObject( tuple.get( this.declaration ) ) );
+ evaluator.prepareLeftObject( tuple.get( this.declaration ) ) );
} else {
this.left = false;
}
@@ -573,14 +573,14 @@
public void updateFromFactHandle(final InternalWorkingMemory workingMemory,
final InternalFactHandle handle) {
- this.object = evaluator.prepareObject( handle );
+ this.object = evaluator.prepareLeftObject( handle );
this.workingMemory = workingMemory;
this.rightNull = this.extractor.isNullValue( workingMemory,
- evaluator.prepareObject( handle ) );
+ evaluator.prepareLeftObject( handle ) );
if ( !rightNull ) { // avoid a NullPointerException
this.right = this.extractor.getBooleanValue( workingMemory,
- evaluator.prepareObject( handle ) );
+ evaluator.prepareLeftObject( handle ) );
} else {
this.right = false;
}
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Evaluator.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Evaluator.java 2008-12-15 04:45:46 UTC (rev 24376)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/spi/Evaluator.java 2008-12-15 05:10:01 UTC (rev 24377)
@@ -58,19 +58,46 @@
public ValueType getCoercedValueType();
/**
- * There are evaluators that operate on fact attributes and
+ * There are evaluators that operate on fact attributes,
* there are evaluators that operate on fact handle attributes
- * (metadata).
+ * (metadata), and there are evaluators that can operate in
+ * either one.
*
- * This method allows the evaluator to prepare the object
- * to be evaluated. That includes, unwrapping the object if needed.
+ * This method allows the evaluator to prepare the left object
+ * for evaluation. That includes, unwrapping the object from the
+ * handle, if necessary.
+ *
+ * It is important to note that the concept of left and right
+ * is based on the Rete notion of left and right, where right
+ * corresponds to the current pattern, while left is a binding
+ * to a previous pattern.
*
* @param handle
* @return
*/
- public Object prepareObject( InternalFactHandle handle );
+ public Object prepareLeftObject( InternalFactHandle handle );
/**
+ * There are evaluators that operate on fact attributes,
+ * there are evaluators that operate on fact handle attributes
+ * (metadata), and there are evaluators that can operate in
+ * either one.
+ *
+ * This method allows the evaluator to prepare the right object
+ * for evaluation. That includes, unwrapping the object from the
+ * handle, if necessary.
+ *
+ * It is important to note that the concept of left and right
+ * is based on the Rete notion of left and right, where right
+ * corresponds to the current pattern, while left is a binding
+ * to a previous pattern.
+ *
+ * @param handle
+ * @return
+ */
+ public Object prepareRightObject( InternalFactHandle handle );
+
+ /**
* Evaluates the expression using the provided parameters.
*
* This method is used when evaluating alpha-constraints,
More information about the jboss-svn-commits
mailing list