1 21 package oracle.toplink.essentials.internal.expressions; 23 24 import java.io.*; 25 import oracle.toplink.essentials.internal.helper.*; 26 import oracle.toplink.essentials.internal.sessions.DatabaseSessionImpl; 27 import oracle.toplink.essentials.expressions.*; 28 import oracle.toplink.essentials.internal.databaseaccess.DatabaseCall; 29 import oracle.toplink.essentials.internal.sessions.AbstractRecord; 30 import oracle.toplink.essentials.internal.sessions.AbstractSession; 31 32 41 public abstract class SQLStatement implements Serializable, Cloneable { 42 protected Expression whereClause; 43 protected ExpressionBuilder builder; 44 protected AbstractRecord translationRow; 45 46 49 public abstract DatabaseCall buildCall(AbstractSession session); 50 51 54 public Object clone() { 55 try { 56 return super.clone(); 57 } catch (CloneNotSupportedException e) { 58 throw new InternalError (); 59 } 60 } 61 62 public ExpressionBuilder getBuilder() { 63 return builder; 64 } 65 66 public ExpressionBuilder getExpressionBuilder() { 67 return builder; 68 } 69 70 74 public AbstractRecord getTranslationRow() { 75 return translationRow; 76 } 77 78 public Expression getWhereClause() { 79 return whereClause; 80 } 81 82 protected void setBuilder(ExpressionBuilder aBuilder) { 83 builder = aBuilder; 84 } 85 86 90 public void setTranslationRow(AbstractRecord theRow) { 91 translationRow = theRow; 92 } 93 94 public void setWhereClause(Expression expression) { 95 whereClause = expression; 96 if (expression != null) { 97 builder = expression.getBuilder(); 98 } 99 } 100 101 104 public String toString() { 105 StringWriter writer = new StringWriter(); 106 writer.write(Helper.getShortClassName(getClass())); 107 writer.write("("); 108 109 try { 110 DatabaseCall call = buildCall(new DatabaseSessionImpl(new oracle.toplink.essentials.sessions.DatabaseLogin())); 111 writer.write(call.getSQLString()); 112 } catch (Exception exception) { 113 } 114 writer.write(")"); 115 116 return writer.toString(); 117 } 118 } 119 | Popular Tags |