1 23 24 package org.xquark.jdbc.typing; 25 26 30 public class SQLStatementCustomizer 31 { 32 private static final String RCSRevision = "$Revision: 1.1 $"; 33 private static final String RCSName = "$Name: $"; 34 35 private String preparedStatement = null; 36 37 40 public SQLStatementCustomizer(String statement) 41 { 42 preparedStatement = statement; 43 } 44 45 public String getTableCreationStatement( 46 String tableName, 47 String columnSpecs) 48 { 49 StringBuffer sb = new StringBuffer (); 50 int offset = preparedStatement.indexOf('?'); 51 sb.append(preparedStatement.substring(0, offset)); 52 sb.append(tableName); 53 int offset2 = preparedStatement.indexOf('?', offset + 1); 54 sb.append(preparedStatement.substring(offset + 1, offset2)); 55 sb.append(columnSpecs); 56 sb.append(preparedStatement.substring(offset2 + 1)); 57 return sb.toString(); 58 } 59 60 public String getSelectStatement( 61 String columnList, 62 String tableName, 63 String filterClause) 64 { 65 StringBuffer sb = new StringBuffer (); 66 int offset = preparedStatement.indexOf('?'); 67 sb.append(preparedStatement.substring(0, offset)); 68 sb.append(columnList); 69 int offset2 = preparedStatement.indexOf('?', offset + 1); 70 sb.append(preparedStatement.substring(offset + 1, offset2)); 71 sb.append(tableName); 72 offset = offset2 + 1; 73 offset2 = preparedStatement.indexOf('?', offset); 74 sb.append(preparedStatement.substring(offset, offset2)); 75 sb.append(filterClause); 76 sb.append(preparedStatement.substring(offset2 + 1)); 77 return sb.toString(); 78 } 79 } 80 | Popular Tags |