Android Open Source - adme A D M E Serializer






From Project

Back to project page adme.

License

The source code is released under:

Apache License

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;
//from w  w  w  .  j a v a 2 s  . com
import android.content.ContentValues;
import android.database.Cursor;

import com.danielesegato.adme.config.ADMEFieldConfig;
import com.danielesegato.adme.config.SQLiteType;

/**
 * A Serializer to convert from/to the SQLite database and Java classes/primitives.
 */
public interface ADMESerializer {
    /**
     * Null value for SQLite
     */
    String NULL_RAW = "NULL";

    /**
     * @return the SQLite data type associated to this serializer.
     */
    SQLiteType getSQLiteType();

    /**
     * Convert an SQL value into it's java Object / primitive type.
     *
     * @param cursor      the Android Cursor.
     * @param columnPos   the column position to read
     * @param fieldConfig the configuration to the associated field (can be used by the serializer)
     * @return the java value of the object
     */
    Object sqlToJava(Cursor cursor, int columnPos, ADMEFieldConfig fieldConfig);

    /**
     * Convert a String value to it's raw string value ready for insertion in a statement for the
     * SQLite database. Any escape for SQLite should be performed here to avoid SQL Injection.
     * Strings should be wrapped with single quotes etc...
     * <p/>
     * This method is used to convert the default value specified in the annotation into a database
     * CREATE TABLE statement but it may be used for other fields.
     * <p/>
     * Example:
     * <pre>
     *     CREATE TABLE `test` (
     *         `my_column` TEXT DEFAULT {raw_string_will_be_placed_here_as_is}
     *     )
     * </pre>
     *
     * @param val         the string value of the content to put in the database
     * @param fieldConfig the configuration to the associated field (can be used by the serializer)
     * @return the raw string value ready to be placed in the SQLite statement.
     */
    String stringToSqlRaw(String val, ADMEFieldConfig fieldConfig);

    /**
     * Put a fieldValue into an Android {@link android.content.ContentValues}.
     *
     * @param key         the key this value should have in the ContentValues
     * @param values      the non null ContentValues container
     * @param fieldValue  the field value, it should be compatible with the type of this serializer
     * @param fieldConfig the configuration to the associated field (can be used by the serializer)
     * @throws java.lang.IllegalArgumentException if the fieldValue is not cast-able to a type handled
     *                                            by this serializer or, for example, if the field should be a primitive non null and a null value
     *                                            is passed
     */
    void storeInContentValues(String key, ContentValues values, Object fieldValue, ADMEFieldConfig fieldConfig) throws IllegalArgumentException;
}




Java Source Code List

com.danielesegato.adme.ADME.java
com.danielesegato.adme.annotation.ADMEEntity.java
com.danielesegato.adme.annotation.ADMEField.java
com.danielesegato.adme.annotation.ADMEIndexConstraint.java
com.danielesegato.adme.config.ADMEConfigUtils.java
com.danielesegato.adme.config.ADMEEntityConfig.java
com.danielesegato.adme.config.ADMEFieldConfig.java
com.danielesegato.adme.config.ADMEIndexConstraintConfig.java
com.danielesegato.adme.config.OnForeignUpdateDelete.java
com.danielesegato.adme.config.SQLiteType.java
com.danielesegato.adme.db.ADMESerializerMapping.java
com.danielesegato.adme.db.ADMESerializer.java
com.danielesegato.adme.db.ContentProviderUris.java
com.danielesegato.adme.db.SQLiteContentProvider.java
com.danielesegato.adme.db.serializer.BaseADMESerializer.java
com.danielesegato.adme.db.serializer.BigDecimalADMESerializer.java
com.danielesegato.adme.db.serializer.BooleanADMESerializer.java
com.danielesegato.adme.db.serializer.BooleanObjectADMESerializer.java
com.danielesegato.adme.db.serializer.CurrencyADMESerializer.java
com.danielesegato.adme.db.serializer.DateAsStringADMESerializer.java
com.danielesegato.adme.db.serializer.DateAsTimestampADMESerializer.java
com.danielesegato.adme.db.serializer.DoubleADMESerializer.java
com.danielesegato.adme.db.serializer.DoubleObjectADMESerializer.java
com.danielesegato.adme.db.serializer.EnumIntADMESerializer.java
com.danielesegato.adme.db.serializer.EnumStringADMESerializer.java
com.danielesegato.adme.db.serializer.IntADMESerializer.java
com.danielesegato.adme.db.serializer.IntObjectADMESerializer.java
com.danielesegato.adme.db.serializer.LongADMESerializer.java
com.danielesegato.adme.db.serializer.LongObjectADMESerializer.java
com.danielesegato.adme.db.serializer.StringADMESerializer.java
com.danielesegato.adme.provider.ADMEContentProviderComponent.java
com.danielesegato.adme.provider.ADMEContentProvider.java
com.danielesegato.adme.utils.DateHelper.java
com.danielesegato.adme.utils.SQLStringHelper.java
com.danielesegato.adme.utils.SQLiteScriptParser.java
com.danielesegato.demo.adme.ADMEDemoMainActivity.java
com.danielesegato.demo.adme.NavigationDrawerFragment.java