svn commit: r892704 - in /ofbiz/trunk/framework: entity/src/org/ofbiz/entity/sql/EntityPlanner.java sql/src/org/ofbiz/sql/MathValue.java sql/src/org/ofbiz/sql/Parser.jj

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r892704 - in /ofbiz/trunk/framework: entity/src/org/ofbiz/entity/sql/EntityPlanner.java sql/src/org/ofbiz/sql/MathValue.java sql/src/org/ofbiz/sql/Parser.jj

doogie-3
Author: doogie
Date: Mon Dec 21 06:04:09 2009
New Revision: 892704

URL: http://svn.apache.org/viewvc?rev=892704&view=rev
Log:
MathValue now supports constants.

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/EntityPlanner.java
    ofbiz/trunk/framework/sql/src/org/ofbiz/sql/MathValue.java
    ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/EntityPlanner.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/EntityPlanner.java?rev=892704&r1=892703&r2=892704&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/EntityPlanner.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/sql/EntityPlanner.java Mon Dec 21 06:04:09 2009
@@ -38,6 +38,7 @@
 import org.ofbiz.sql.BooleanCondition;
 import org.ofbiz.sql.Condition;
 import org.ofbiz.sql.ConditionList;
+import org.ofbiz.sql.ConstantValue;
 import org.ofbiz.sql.FieldAll;
 import org.ofbiz.sql.FieldDef;
 import org.ofbiz.sql.FieldDefFieldValue;
@@ -197,8 +198,8 @@
         } else if (value instanceof MathValue) {
             MathValue mv = (MathValue) value;
             ComplexAlias complexAlias = new ComplexAlias(mv.getOp());
-            for (StaticValue staticValue: mv) {
-                complexAlias.addComplexAliasMember(buildComplexMember(staticValue));
+            for (ConstantValue constantValue: mv) {
+                complexAlias.addComplexAliasMember(buildComplexMember(constantValue));
             }
             return complexAlias;
         }

Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/MathValue.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/MathValue.java?rev=892704&r1=892703&r2=892704&view=diff
==============================================================================
--- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/MathValue.java (original)
+++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/MathValue.java Mon Dec 21 06:04:09 2009
@@ -23,11 +23,11 @@
 
 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 @@
         return null;
     }
 
-    public Iterator<StaticValue> iterator() {
+    public Iterator<ConstantValue> iterator() {
         return values.iterator();
     }
 

Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj?rev=892704&r1=892703&r2=892704&view=diff
==============================================================================
--- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj (original)
+++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj Mon Dec 21 06:04:09 2009
@@ -557,16 +557,16 @@
 
 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 @@
  )*
  <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 @@
  { 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; }
 }