* expression to be evaluated
* @return the conduit
*/
private PropertyConduit build(final Class rootClass, String expression)
{
Tree tree = parse(expression);
try
{
switch (tree.getType())
{
case TRUE:
return literalTrue;
case FALSE:
return literalFalse;
case NULL:
return literalNull;
case INTEGER:
// Leading '+' may screw this up.
// TODO: Singleton instance for "0", maybe "1"?
return createLiteralConduit(Long.class, new Long(tree.getText()));
case DECIMAL:
// Leading '+' may screw this up.
// TODO: Singleton instance for "0.0"?
return createLiteralConduit(Double.class, new Double(tree.getText()));
case STRING:
return createLiteralConduit(String.class, tree.getText());
case RANGEOP:
Tree fromNode = tree.getChild(0);
Tree toNode = tree.getChild(1);
// If the range is defined as integers (not properties, etc.)
// then it is possible to calculate the value here, once, and not
// build a new class.
if (fromNode.getType() != INTEGER || toNode.getType() != INTEGER)
break;
int from = Integer.parseInt(fromNode.getText());
int to = Integer.parseInt(toNode.getText());
IntegerRange ir = new IntegerRange(from, to);
return createLiteralConduit(IntegerRange.class, ir);