Support MathValue for field definitions.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@892705 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adam Heath
2009-12-21 06:04:47 +00:00
parent c66af181b1
commit be3e008240
3 changed files with 17 additions and 9 deletions
@@ -19,14 +19,14 @@
package org.ofbiz.sql;
public final class FieldDefValue extends FieldDef {
private final StaticValue value;
private final ConstantValue value;
public FieldDefValue(StaticValue value, String alias) {
super(alias == null ? value.getDefaultName() : alias);
public FieldDefValue(ConstantValue value, String alias) {
super(alias == null && value instanceof StaticValue ? ((StaticValue) value).getDefaultName() : alias);
this.value = value;
}
public StaticValue getValue() {
public ConstantValue getValue() {
return value;
}
+12 -4
View File
@@ -418,16 +418,24 @@ private List<SetField> SetField():
}
{
(
n=NamePart() <EQUALS> v=Value() { setFields.add(new SetField(n, v)); }
n=NamePart() <EQUALS> (
v=Value() { setFields.add(new SetField(n, v)); }
| v=MathValue() { setFields.add(new SetField(n, v)); }
)
| <OPEN_PAREN>
n=NamePart() { columnList.add(n); }
( <COMMA> n=NamePart() { columnList.add(n); } )*
<CLOSE_PAREN>
<EQUALS>
<OPEN_PAREN>
v=Value() { valueList.add(v); }
( <COMMA> v=Value() { valueList.add(v); } )*
<CLOSE_PAREN>
(v=Value()|v=MathValue()) { valueList.add(v); }
( <COMMA> (v=Value()|v=MathValue()) { valueList.add(v); } )*
<CLOSE_PAREN> {
if (columnList.size() != valueList.size()) throw new ParseException();
for (int i = 0; i < columnList.size(); i++) {
setFields.add(new SetField(columnList.get(i), valueList.get(i)));
}
}
)
{ return setFields; }
}