Magic SQL setter! Each occurrence of the pattern "??" will be replaced by a string of repeated ?'s @param sql
(String sql)
| 59 | * @param sql |
| 60 | */ |
| 61 | public final void setSQL(String sql) { |
| 62 | this.orig_sql = sql.trim(); |
| 63 | for (int ctr : this.substitutions) { |
| 64 | StringBuilder sb = new StringBuilder(); |
| 65 | for (int i = 0; i < ctr; i++) { |
| 66 | sb.append(i > 0 ? ", " : "").append("?"); |
| 67 | } |
| 68 | Matcher m = SUBSTITUTION_PATTERN.matcher(sql); |
| 69 | String replace = sb.toString(); |
| 70 | sql = m.replaceFirst(replace); |
| 71 | } |
| 72 | this.sql = sql; |
| 73 | if (LOG.isDebugEnabled()) { |
| 74 | LOG.debug("Initialized SQL:\n{}", this.sql); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | public final String getSQL() { |
| 79 | return (this.sql); |