ForcePreparedStatement implements PreparedStatement { protected CacheMode getCacheMode(String query) { Matcher matcher = Pattern.compile(CACHE_HINT).matcher(query); if (matcher.matches()) { String mode = matcher.group(2); return CacheMode.valueOf(mode.toUpperCase()); } else { return CacheMode.NO_CACHE; } } ForcePreparedStatement(ForceConnection connection, String soql); static RuntimeException rethrowAsNonChecked(Throwable throwable); @Override ResultSet executeQuery(); List<Object> getParameters(); @Override ParameterMetaData getParameterMetaData(); ResultSetMetaData getMetaData(); void setFetchSize(int rows); int getFetchSize(); void setMaxRows(int max); int getMaxRows(); void setArray(int i, Array x); void setAsciiStream(int parameterIndex, InputStream x, int length); void setBigDecimal(int parameterIndex, BigDecimal x); void setBinaryStream(int parameterIndex, InputStream x, int length); void setBlob(int i, Blob x); void setBoolean(int parameterIndex, boolean x); void setByte(int parameterIndex, byte x); void setBytes(int parameterIndex, byte[] x); void setCharacterStream(int parameterIndex, Reader reader, int length); void setClob(int i, Clob x); void setDate(int parameterIndex, Date x); void setDate(int parameterIndex, Date x, Calendar cal); void setDouble(int parameterIndex, double x); void setFloat(int parameterIndex, float x); void setInt(int parameterIndex, int x); void setLong(int parameterIndex, long x); void setNull(int parameterIndex, int sqlType); void setNull(int paramIndex, int sqlType, String typeName); void setObject(int parameterIndex, Object x); void setObject(int parameterIndex, Object x, int targetSqlType); void setObject(int parameterIndex, Object x, int targetSqlType,
                          int scale); void setRef(int i, Ref x); void setShort(int parameterIndex, short x); void setString(int parameterIndex, String x); void setTime(int parameterIndex, Time x); void setTime(int parameterIndex, Time x, Calendar cal); void setTimestamp(int parameterIndex, Timestamp x); void setTimestamp(int parameterIndex, Timestamp x, Calendar cal); void setURL(int parameterIndex, URL x); void setUnicodeStream(int parameterIndex, InputStream x, int length); @Override ResultSet executeQuery(String sql); @Override int executeUpdate(String sql); @Override void close(); @Override int getMaxFieldSize(); @Override void setMaxFieldSize(int max); @Override void setEscapeProcessing(boolean enable); @Override int getQueryTimeout(); @Override void setQueryTimeout(int seconds); @Override void cancel(); @Override SQLWarning getWarnings(); @Override void clearWarnings(); @Override void setCursorName(String name); @Override boolean execute(String sql); @Override ResultSet getResultSet(); @Override int getUpdateCount(); @Override boolean getMoreResults(); @Override void setFetchDirection(int direction); @Override int getFetchDirection(); @Override int getResultSetConcurrency(); @Override int getResultSetType(); @Override void addBatch(String sql); @Override void clearBatch(); @Override int[] executeBatch(); @Override Connection getConnection(); @Override boolean getMoreResults(int current); @Override ResultSet getGeneratedKeys(); @Override int executeUpdate(String sql, int autoGeneratedKeys); @Override int executeUpdate(String sql, int[] columnIndexes); @Override int executeUpdate(String sql, String[] columnNames); @Override boolean execute(String sql, int autoGeneratedKeys); @Override boolean execute(String sql, int[] columnIndexes); @Override boolean execute(String sql, String[] columnNames); @Override int getResultSetHoldability(); @Override boolean isClosed(); @Override void setPoolable(boolean poolable); @Override boolean isPoolable(); @Override void closeOnCompletion(); @Override boolean isCloseOnCompletion(); @Override T unwrap(Class<T> iface); @Override boolean isWrapperFor(Class<?> iface); @Override int executeUpdate(); @Override void clearParameters(); @Override boolean execute(); @Override void addBatch(); @Override void setRowId(int parameterIndex, RowId x); @Override void setNString(int parameterIndex, String value); @Override void setNCharacterStream(int parameterIndex, Reader value, long length); @Override void setNClob(int parameterIndex, NClob value); @Override void setClob(int parameterIndex, Reader reader, long length); @Override void setBlob(int parameterIndex, InputStream inputStream, long length); @Override void setNClob(int parameterIndex, Reader reader, long length); @Override void setSQLXML(int parameterIndex, SQLXML xmlObject); @Override void setAsciiStream(int parameterIndex, InputStream x, long length); @Override void setBinaryStream(int parameterIndex, InputStream x, long length); @Override void setCharacterStream(int parameterIndex, Reader reader, long length); @Override void setAsciiStream(int parameterIndex, InputStream x); @Override void setBinaryStream(int parameterIndex, InputStream x); @Override void setCharacterStream(int parameterIndex, Reader reader); @Override void setNCharacterStream(int parameterIndex, Reader value); @Override void setClob(int parameterIndex, Reader reader); @Override void setBlob(int parameterIndex, InputStream inputStream); @Override void setNClob(int parameterIndex, Reader reader);  }
@Test public void testGetCacheMode() { ForcePreparedStatement statement = new ForcePreparedStatement(null, ""); assertEquals(ForcePreparedStatement.CacheMode.SESSION, statement.getCacheMode("CACHE SESSION select name from Account")); assertEquals(ForcePreparedStatement.CacheMode.GLOBAL, statement.getCacheMode(" Cache global select name from Account")); assertEquals(ForcePreparedStatement.CacheMode.NO_CACHE, statement.getCacheMode("select name from Account")); assertEquals(ForcePreparedStatement.CacheMode.NO_CACHE, statement.getCacheMode(" Cache unknown select name from Account")); }