/** * Appends an SQL part consisting of a list of bind parameters. * <p> * That is, <code>appendParams(1)</code> appends <code><strong>?</strong></code>, <code>appendParams(2)</code> * appends <code><strong>?,?</strong></code> and so on. * * @param count the number of parameters ("?" symbols) to be added * @return this instance * @throws IllegalStateException if instance is fixed */ public SQLParts appendParams(int count) { return append(getParamsString(count)); }
public int hashCode() { if (myHash == 0) myHash = calcHash(); return myHash; }
fixedKey = e.getKey(); assert fixedKey != null; assert fixedKey.isFixed() : sql; stmt = e.getValue(); if (stmt != null) { Internal.logFine(this, "calling sqlite3_prepare_v2 for [" + sql + "]"); long from = profiler == null ? 0 : System.nanoTime(); String sqlString = sql.toString(); if (sqlString.trim().length() == 0) throw new SQLiteException(WRAPPER_USER_ERROR, "empty SQL"); SQLiteController controller = cached ? myCachedController : myUncachedController; if (fixedKey == null) fixedKey = sql.getFixedParts(); statement = new SQLiteStatement(controller, stmt, fixedKey, myProfiler); myStatements.add(statement);
/** * Empties this SQLParts instance. * * @throws IllegalStateException if instance is fixed */ public void clear() { if (myFixed) { throw new IllegalStateException(String.valueOf(this)); } myParts.clear(); dropCachedValues(); }
rc = _SQLiteSwigged.sqlite3_step(handle); if (profiler != null) profiler.reportStep(myStepped, mySqlParts.toString(), from, System.nanoTime(), rc); } finally { finalizeStep(ph, "step");
private String getParamsString(int count) { if (count < 1) return null; if (count >= PARAMS_STRINGS.length) return createParamsString(count); String s = PARAMS_STRINGS[count]; if (s == null) s = PARAMS_STRINGS[count] = createParamsString(count); return s; }
/** * Create an instance of SQLParts containing only single piece of SQL. * * @param sql SQL piece */ public SQLParts(String sql) { myParts = new ArrayList<String>(1); append(sql); }
/** * Convenience method that prepares a statement for the given String-based SQL. See {@link #prepare(SQLParts, boolean)} * for details. * * @param sql the SQL statement, not null * @param cached if true, the statement handle will be cached by the connection * @return an instance of {@link SQLiteStatement} * @throws SQLiteException if SQLite returns an error, or if the call violates the contract of this class */ public SQLiteStatement prepare(String sql, boolean cached) throws SQLiteException { return prepare(new SQLParts(sql), cached); }
/** * Instances are constructed only by SQLiteConnection. * * @param controller controller, provided by the connection * @param handle native handle wrapper * @param sqlParts SQL * @param profiler an instance of profiler for the statement, or null * @see SQLiteConnection#prepare(String, boolean) */ SQLiteStatement(SQLiteController controller, SWIGTYPE_p_sqlite3_stmt handle, SQLParts sqlParts, SQLiteProfiler profiler) { assert handle != null; assert sqlParts.isFixed() : sqlParts; myController = controller; myHandle = handle; mySqlParts = sqlParts; myProfiler = profiler; Internal.logFine(this, "instantiated"); }
/** * Adds a part to the SQL. * * @param part a piece of SQL added * @return this instance * @throws IllegalStateException if instance is fixed */ public SQLParts append(String part) { if (myFixed) { throw new IllegalStateException(String.valueOf(this)); } if (part != null && part.length() > 0) { myParts.add(part); dropCachedValues(); } return this; }
r = manual.wrapper_load_ints(handle, column, buffer, offset, length); rc = manual.getLastReturnCode(); if (profiler != null) profiler.reportLoadInts(myStepped, mySqlParts.toString(), from, System.nanoTime(), rc, r); } finally { finalizeStep(ph, "loadInts");
/** * Adds all parts from a different SQLParts to the SQL. * * @param parts source object to copy parts from, may be null * @return this instance * @throws IllegalStateException if instance is fixed */ public SQLParts append(SQLParts parts) { if (myFixed) { throw new IllegalStateException(String.valueOf(this)); } if (parts != null && !parts.myParts.isEmpty()) { myParts.addAll(parts.myParts); dropCachedValues(); } return this; }
r = manual.wrapper_load_longs(handle, column, buffer, offset, length); rc = manual.getLastReturnCode(); if (profiler != null) profiler.reportLoadLongs(myStepped, mySqlParts.toString(), from, System.nanoTime(), rc, r); } finally { finalizeStep(ph, "loadLongs");