本文整理汇总了Java中org.litepal.util.LogUtil.d方法的典型用法代码示例。如果您正苦于以下问题:Java LogUtil.d方法的具体用法?Java LogUtil.d怎么用?Java LogUtil.d使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.litepal.util.LogUtil
的用法示例。
在下文中一共展示了LogUtil.d方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: giveTableSchemaACopy
import org.litepal.util.LogUtil; //导入方法依赖的package包/类
/**
* Once there's new table created. The table name will be saved into
* table_schema as a copy. Each table name will be saved only once.
*
* @param tableName
* The table name.
* @param tableType
* 0 means normal table, 1 means intermediate join table.
* @param db
* Instance of SQLiteDatabase.
*/
protected void giveTableSchemaACopy(String tableName, int tableType, SQLiteDatabase db) {
StringBuilder sql = new StringBuilder("select * from ");
sql.append(Const.TableSchema.TABLE_NAME);
LogUtil.d(TAG, "giveTableSchemaACopy SQL is >> " + sql);
Cursor cursor = null;
try {
cursor = db.rawQuery(sql.toString(), null);
if (isNeedtoGiveACopy(cursor, tableName)) {
ContentValues values = new ContentValues();
values.put(Const.TableSchema.COLUMN_NAME, BaseUtility.changeCase(tableName));
values.put(Const.TableSchema.COLUMN_TYPE, tableType);
db.insert(Const.TableSchema.TABLE_NAME, null, values);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (cursor != null) {
cursor.close();
}
}
}
示例2: getChangeColumnsConstraintsSQL
import org.litepal.util.LogUtil; //导入方法依赖的package包/类
/**
* This method create a SQL array for the whole changing column constraints job.
* @return A SQL list contains create temporary table, create new table, add foreign keys,
* migrate data and drop temporary table.
*/
private List<String> getChangeColumnsConstraintsSQL() {
String alterToTempTableSQL = generateAlterToTempTableSQL(mTableModel.getTableName());
String createNewTableSQL = generateCreateTableSQL(mTableModel);
List<String> addForeignKeySQLs = generateAddForeignKeySQL();
String dataMigrationSQL = generateDataMigrationSQL(mTableModelDB);
String dropTempTableSQL = generateDropTempTableSQL(mTableModel.getTableName());
List<String> sqls = new ArrayList<String>();
sqls.add(alterToTempTableSQL);
sqls.add(createNewTableSQL);
sqls.addAll(addForeignKeySQLs);
sqls.add(dataMigrationSQL);
sqls.add(dropTempTableSQL);
LogUtil.d(TAG, "generateChangeConstraintSQL >> ");
for (String sql : sqls) {
LogUtil.d(TAG, sql);
}
LogUtil.d(TAG, "<< generateChangeConstraintSQL");
return sqls;
}
示例3: getForeignKeyColumns
import org.litepal.util.LogUtil; //导入方法依赖的package包/类
/**
* This method looks around all the columns in the table, and judge which of
* them are foreign key columns.
*
* @param tableModel
* Use the TableModel to get table name and columns name to
* generate SQL.
* @return All the foreign key columns in a list.
*/
protected List<String> getForeignKeyColumns(TableModel tableModel) {
List<String> foreignKeyColumns = new ArrayList<String>();
List<ColumnModel> columnModelList = getTableModelFromDB(tableModel.getTableName()).getColumnModels();
for (ColumnModel columnModel : columnModelList) {
String columnName = columnModel.getColumnName();
if (isForeignKeyColumnFormat(columnModel.getColumnName())) {
if (!tableModel.containsColumn(columnName)) {
// Now this is a foreign key column.
LogUtil.d(TAG, "getForeignKeyColumnNames >> foreign key column is " + columnName);
foreignKeyColumns.add(columnName);
}
}
}
return foreignKeyColumns;
}
示例4: clearCopyInTableSchema
import org.litepal.util.LogUtil; //导入方法依赖的package包/类
/**
* The values in table_schame should be synchronized with the model tables
* in the database. If a model table is dropped, the corresponding data
* should be removed from table_schema too.
*
* @param tableNames
* The table names need to remove from table_schema.
*/
protected void clearCopyInTableSchema(List<String> tableNames) {
if (tableNames != null && !tableNames.isEmpty()) {
StringBuilder deleteData = new StringBuilder("delete from ");
deleteData.append(Const.TableSchema.TABLE_NAME).append(" where");
boolean needOr = false;
for (String tableName : tableNames) {
if (needOr) {
deleteData.append(" or ");
}
needOr = true;
deleteData.append(" lower(").append(Const.TableSchema.COLUMN_NAME).append(") ");
deleteData.append("=").append(" lower('").append(tableName).append("')");
}
LogUtil.d(TAG, "clear table schema value sql is " + deleteData);
List<String> sqls = new ArrayList<String>();
sqls.add(deleteData.toString());
execute(sqls, mDb);
}
}
示例5: findIntermediateTablesToDrop
import org.litepal.util.LogUtil; //导入方法依赖的package包/类
/**
* When many2many associations are no longer exist between two models, the
* intermediate join table should be dropped from database. This method
* helps find out those intermediate join tables which should be dropped
* cause their associations in classes are done.
*
* @return A list with all intermediate join tables to drop.
*/
private List<String> findIntermediateTablesToDrop() {
List<String> intermediateTables = new ArrayList<String>();
for (String tableName : DBUtility.findAllTableNames(mDb)) {
if (DBUtility.isIntermediateTable(tableName, mDb)) {
boolean dropIntermediateTable = true;
for (AssociationsModel associationModel : mAssociationModels) {
if (associationModel.getAssociationType() == Const.Model.MANY_TO_MANY) {
String intermediateTableName = DBUtility.getIntermediateTableName(
associationModel.getTableName(),
associationModel.getAssociatedTableName());
if (tableName.equalsIgnoreCase(intermediateTableName)) {
dropIntermediateTable = false;
}
}
}
if (dropIntermediateTable) {
// drop the intermediate join table
intermediateTables.add(tableName);
}
}
}
LogUtil.d(TAG, "findIntermediateTablesToDrop >> " + intermediateTables);
return intermediateTables;
}
示例6: getRemoveColumnSQLs
import org.litepal.util.LogUtil; //导入方法依赖的package包/类
/**
* This method create a SQL array for the whole remove dump columns job.
*
* @param removeColumnNames
* The column names need to remove.
* @param tableName
* The table name to remove from.
* @return A SQL list contains create temporary table, create new table,
* migrate data and drop temporary table.
*/
private List<String> getRemoveColumnSQLs(Collection<String> removeColumnNames, String tableName) {
TableModel tableModelFromDB = getTableModelFromDB(tableName);
String alterToTempTableSQL = generateAlterToTempTableSQL(tableName);
LogUtil.d(TAG, "generateRemoveColumnSQL >> " + alterToTempTableSQL);
String createNewTableSQL = generateCreateNewTableSQL(removeColumnNames, tableModelFromDB);
LogUtil.d(TAG, "generateRemoveColumnSQL >> " + createNewTableSQL);
String dataMigrationSQL = generateDataMigrationSQL(tableModelFromDB);
LogUtil.d(TAG, "generateRemoveColumnSQL >> " + dataMigrationSQL);
String dropTempTableSQL = generateDropTempTableSQL(tableName);
LogUtil.d(TAG, "generateRemoveColumnSQL >> " + dropTempTableSQL);
List<String> sqls = new ArrayList<String>();
sqls.add(alterToTempTableSQL);
sqls.add(createNewTableSQL);
sqls.add(dataMigrationSQL);
sqls.add(dropTempTableSQL);
return sqls;
}
示例7: findColumnsToRemove
import org.litepal.util.LogUtil; //导入方法依赖的package包/类
/**
* This method helps find the difference between table model from class and
* table model from database. Database should always be synchronized with
* model class. If there're some fields are removed from class, the table
* model from database will be compared to find out which fields are
* removed. But there're still some exceptions. The columns named id or _id
* won't ever be removed. The foreign key column will be checked some where
* else, not from here.
*
* @return A list with column names need to remove.
*/
private List<String> findColumnsToRemove() {
TableModel tableModelDB = getTableModelFromDB(mTableModel.getTableName());
List<String> removeColumns = new ArrayList<String>();
Map<String, String> dbColumnsMap = tableModelDB.getColumns();
Set<String> dbColumnNames = dbColumnsMap.keySet();
for (String dbColumnName : dbColumnNames) {
if (isNeedToRemove(dbColumnName)) {
removeColumns.add(dbColumnName);
}
}
for (String removeColumn : removeColumns) {
LogUtil.d(TAG, "remove column is >> " + removeColumn);
}
return removeColumns;
}
示例8: getForeignKeyColumns
import org.litepal.util.LogUtil; //导入方法依赖的package包/类
/**
* This method looks around all the columns in the table, and judge which of
* them are foreign key columns.
*
* @param tableModel
* Use the TableModel to get table name and columns name to
* generate SQL.
* @return All the foreign key columns in a list.
*/
protected List<String> getForeignKeyColumns(TableModel tableModel) {
List<String> foreignKeyColumns = new ArrayList<String>();
Set<String> columnNamesDB = getTableModelFromDB(tableModel.getTableName()).getColumnNames();
for (String columnNameDB : columnNamesDB) {
if (isForeignKeyColumnFormat(columnNameDB)) {
if (!BaseUtility.containsIgnoreCases(tableModel.getColumnNames(), columnNameDB)) {
// Now this is a foreign key column.
LogUtil.d(TAG, "getForeignKeyColumnNames >> foreign key column is "
+ columnNameDB);
foreignKeyColumns.add(columnNameDB);
}
}
}
return foreignKeyColumns;
}
示例9: clearCopyInTableSchema
import org.litepal.util.LogUtil; //导入方法依赖的package包/类
/**
* The values in table_schame should be synchronized with the model tables
* in the database. If a model table is dropped, the corresponding data
* should be removed from table_schema too.
*
* @param tableNames
* The table names need to remove from table_schema.
*/
protected void clearCopyInTableSchema(List<String> tableNames) {
if (tableNames != null && !tableNames.isEmpty()) {
StringBuilder deleteData = new StringBuilder("delete from ");
deleteData.append(Const.TableSchema.TABLE_NAME).append(" where");
boolean needOr = false;
for (String tableName : tableNames) {
if (needOr) {
deleteData.append(" or ");
}
needOr = true;
deleteData.append(" lower(").append(Const.TableSchema.COLUMN_NAME).append(") ");
deleteData.append("=").append(" lower('").append(tableName).append("')");
}
LogUtil.d(TAG, "clear table schema value sql is " + deleteData);
String[] sqls = { deleteData.toString() };
execute(sqls, mDb);
}
}
示例10: generateCreateTableSQL
import org.litepal.util.LogUtil; //导入方法依赖的package包/类
/**
* Generate a create table SQL by the passed in parameters. Note that it
* will always generate a SQL with id/_id column in it as primary key and
* this id is auto increment as integer if the autoIncrementId is true, or
* no primary key will be added.
*
* @param tableName
* The table name.
* @param columnModels
* A list contains all column models with column info.
* @param autoIncrementId
* Generate an auto increment id or not. Only intermediate join table doesn't need
* an auto increment id.
* @return A generated create table SQL.
*/
protected String generateCreateTableSQL(String tableName, List<ColumnModel> columnModels,
boolean autoIncrementId) {
StringBuilder createTableSQL = new StringBuilder("create table ");
createTableSQL.append(tableName).append(" (");
if (autoIncrementId) {
createTableSQL.append("id integer primary key autoincrement,");
}
if (isContainsOnlyIdField(columnModels)) {
// Remove the last comma when only have id field in model.
createTableSQL.deleteCharAt(createTableSQL.length() - 1);
}
boolean needSeparator = false;
for (ColumnModel columnModel : columnModels) {
if (columnModel.isIdColumn()) {
continue;
}
if (needSeparator) {
createTableSQL.append(", ");
}
needSeparator = true;
createTableSQL.append(columnModel.getColumnName()).append(" ").append(columnModel.getColumnType());
if (!columnModel.isNullable()) {
createTableSQL.append(" not null");
}
if (columnModel.isUnique()) {
createTableSQL.append(" unique");
}
String defaultValue = columnModel.getDefaultValue();
if (!TextUtils.isEmpty(defaultValue)) {
createTableSQL.append(" default ").append(defaultValue);
}
}
createTableSQL.append(")");
LogUtil.d(TAG, "create table sql is >> " + createTableSQL);
return createTableSQL.toString();
}
示例11: generateAddColumnSQL
import org.litepal.util.LogUtil; //导入方法依赖的package包/类
/**
* Generate a SQL for add new column into the existing table.
* @param tableName
* The table which want to add a column
* @param columnModel
* Which contains column info
* @return A SQL to add new column.
*/
protected String generateAddColumnSQL(String tableName, ColumnModel columnModel) {
StringBuilder addColumnSQL = new StringBuilder();
addColumnSQL.append("alter table ").append(tableName);
addColumnSQL.append(" add column ").append(columnModel.getColumnName());
addColumnSQL.append(" ").append(columnModel.getColumnType());
if (!columnModel.isNullable()) {
addColumnSQL.append(" not null");
}
if (columnModel.isUnique()) {
addColumnSQL.append(" unique");
}
String defaultValue = columnModel.getDefaultValue();
if (!TextUtils.isEmpty(defaultValue)) {
addColumnSQL.append(" default ").append(defaultValue);
} else {
if (!columnModel.isNullable()) {
if ("integer".equalsIgnoreCase(columnModel.getColumnType())) {
defaultValue = "0";
} else if ("text".equalsIgnoreCase(columnModel.getColumnType())) {
defaultValue = "''";
} else if ("real".equalsIgnoreCase(columnModel.getColumnType())) {
defaultValue = "0.0";
}
addColumnSQL.append(" default ").append(defaultValue);
}
}
LogUtil.d(TAG, "add column sql is >> " + addColumnSQL);
return addColumnSQL.toString();
}
示例12: addForeignKeyColumn
import org.litepal.util.LogUtil; //导入方法依赖的package包/类
/**
* This method is used to add many to one association or one to one
* association on tables. It will automatically build a SQL to add foreign
* key to a table. If the passed in table name or associated table name
* doesn't exist, it will throw an exception.
*
* @param tableName
* The table name.
* @param associatedTableName
* The associated table name.
* @param tableHoldsForeignKey
* The table which holds the foreign key.
* @param db
* Instance of SQLiteDatabase.
*
* @throws org.litepal.exceptions.DatabaseGenerateException
*/
protected void addForeignKeyColumn(String tableName, String associatedTableName,
String tableHoldsForeignKey, SQLiteDatabase db) {
if (DBUtility.isTableExists(tableName, db)) {
if (DBUtility.isTableExists(associatedTableName, db)) {
String foreignKeyColumn = null;
if (tableName.equals(tableHoldsForeignKey)) {
foreignKeyColumn = getForeignKeyColumnName(associatedTableName);
} else if (associatedTableName.equals(tableHoldsForeignKey)) {
foreignKeyColumn = getForeignKeyColumnName(tableName);
}
if (!DBUtility.isColumnExists(foreignKeyColumn, tableHoldsForeignKey, db)) {
ColumnModel columnModel = new ColumnModel();
columnModel.setColumnName(foreignKeyColumn);
columnModel.setColumnType("integer");
List<String> sqls = new ArrayList<String>();
sqls.add(generateAddColumnSQL(tableHoldsForeignKey, columnModel));
execute(sqls, db);
} else {
LogUtil.d(TAG, "column " + foreignKeyColumn
+ " is already exist, no need to add one");
}
} else {
throw new DatabaseGenerateException(DatabaseGenerateException.TABLE_DOES_NOT_EXIST
+ associatedTableName);
}
} else {
throw new DatabaseGenerateException(DatabaseGenerateException.TABLE_DOES_NOT_EXIST
+ tableName);
}
}
示例13: createOrUpgradeTable
import org.litepal.util.LogUtil; //导入方法依赖的package包/类
/**
* Analyzing the table model, them remove the dump columns and add new
* columns of a table.
*/
@Override
protected void createOrUpgradeTable(SQLiteDatabase db, boolean force) {
mDb = db;
for (TableModel tableModel : getAllTableModels()) {
mTableModel = tableModel;
mTableModelDB = getTableModelFromDB(tableModel.getTableName());
LogUtil.d(TAG, "createOrUpgradeTable: model is " + mTableModel.getTableName());
upgradeTable();
}
}
示例14: findColumnsToRemove
import org.litepal.util.LogUtil; //导入方法依赖的package包/类
/**
* This method helps find the difference between table model from class and
* table model from database. Database should always be synchronized with
* model class. If there're some fields are removed from class, the table
* model from database will be compared to find out which fields are
* removed. But there're still some exceptions. The columns named id or _id
* won't ever be removed. The foreign key column will be checked some where
* else, not from here.
*
* @return A list with column names need to remove.
*/
private List<String> findColumnsToRemove() {
String tableName = mTableModel.getTableName();
List<String> removeColumns = new ArrayList<String>();
List<ColumnModel> columnModelList = mTableModelDB.getColumnModels();
for (ColumnModel columnModel : columnModelList) {
String dbColumnName = columnModel.getColumnName();
if (isNeedToRemove(dbColumnName)) {
removeColumns.add(dbColumnName);
}
}
LogUtil.d(TAG, "remove columns from " + tableName + " >> " + removeColumns);
return removeColumns;
}
示例15: findColumnTypesToChange
import org.litepal.util.LogUtil; //导入方法依赖的package包/类
/**
* It will check each class in the mapping list. Find their types for each
* field is changed or not by comparing with the types in table columns. If
* there's a column have same name as a field in class but with different
* type, then it's a type changed column.
*
* @return A list contains all ColumnModel which type are changed from database.
*/
private List<ColumnModel> findColumnTypesToChange() {
List<ColumnModel> columnsToChangeType = new ArrayList<ColumnModel>();
for (ColumnModel columnModelDB : mTableModelDB.getColumnModels()) {
for (ColumnModel columnModel : mTableModel.getColumnModels()) {
if (columnModelDB.getColumnName().equalsIgnoreCase(columnModel.getColumnName())) {
if (!columnModelDB.getColumnType().equalsIgnoreCase(columnModel.getColumnType())) {
if (columnModel.getColumnType().equalsIgnoreCase("blob") && TextUtils.isEmpty(columnModelDB.getColumnType())) {
// Case for binary array type upgrade. Do nothing under this condition.
} else {
// column type is changed
columnsToChangeType.add(columnModel);
}
}
if (!hasConstraintChanged) {
// for reducing loops, check column constraints change here.
LogUtil.d(TAG, "default value db is:" + columnModelDB.getDefaultValue() + ", default value is:" + columnModel.getDefaultValue());
if (columnModelDB.isNullable() != columnModel.isNullable() ||
!columnModelDB.getDefaultValue().equalsIgnoreCase(columnModel.getDefaultValue()) ||
(columnModelDB.isUnique() && !columnModel.isUnique())) { // unique constraint can not be added
hasConstraintChanged = true;
}
}
}
}
}
return columnsToChangeType;
}