MathValue now supports constants.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@892704 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -23,11 +23,11 @@ import java.util.List;
|
||||
|
||||
import org.ofbiz.base.util.StringUtil;
|
||||
|
||||
public final class MathValue extends StaticValue implements Iterable<StaticValue> {
|
||||
public final class MathValue extends StaticValue implements Iterable<ConstantValue> {
|
||||
private final String op;
|
||||
private final List<StaticValue> values;
|
||||
private final List<ConstantValue> values;
|
||||
|
||||
public MathValue(String op, List<StaticValue> values) {
|
||||
public MathValue(String op, List<ConstantValue> values) {
|
||||
this.op = op;
|
||||
this.values = values;
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public final class MathValue extends StaticValue implements Iterable<StaticValue
|
||||
return null;
|
||||
}
|
||||
|
||||
public Iterator<StaticValue> iterator() {
|
||||
public Iterator<ConstantValue> iterator() {
|
||||
return values.iterator();
|
||||
}
|
||||
|
||||
|
||||
@@ -557,16 +557,16 @@ private void FieldDef(Map<String, FieldDef> fieldDefs, List<FieldAll> fieldAlls,
|
||||
|
||||
private StaticValue MathValue():
|
||||
{
|
||||
StaticValue v;
|
||||
List<StaticValue> values = FastList.newInstance();
|
||||
ConstantValue v;
|
||||
List<ConstantValue> values = FastList.newInstance();
|
||||
String operator = null, newOperator;
|
||||
}
|
||||
{
|
||||
<OPEN_PAREN>
|
||||
v=StaticValue() { values.add(v); }
|
||||
v=ConstantValue() { values.add(v); }
|
||||
(
|
||||
newOperator=MathOperator()
|
||||
v=StaticValue() {
|
||||
v=ConstantValue() {
|
||||
if (operator == null) {
|
||||
operator = newOperator;
|
||||
} else if (!newOperator.equals(operator)) {
|
||||
@@ -577,7 +577,7 @@ private StaticValue MathValue():
|
||||
)*
|
||||
<CLOSE_PAREN>
|
||||
{
|
||||
if (values.size() == 1) return values.get(0);
|
||||
if (values.size() == 1 && values.get(0) instanceof StaticValue) return (StaticValue) values.get(0);
|
||||
return new MathValue(operator, values);
|
||||
}
|
||||
}
|
||||
@@ -597,16 +597,20 @@ private FunctionCall FunctionCallRest(String name):
|
||||
{ return new FunctionCall(name, args); }
|
||||
}
|
||||
|
||||
private StaticValue StaticValue():
|
||||
private ConstantValue ConstantValue():
|
||||
{
|
||||
String n;
|
||||
StaticValue v;
|
||||
ConstantValue v;
|
||||
int i;
|
||||
String s;
|
||||
}
|
||||
{
|
||||
n=NamePart() (
|
||||
v=FunctionCallRest(n) { return v; }
|
||||
| v=FieldValue(n) { return v; }
|
||||
)
|
||||
| i=Integer() { return new NumberValue<Integer>(i); }
|
||||
| s=SQuoted() { return new StringValue(s); }
|
||||
| v=MathValue() { return v; }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user