If you think the Android project adme listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.danielesegato.adme.db.serializer;
//www.java2s.comimport android.content.ContentValues;
import android.database.Cursor;
import com.danielesegato.adme.config.ADMEFieldConfig;
import com.danielesegato.adme.config.SQLiteType;
/**
* Persist a primitive double in the SQLite database.
*/publicclass DoubleADMESerializer extends BaseADMESerializer {
privatestatic DoubleADMESerializer singleton = new DoubleADMESerializer();
publicstatic DoubleADMESerializer getSingleton() {
return singleton;
}
@Override
public SQLiteType getSQLiteType() {
return SQLiteType.REAL;
}
@Override
public Object sqlToJava(Cursor cursor, int columnPos, ADMEFieldConfig fieldConfig) {
return cursor.getDouble(columnPos);
}
@Override
public String stringToSqlRaw(String val, ADMEFieldConfig fieldConfig) {
return Double.toString(Double.parseDouble(val));
}
@Override
publicvoid storeInContentValues(String key, ContentValues values, Object fieldValue, ADMEFieldConfig fieldConfig) throws IllegalArgumentException {
if (fieldValue == null || !(fieldValue instanceof Double)) {
thrownew IllegalArgumentException(String.format(
String.format("Field value for entity %s field %s can't be considered a primitive double for key %s: %s",
fieldConfig.getADMEEntityConfig().getEntityName(),
fieldConfig.getColumnName(),
key,
fieldValue)
));
}
values.put(key, (Double) fieldValue);
}
}