Author: doogie
Date: Tue Nov 17 08:24:41 2009 New Revision: 881188 URL: http://svn.apache.org/viewvc?rev=881188&view=rev Log: Make most classes extends Atom, which implements Appender, and toString(). Added: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Atom.java - copied, changed from r881185, ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Value.java Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/BooleanCondition.java ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Condition.java ofbiz/trunk/framework/sql/src/org/ofbiz/sql/ConditionList.java ofbiz/trunk/framework/sql/src/org/ofbiz/sql/FieldAll.java ofbiz/trunk/framework/sql/src/org/ofbiz/sql/FieldDef.java ofbiz/trunk/framework/sql/src/org/ofbiz/sql/InsertRow.java ofbiz/trunk/framework/sql/src/org/ofbiz/sql/InsertValues.java ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Joined.java ofbiz/trunk/framework/sql/src/org/ofbiz/sql/KeyMap.java ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Relation.java ofbiz/trunk/framework/sql/src/org/ofbiz/sql/SQLPlan.java ofbiz/trunk/framework/sql/src/org/ofbiz/sql/SQLStatement.java ofbiz/trunk/framework/sql/src/org/ofbiz/sql/SetField.java ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Table.java ofbiz/trunk/framework/sql/src/org/ofbiz/sql/TableName.java ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Value.java Copied: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Atom.java (from r881185, ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Value.java) URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Atom.java?p2=ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Atom.java&p1=ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Value.java&r1=881185&r2=881188&rev=881188&view=diff ============================================================================== --- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Value.java (original) +++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Atom.java Tue Nov 17 08:24:41 2009 @@ -20,7 +20,7 @@ import org.ofbiz.base.util.Appender; -public abstract class Value implements Appender<StringBuilder> { +public abstract class Atom implements Appender<StringBuilder> { public String toString() { return appendTo(new StringBuilder()).toString(); } Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/BooleanCondition.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/BooleanCondition.java?rev=881188&r1=881187&r2=881188&view=diff ============================================================================== --- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/BooleanCondition.java (original) +++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/BooleanCondition.java Tue Nov 17 08:24:41 2009 @@ -18,7 +18,7 @@ */ package org.ofbiz.sql; -public final class BooleanCondition implements Condition { +public final class BooleanCondition extends Condition { private final Value left; private final String op; private final Value right; @@ -41,10 +41,6 @@ return right; } - public String toString() { - return appendTo(new StringBuilder()).toString(); - } - public StringBuilder appendTo(StringBuilder sb) { left.appendTo(sb); sb.append(' ').append(op).append(' '); Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Condition.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Condition.java?rev=881188&r1=881187&r2=881188&view=diff ============================================================================== --- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Condition.java (original) +++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Condition.java Tue Nov 17 08:24:41 2009 @@ -18,7 +18,5 @@ */ package org.ofbiz.sql; -import org.ofbiz.base.util.Appender; - -public interface Condition extends Appender<StringBuilder> { +public abstract class Condition extends Atom { } Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/ConditionList.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/ConditionList.java?rev=881188&r1=881187&r2=881188&view=diff ============================================================================== --- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/ConditionList.java (original) +++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/ConditionList.java Tue Nov 17 08:24:41 2009 @@ -23,7 +23,7 @@ import org.ofbiz.base.util.StringUtil; -public final class ConditionList implements Condition, Iterable<Condition> { +public final class ConditionList extends Condition implements Iterable<Condition> { private final Joiner joiner; private final List<Condition> conditions; Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/FieldAll.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/FieldAll.java?rev=881188&r1=881187&r2=881188&view=diff ============================================================================== --- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/FieldAll.java (original) +++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/FieldAll.java Tue Nov 17 08:24:41 2009 @@ -21,10 +21,9 @@ import java.util.Iterator; import java.util.List; -import org.ofbiz.base.util.Appender; import org.ofbiz.base.util.StringUtil; -public final class FieldAll implements Appender<StringBuilder>, Iterable<String> { +public final class FieldAll extends Atom implements Iterable<String> { private final String alias; private final List<String> exclude; 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=881188&r1=881187&r2=881188&view=diff ============================================================================== --- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/FieldDef.java (original) +++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/FieldDef.java Tue Nov 17 08:24:41 2009 @@ -18,9 +18,7 @@ */ package org.ofbiz.sql; -import org.ofbiz.base.util.Appender; - -public abstract class FieldDef implements Appender<StringBuilder> { +public abstract class FieldDef extends Atom { protected final String alias; protected FieldDef(String alias) { @@ -30,8 +28,4 @@ public final String getAlias() { return alias; } - - public String toString() { - return appendTo(new StringBuilder()).toString(); - } } Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/InsertRow.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/InsertRow.java?rev=881188&r1=881187&r2=881188&view=diff ============================================================================== --- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/InsertRow.java (original) +++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/InsertRow.java Tue Nov 17 08:24:41 2009 @@ -21,10 +21,9 @@ import java.util.Iterator; import java.util.List; -import org.ofbiz.base.util.Appender; import org.ofbiz.base.util.StringUtil; -public final class InsertRow implements Appender<StringBuilder>, Iterable<Value> { +public final class InsertRow extends Atom implements Iterable<Value> { private final List<Value> values; public InsertRow(List<Value> values) { Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/InsertValues.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/InsertValues.java?rev=881188&r1=881187&r2=881188&view=diff ============================================================================== --- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/InsertValues.java (original) +++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/InsertValues.java Tue Nov 17 08:24:41 2009 @@ -23,7 +23,7 @@ import org.ofbiz.base.util.StringUtil; -public final class InsertValues implements InsertSource, Iterable<InsertRow> { +public final class InsertValues extends Atom implements InsertSource, Iterable<InsertRow> { private final List<InsertRow> rows; public InsertValues(List<InsertRow> rows) { Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Joined.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Joined.java?rev=881188&r1=881187&r2=881188&view=diff ============================================================================== --- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Joined.java (original) +++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Joined.java Tue Nov 17 08:24:41 2009 @@ -21,7 +21,7 @@ import java.util.Iterator; import java.util.List; -public final class Joined implements Iterable<KeyMap> { +public final class Joined extends Atom implements Iterable<KeyMap> { private final boolean isOptional; private final TableName tableName; private final List<KeyMap> keyMaps; @@ -54,6 +54,10 @@ return joined; } + public StringBuilder appendTo(StringBuilder sb) { + return appendTo("left", sb); + } + public StringBuilder appendTo(String leftAlias, StringBuilder sb) { sb.append(isOptional ? " LEFT JOIN " : " JOIN "); return appendToRest(leftAlias, sb); Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/KeyMap.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/KeyMap.java?rev=881188&r1=881187&r2=881188&view=diff ============================================================================== --- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/KeyMap.java (original) +++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/KeyMap.java Tue Nov 17 08:24:41 2009 @@ -18,7 +18,7 @@ */ package org.ofbiz.sql; -public final class KeyMap { +public final class KeyMap extends Atom { private final String leftFieldName; private final String rightFieldName; @@ -35,6 +35,10 @@ return rightFieldName; } + public StringBuilder appendTo(StringBuilder sb) { + return appendTo("left", "right", sb); + } + public StringBuilder appendTo(String leftAlias, String rightAlias, StringBuilder sb) { sb.append(leftAlias).append('.').append(leftFieldName); sb.append(" = "); Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Relation.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Relation.java?rev=881188&r1=881187&r2=881188&view=diff ============================================================================== --- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Relation.java (original) +++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Relation.java Tue Nov 17 08:24:41 2009 @@ -21,9 +21,7 @@ import java.util.Iterator; import java.util.List; -import org.ofbiz.base.util.Appender; - -public final class Relation implements Appender<StringBuilder>, Iterable<KeyMap> { +public final class Relation extends Atom implements Iterable<KeyMap> { private final String type; private final String title; private final String entityName; Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/SQLPlan.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/SQLPlan.java?rev=881188&r1=881187&r2=881188&view=diff ============================================================================== --- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/SQLPlan.java (original) +++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/SQLPlan.java Tue Nov 17 08:24:41 2009 @@ -18,5 +18,8 @@ */ package org.ofbiz.sql; -public abstract class SQLPlan<P extends SQLPlan<P>> { +public abstract class SQLPlan<P extends SQLPlan<P>> extends Atom { + public StringBuilder appendTo(StringBuilder sb) { + return sb.append("SQLPlan[").append(getClass().getName()).append("]"); + } } Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/SQLStatement.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/SQLStatement.java?rev=881188&r1=881187&r2=881188&view=diff ============================================================================== --- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/SQLStatement.java (original) +++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/SQLStatement.java Tue Nov 17 08:24:41 2009 @@ -18,12 +18,6 @@ */ package org.ofbiz.sql; -import org.ofbiz.base.util.Appender; - -public abstract class SQLStatement<S extends SQLStatement<S, P>, P extends SQLPlan<P>> implements Appender<StringBuilder> { +public abstract class SQLStatement<S extends SQLStatement<S, P>, P extends SQLPlan<P>> extends Atom { public abstract <PP extends P> PP plan(Planner<?, ?, ?, ?, ?, ?> planner); - - public String toString() { - return appendTo(new StringBuilder()).toString(); - } } Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/SetField.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/SetField.java?rev=881188&r1=881187&r2=881188&view=diff ============================================================================== --- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/SetField.java (original) +++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/SetField.java Tue Nov 17 08:24:41 2009 @@ -18,9 +18,7 @@ */ package org.ofbiz.sql; -import org.ofbiz.base.util.Appender; - -public final class SetField implements Appender<StringBuilder> { +public final class SetField extends Atom { private final String name; private final Value value; Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Table.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Table.java?rev=881188&r1=881187&r2=881188&view=diff ============================================================================== --- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Table.java (original) +++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Table.java Tue Nov 17 08:24:41 2009 @@ -18,9 +18,7 @@ */ package org.ofbiz.sql; -import org.ofbiz.base.util.Appender; - -public final class Table implements Appender<StringBuilder> { +public final class Table extends Atom { private final TableName tableName; private final Joined joined; @@ -41,10 +39,6 @@ return joined; } - public String toString() { - return appendTo(new StringBuilder()).toString(); - } - public StringBuilder appendTo(StringBuilder sb) { tableName.appendTo(sb); if (joined != null) { Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/TableName.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/TableName.java?rev=881188&r1=881187&r2=881188&view=diff ============================================================================== --- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/TableName.java (original) +++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/TableName.java Tue Nov 17 08:24:41 2009 @@ -18,9 +18,7 @@ */ package org.ofbiz.sql; -import org.ofbiz.base.util.Appender; - -public final class TableName implements Appender<StringBuilder> { +public final class TableName extends Atom { private final String tableName; private final String alias; @@ -37,10 +35,6 @@ return alias; } - public String toString() { - return appendTo(new StringBuilder()).toString(); - } - public StringBuilder appendTo(StringBuilder sb) { sb.append(tableName); if (!alias.equals(tableName)) { Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Value.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Value.java?rev=881188&r1=881187&r2=881188&view=diff ============================================================================== --- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Value.java (original) +++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/Value.java Tue Nov 17 08:24:41 2009 @@ -18,10 +18,5 @@ */ package org.ofbiz.sql; -import org.ofbiz.base.util.Appender; - -public abstract class Value implements Appender<StringBuilder> { - public String toString() { - return appendTo(new StringBuilder()).toString(); - } +public abstract class Value extends Atom { } |
Free forum by Nabble | Edit this page |