當前位置: 首頁>>代碼示例>>Java>>正文


Java Column類代碼示例

本文整理匯總了Java中com.activeandroid.annotation.Column的典型用法代碼示例。如果您正苦於以下問題:Java Column類的具體用法?Java Column怎麽用?Java Column使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Column類屬於com.activeandroid.annotation包,在下文中一共展示了Column類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getDeclaredColumnFields

import com.activeandroid.annotation.Column; //導入依賴的package包/類
public static Set<Field> getDeclaredColumnFields(Class<?> type) {
	Set<Field> declaredColumnFields = Collections.emptySet();
	
	if (ReflectionUtils.isSubclassOf(type, Model.class) || Model.class.equals(type)) {
		declaredColumnFields = new LinkedHashSet<Field>();
		
		Field[] fields = type.getDeclaredFields();
		Arrays.sort(fields, new Comparator<Field>() {
			@Override
			public int compare(Field field1, Field field2) {
				return field2.getName().compareTo(field1.getName());
			}
		});
		for (Field field : fields) {
			if (field.isAnnotationPresent(Column.class)) {
				declaredColumnFields.add(field);
			}
		}

		Class<?> parentType = type.getSuperclass();
		if (parentType != null) {
			declaredColumnFields.addAll(getDeclaredColumnFields(parentType));
		}
	}
	
	return declaredColumnFields;		
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:28,代碼來源:ReflectionUtils.java

示例2: createUniqueColumnDefinition

import com.activeandroid.annotation.Column; //導入依賴的package包/類
public static void createUniqueColumnDefinition(TableInfo tableInfo, Field field) {
	final String name = tableInfo.getColumnName(field);
	final Column column = field.getAnnotation(Column.class);

       if (field.getName().equals("mId")) {
           return;
       }

	String[] groups = column.uniqueGroups();
	ConflictAction[] conflictActions = column.onUniqueConflicts();
	if (groups.length != conflictActions.length)
		return;

	for (int i = 0; i < groups.length; i++) {
		String group = groups[i];
		ConflictAction conflictAction = conflictActions[i];

		if (TextUtils.isEmpty(group))
			continue;

		List<String> list = sUniqueGroupMap.get(group);
		if (list == null) {
			list = new ArrayList<String>();
		}
		list.add(name);

		sUniqueGroupMap.put(group, list);
		sOnUniqueConflictsMap.put(group, conflictAction);
	}
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:31,代碼來源:SQLiteUtils.java

示例3: createColumnDefinition

import com.activeandroid.annotation.Column; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public static String createColumnDefinition(TableInfo tableInfo, Field field) {
	StringBuilder definition = new StringBuilder();

	Class<?> type = field.getType();
	final String name = tableInfo.getColumnName(field);
	final TypeSerializer typeSerializer = Cache.getParserForType(field.getType());
	final Column column = field.getAnnotation(Column.class);

	if (typeSerializer != null) {
		type = typeSerializer.getSerializedType();
	}

	if (TYPE_MAP.containsKey(type)) {
		definition.append(name);
		definition.append(" ");
		definition.append(TYPE_MAP.get(type).toString());
	}
	else if (ReflectionUtils.isModel(type)) {
		definition.append(name);
		definition.append(" ");
		definition.append(SQLiteType.INTEGER.toString());
	}
	else if (ReflectionUtils.isSubclassOf(type, Enum.class)) {
		definition.append(name);
		definition.append(" ");
		definition.append(SQLiteType.TEXT.toString());
	}

	if (!TextUtils.isEmpty(definition)) {

		if (name.equals(tableInfo.getIdName())) {
			definition.append(" PRIMARY KEY AUTOINCREMENT");
		}else if(column!=null){
			if (column.length() > -1) {
				definition.append("(");
				definition.append(column.length());
				definition.append(")");
			}

			if (column.notNull()) {
				definition.append(" NOT NULL ON CONFLICT ");
				definition.append(column.onNullConflict().toString());
			}

			if (column.unique()) {
				definition.append(" UNIQUE ON CONFLICT ");
				definition.append(column.onUniqueConflict().toString());
			}
		}

		if (FOREIGN_KEYS_SUPPORTED && ReflectionUtils.isModel(type)) {
			definition.append(" REFERENCES ");
			definition.append(Cache.getTableInfo((Class<? extends Model>) type).getTableName());
			definition.append("("+tableInfo.getIdName()+")");
			definition.append(" ON DELETE ");
			definition.append(column.onDelete().toString().replace("_", " "));
			definition.append(" ON UPDATE ");
			definition.append(column.onUpdate().toString().replace("_", " "));
		}
	}
	else {
		Log.e("No type mapping for: " + type.toString());
	}

	return definition.toString();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:68,代碼來源:SQLiteUtils.java

示例4: TableInfo

import com.activeandroid.annotation.Column; //導入依賴的package包/類
public TableInfo(Class<? extends Model> type) {
	mType = type;

	final Table tableAnnotation = type.getAnnotation(Table.class);

       if (tableAnnotation != null) {
		mTableName = tableAnnotation.name();
		mIdName = tableAnnotation.id();
	}
	else {
		mTableName = type.getSimpleName();
       }

       // Manually add the id column since it is not declared like the other columns.
       Field idField = getIdField(type);
       mColumnNames.put(idField, mIdName);

       List<Field> fields = new LinkedList<Field>(ReflectionUtils.getDeclaredColumnFields(type));
       Collections.reverse(fields);

       for (Field field : fields) {
           if (field.isAnnotationPresent(Column.class)) {
               final Column columnAnnotation = field.getAnnotation(Column.class);
               String columnName = columnAnnotation.name();
               if (TextUtils.isEmpty(columnName)) {
                   columnName = field.getName();
               }

               mColumnNames.put(field, columnName);
           }
       }

}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:34,代碼來源:TableInfo.java

示例5: createUniqueColumnDefinition

import com.activeandroid.annotation.Column; //導入依賴的package包/類
public static void createUniqueColumnDefinition(TableInfo tableInfo, Field field) {
	final String name = tableInfo.getColumnName(field);
	final Column column = field.getAnnotation(Column.class);

       if (field.getName().equals("mId")) {
           return;
       }

	String[] groups = column.uniqueGroups();
	ConflictAction[] conflictActions = column.onUniqueConflicts();
	if (groups.length != conflictActions.length)
		return;

	for (int i = 0; i < groups.length; i++) {
		String group = groups[i];
		ConflictAction conflictAction = conflictActions[i];

		if (group.isEmpty())
			continue;

		List<String> list = sUniqueGroupMap.get(group);
		if (list == null) {
			list = new ArrayList<String>();
		}
		list.add(name);

		sUniqueGroupMap.put(group, list);
		sOnUniqueConflictsMap.put(group, conflictAction);
	}
}
 
開發者ID:DobrinAlexandru,項目名稱:Wabbit-Messenger---android-client,代碼行數:31,代碼來源:SQLiteUtils.java


注:本文中的com.activeandroid.annotation.Column類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。