Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Licensed to JumpMind Inc under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. JumpMind Inc licenses this file
* to you under the GNU General Public License, version 3.0 (GPLv3)
* (the "License"); you may not use this file except in compliance
* with the License.
*
* You should have received a copy of the GNU General Public License,
* version 3.0 (GPLv3) along with this library; if not, see
* .
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jumpmind.symmetric.android;
import java.sql.Timestamp;
import java.util.Date;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.NotImplementedException;
import org.jumpmind.db.sql.AbstractSqlTemplate;
import org.jumpmind.db.sql.ISqlReadCursor;
import org.jumpmind.db.sql.ISqlResultsListener;
import org.jumpmind.db.sql.ISqlRowMapper;
import org.jumpmind.db.sql.ISqlStatementSource;
import org.jumpmind.db.sql.ISqlTransaction;
import org.jumpmind.db.sql.ListSqlStatementSource;
import org.jumpmind.db.sql.Row;
import org.jumpmind.db.sql.UniqueKeyException;
import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
import android.database.Cursor;
import android.database.sqlite.SQLiteConstraintException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class AndroidSqlTemplate extends AbstractSqlTemplate {
protected SQLiteOpenHelper databaseHelper;
protected Context androidContext;
public AndroidSqlTemplate(SQLiteOpenHelper databaseHelper, Context androidContext) {
this.databaseHelper = databaseHelper;
this.androidContext = androidContext;
}
public SQLiteOpenHelper getDatabaseHelper() {
return databaseHelper;
}
public byte[] queryForBlob(String sql, int jdbcTypeCode, String jdbcTypeName, Object... params) {
return queryForBlob(sql, params);
}
public byte[] queryForBlob(String sql, Object... params) {
return queryForObject(sql, byte[].class, params);
}
public String queryForClob(String sql, Object... params) {
return queryForString(sql, params);
}
public T queryForObject(String sql, Class clazz, Object... params) {
SQLiteDatabase database = databaseHelper.getWritableDatabase();
try {
return queryForObject(database, sql, clazz, params);
} catch (Exception ex) {
throw translate(ex);
} finally {
close(database);
}
}
protected T queryForObject(SQLiteDatabase database, String sql, Class clazz,
Object... params) {
Cursor cursor = null;
try {
T result = null;
cursor = database.rawQuery(sql, toStringArray(params));
if (cursor.moveToFirst()) {
result = get(cursor, clazz, 0);
}
return result;
} catch (Exception ex) {
throw translate(ex);
} finally {
close(cursor);
}
}
public Map queryForMap(final String sql, final Object... args) {
return queryForObject(sql, new ISqlRowMapper