本文整理汇总了Java中com.j256.ormlite.field.FieldType类的典型用法代码示例。如果您正苦于以下问题:Java FieldType类的具体用法?Java FieldType怎么用?Java FieldType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FieldType类属于com.j256.ormlite.field包,在下文中一共展示了FieldType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clearTable
import com.j256.ormlite.field.FieldType; //导入依赖的package包/类
public static int clearTable(ConnectionSource connectionSource, String tableName) throws SQLException {
FieldType[] noFieldTypes = new FieldType[0];
DatabaseType databaseType = connectionSource.getDatabaseType();
StringBuilder sb = new StringBuilder(48);
if (databaseType.isTruncateSupported()) {
sb.append("TRUNCATE TABLE ");
} else {
sb.append("DELETE FROM ");
}
databaseType.appendEscapedEntityName(sb, tableName);
String statement = sb.toString();
Log.i("DatabaseHelper", "clearing table '" + tableName + "' with '" + statement + "'");
CompiledStatement compiledStmt = null;
DatabaseConnection connection = connectionSource.getReadWriteConnection();
try {
compiledStmt =
connection.compileStatement(statement, StatementBuilder.StatementType.EXECUTE, noFieldTypes,
DatabaseConnection.DEFAULT_RESULT_FLAGS);
return compiledStmt.runExecute();
} finally {
if (compiledStmt != null) {
compiledStmt.close();
}
connectionSource.releaseConnection(connection);
}
}
示例2: extractFieldTypes
import com.j256.ormlite.field.FieldType; //导入依赖的package包/类
private static <T> FieldType[] extractFieldTypes(ConnectionSource paramConnectionSource, Class<T> paramClass, String paramString)
{
ArrayList localArrayList = new ArrayList();
for (Object localObject = paramClass; localObject != null; localObject = ((Class)localObject).getSuperclass())
{
Field[] arrayOfField = ((Class)localObject).getDeclaredFields();
int i = arrayOfField.length;
for (int j = 0; j < i; j++)
{
FieldType localFieldType = FieldType.createFieldType(paramConnectionSource, paramString, arrayOfField[j], paramClass);
if (localFieldType != null)
localArrayList.add(localFieldType);
}
}
if (localArrayList.isEmpty())
throw new IllegalArgumentException("No fields have a " + DatabaseField.class.getSimpleName() + " annotation in " + paramClass);
return (FieldType[])localArrayList.toArray(new FieldType[localArrayList.size()]);
}
示例3: sqlArgToJava
import com.j256.ormlite.field.FieldType; //导入依赖的package包/类
@Override
public Object sqlArgToJava(FieldType fieldType, Object sqlArg, int columnPos) throws SQLException {
try {
return Class.forName(sqlArg.toString());
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return null;
}
示例4: resultToJava
import com.j256.ormlite.field.FieldType; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "static-access" })
@Override
public Object resultToJava(FieldType fieldType, DatabaseResults results, int columnPos) throws SQLException {
try {
Class<? extends ServiceParser> serviceParserClass = (Class<? extends ServiceParser>) ServiceParser.class.forName(results.getString(3));
return ServiceFactory.getInstance(serviceParserClass).getData(results.getLong(4));
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return null;
}
示例5: javaToSqlArg
import com.j256.ormlite.field.FieldType; //导入依赖的package包/类
@Override
public Object javaToSqlArg(FieldType fieldType, Object javaObject) throws SQLException {
VKApiFeedItem item = (VKApiFeedItem) javaObject;
if (item == null) {
return null;
} else {
Parcel p = Parcel.obtain();
item.writeToParcel(p, 0);
p.setDataPosition(0);
Object result = super.javaToSqlArg(fieldType, p.marshall());
p.recycle();
return result;
}
}
示例6: sqlArgToJava
import com.j256.ormlite.field.FieldType; //导入依赖的package包/类
@Override
public Object sqlArgToJava(FieldType fieldType, Object sqlArg, int columnPos) throws SQLException {
byte[] cached = (byte[]) super.sqlArgToJava(fieldType, sqlArg, columnPos);
Parcel p = Parcel.obtain();
p.unmarshall(cached, 0, cached.length);
p.setDataPosition(0);
VKApiFeedItem result = new VKApiFeedItem(p);
p.recycle();
return result;
}
示例7: parseDefaultString
import com.j256.ormlite.field.FieldType; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Object parseDefaultString(FieldType fieldType, String defaultStr) {
Object defaultValue = null;
if (DateConverter.DATETIME_FORMAT.equals(defaultStr)) {
defaultValue = javaToSqlArg(null, new Date());
}
return defaultValue;
}
示例8: javaToSqlArg
import com.j256.ormlite.field.FieldType; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Object javaToSqlArg(FieldType fieldType, Object javaObject) {
Object stringDate = null;
if (javaObject != null && javaObject instanceof Date) {
stringDate = dateConverter.stringValue((Date) javaObject);
}
return stringDate;
}
示例9: sqlArgToJava
import com.j256.ormlite.field.FieldType; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Object sqlArgToJava(FieldType fieldType, Object sqlArg, int columnPos)
throws SQLException {
Object javaDate = null;
if (sqlArg != null && sqlArg instanceof String) {
try {
javaDate = dateConverter.dateValue((String) sqlArg);
} catch (Exception e) {
throw new SQLException(
"Failed to parse date string: " + sqlArg, e);
}
}
return javaDate;
}
示例10: TableInfo
import com.j256.ormlite.field.FieldType; //导入依赖的package包/类
public TableInfo(DatabaseType paramDatabaseType, BaseDaoImpl<T, ID> paramBaseDaoImpl, DatabaseTableConfig<T> paramDatabaseTableConfig)
{
this.baseDaoImpl = paramBaseDaoImpl;
this.dataClass = paramDatabaseTableConfig.getDataClass();
this.tableName = paramDatabaseTableConfig.getTableName();
this.fieldTypes = paramDatabaseTableConfig.getFieldTypes(paramDatabaseType);
Object localObject = null;
boolean bool = false;
int i = 0;
for (FieldType localFieldType2 : this.fieldTypes)
{
if ((localFieldType2.isId()) || (localFieldType2.isGeneratedId()) || (localFieldType2.isGeneratedIdSequence()))
{
if (localObject != null)
throw new SQLException("More than 1 idField configured for class " + this.dataClass + " (" + localObject + "," + localFieldType2 + ")");
localObject = localFieldType2;
}
if (localFieldType2.isForeignAutoCreate())
bool = true;
if (localFieldType2.isForeignCollection())
i++;
}
this.idField = localObject;
this.constructor = paramDatabaseTableConfig.getConstructor();
this.foreignAutoCreate = bool;
if (i == 0)
{
this.foreignCollections = NO_FOREIGN_COLLECTIONS;
return;
}
this.foreignCollections = new FieldType[i];
int m = 0;
for (FieldType localFieldType1 : this.fieldTypes)
if (localFieldType1.isForeignCollection())
{
this.foreignCollections[m] = localFieldType1;
m++;
}
}
示例11: buildQueryNextSequence
import com.j256.ormlite.field.FieldType; //导入依赖的package包/类
private static String buildQueryNextSequence(DatabaseType paramDatabaseType, FieldType paramFieldType)
{
if (paramFieldType == null)
return null;
String str = paramFieldType.getGeneratedIdSequence();
if (str == null)
return null;
StringBuilder localStringBuilder = new StringBuilder(64);
paramDatabaseType.appendSelectNextValFromSequence(localStringBuilder, str);
return localStringBuilder.toString();
}
示例12: foreignCollectionsAreAssigned
import com.j256.ormlite.field.FieldType; //导入依赖的package包/类
private boolean foreignCollectionsAreAssigned(FieldType[] paramArrayOfFieldType, Object paramObject)
{
int i = paramArrayOfFieldType.length;
for (int j = 0; j < i; j++)
if (paramArrayOfFieldType[j].extractJavaFieldValue(paramObject) == null)
return false;
return true;
}
示例13: isFieldCreatable
import com.j256.ormlite.field.FieldType; //导入依赖的package包/类
private static boolean isFieldCreatable(DatabaseType paramDatabaseType, FieldType paramFieldType)
{
if (paramFieldType.isForeignCollection())
return false;
if ((paramDatabaseType.isIdSequenceNeeded()) && (paramDatabaseType.isSelectSequenceBeforeInsert()))
return true;
return (!paramFieldType.isGeneratedId()) || (paramFieldType.isSelfGeneratedId()) || (paramFieldType.isAllowGeneratedIdInsert());
}
示例14: generateIdSequenceName
import com.j256.ormlite.field.FieldType; //导入依赖的package包/类
public String generateIdSequenceName(String paramString, FieldType paramFieldType)
{
String str = paramString + DEFAULT_SEQUENCE_SUFFIX;
if (isEntityNamesMustBeUpCase())
return str.toUpperCase();
return str;
}
示例15: appendStringType
import com.j256.ormlite.field.FieldType; //导入依赖的package包/类
protected void appendStringType(StringBuilder paramStringBuilder, FieldType paramFieldType, int paramInt)
{
if (isVarcharFieldWidthSupported())
{
paramStringBuilder.append("VARCHAR(").append(paramInt).append(")");
return;
}
paramStringBuilder.append("VARCHAR");
}