[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-jel] Data type of compiled expressions
From: |
Mike Squance |
Subject: |
[Bug-jel] Data type of compiled expressions |
Date: |
Wed, 27 Nov 2002 16:34:22 -0800 |
Hi,
First, let me say that I've been extremely happy with JEL and I hope it
continues to be supported.
I'm having a bit of trouble with the data type of expressions that I suspect
is a limitation of the software, but I thought I'd ask anyways.
I rely on the getType() result to validate whether an expression has been
entered correctly with respect to the data type that the expression is
supposed to be producing. For example:
There are 2 measurements defined:
RAW1 of type Integer
RAW2 of type Integer
A derived measurement is defined:
DERIVED1 of type Integer
An expression is written to derive DERIVED1 from the available
measurements.
I look at the result of getType() to ensure that the result of the
expression for DERIVED1 is of type Integer.
In general, with expressions like "RAW1 + RAW2", "RAW1 + 10", this works
fine. I get Integer as the resulting data type. However, with an expression
"RAW1" or "(RAW1 > RAW2)?(RAW1):(RAW2)", I get Object as the resulting data
type. I know that I can do "RAW1+0" to work around this, but this is not
very desirable.
Here is a bit of code, based on the YourTestBed example. The DVResolver was
updated to support Integer.
resolver.addProperty("RAW1", new Integer( 10 ) );
resolver.addProperty("RAW2",new Integer( 3 ) );
expr=gnu.jel.Evaluator.compile("RAW2",lib);
System.out.println("DATATYPE = " +expr.getType() );
System.out.println("RAW2="+expr.evaluate(context));
expr=gnu.jel.Evaluator.compile("(1>0)?(RAW1):(RAW2)",lib);
System.out.println("DATATYPE = " +expr.getType() );
System.out.println("MYRESULT = " +expr.evaluate(context) );
First, is this a bug? If not, can you suggest a better alternative than the
"+0" approach?
Thanks for any help,
Mike.
- [Bug-jel] Data type of compiled expressions,
Mike Squance <=