1 package org.apache.ojb.broker.accesslayer.sql; 2 3 17 18 import java.util.ArrayList ; 19 import java.util.List ; 20 21 import org.apache.ojb.broker.util.logging.Logger; 22 23 29 public abstract class SqlMNStatement implements SqlStatement 30 { 31 private String m_table; 32 private String [] m_columns; 33 private Logger m_logger; 34 35 36 39 public SqlMNStatement(String table, String [] columns, Logger logger) 40 { 41 super(); 42 this.m_table = table; 43 this.m_columns = columns; 44 this.m_logger = logger; 45 } 46 47 50 protected void appendTable(String table, StringBuffer stmt) 51 { 52 stmt.append(table); 53 } 54 55 59 protected String [] getColumns() 60 { 61 return m_columns; 62 } 63 64 68 protected String getTable() 69 { 70 return m_table; 71 } 72 73 77 protected Logger getLogger() 78 { 79 return m_logger; 80 } 81 82 87 protected void appendWhereClause(StringBuffer stmt, Object [] columns) 88 { 89 stmt.append(" WHERE "); 90 91 for (int i = 0; i < columns.length; i++) 92 { 93 if (i > 0) 94 { 95 stmt.append(" AND "); 96 } 97 stmt.append(columns[i]); 98 stmt.append("=?"); 99 } 100 } 101 102 108 protected List appendListOfColumns(String [] columns, StringBuffer stmt) 109 { 110 ArrayList columnList = new ArrayList (); 111 112 for (int i = 0; i < columns.length; i++) 113 { 114 if (i > 0) 115 { 116 stmt.append(","); 117 } 118 stmt.append(columns[i]); 119 columnList.add(columns[i]); 120 } 121 return columnList; 122 123 } 124 125 126 } 127 | Popular Tags |