svn commit: r981618 - in /ofbiz/trunk/framework/sql/src/org/ofbiz/sql: FieldDef.java 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: r981618 - in /ofbiz/trunk/framework/sql/src/org/ofbiz/sql: FieldDef.java Parser.jj

doogie-3
Author: doogie
Date: Mon Aug  2 17:42:06 2010
New Revision: 981618

URL: http://svn.apache.org/viewvc?rev=981618&view=rev
Log:
Introduce a new method, getDefaultName(), so that null alias logic
doesn't happen in the constructor.

Modified:
    ofbiz/trunk/framework/sql/src/org/ofbiz/sql/FieldDef.java
    ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj

Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/FieldDef.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/FieldDef.java?rev=981618&r1=981617&r2=981618&view=diff
==============================================================================
--- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/FieldDef.java (original)
+++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/FieldDef.java Mon Aug  2 17:42:06 2010
@@ -23,7 +23,7 @@ public final class FieldDef extends Atom
     private final StaticValue value;
 
     public FieldDef(StaticValue value, String alias) {
-        this.alias = alias == null ? value.getDefaultName() : alias;
+        this.alias = alias;
         this.value = value;
     }
 
@@ -31,6 +31,10 @@ public final class FieldDef extends Atom
         return alias;
     }
 
+    public String getDefaultName() {
+        return alias == null ? value.getDefaultName() : alias;
+    }
+
     public StaticValue getValue() {
         return value;
     }
@@ -38,7 +42,7 @@ public final class FieldDef extends Atom
     public boolean equals(Object o) {
         if (o instanceof FieldDef) {
             FieldDef other = (FieldDef) o;
-            return alias.equals(other.alias) && value.equals(other.value);
+            return equalsHelper(alias, other.alias) && value.equals(other.value);
         } else {
             return false;
         }
@@ -46,7 +50,7 @@ public final class FieldDef extends Atom
 
     public StringBuilder appendTo(StringBuilder sb) {
         value.appendTo(sb);
-        if (!equalsHelper(value.getDefaultName(), alias)) {
+        if (alias != null) {
             sb.append(" AS ").append(alias);
         }
         return sb;

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=981618&r1=981617&r2=981618&view=diff
==============================================================================
--- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj (original)
+++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Parser.jj Mon Aug  2 17:42:06 2010
@@ -513,8 +513,8 @@ private void SelectField(Map<String, Fie
         fieldAlls.add(fieldAll); return;
       }
     | fieldDef=FieldDef() {
-        if (fieldDefs.containsKey(fieldDef.getAlias())) throw new ParseException("duplicate alias(" + fieldDef.getAlias() + ")");
-        fieldDefs.put(fieldDef.getAlias(), fieldDef);
+        if (fieldDefs.containsKey(fieldDef.getDefaultName())) throw new ParseException("duplicate alias(" + fieldDef.getDefaultName() + ")");
+        fieldDefs.put(fieldDef.getDefaultName(), fieldDef);
     }
 }