Java Code Examples for android.database.Cursor#getShort()

The following examples show how to use android.database.Cursor#getShort() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AllophoneDao.java    From ml-authentication with Apache License 2.0 6 votes vote down vote up
@Override
public Allophone readEntity(Cursor cursor, int offset) {
    Allophone entity = new Allophone( //
        cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
        localeConverter.convertToEntityProperty(cursor.getString(offset + 1)), // locale
        cursor.isNull(offset + 2) ? null : timeLastUpdateConverter.convertToEntityProperty(cursor.getLong(offset + 2)), // timeLastUpdate
        cursor.getInt(offset + 3), // revisionNumber
        contentStatusConverter.convertToEntityProperty(cursor.getString(offset + 4)), // contentStatus
        cursor.getString(offset + 5), // valueIpa
        cursor.getString(offset + 6), // valueSampa
        cursor.getShort(offset + 7) != 0, // diacritic
        cursor.isNull(offset + 8) ? null : soundTypeConverter.convertToEntityProperty(cursor.getString(offset + 8)), // soundType
        cursor.isNull(offset + 9) ? null : vowelLengthConverter.convertToEntityProperty(cursor.getString(offset + 9)), // vowelLength
        cursor.isNull(offset + 10) ? null : vowelHeightConverter.convertToEntityProperty(cursor.getString(offset + 10)), // vowelHeight
        cursor.isNull(offset + 11) ? null : vowelFrontnessConverter.convertToEntityProperty(cursor.getString(offset + 11)), // vowelFrontness
        cursor.isNull(offset + 12) ? null : lipRoundingConverter.convertToEntityProperty(cursor.getString(offset + 12)), // lipRounding
        cursor.isNull(offset + 13) ? null : consonantTypeConverter.convertToEntityProperty(cursor.getString(offset + 13)), // consonantType
        cursor.isNull(offset + 14) ? null : consonantPlaceConverter.convertToEntityProperty(cursor.getString(offset + 14)), // consonantPlace
        cursor.isNull(offset + 15) ? null : consonantVoicingConverter.convertToEntityProperty(cursor.getString(offset + 15)), // consonantVoicing
        cursor.getInt(offset + 16) // usageCount
    );
    return entity;
}
 
Example 2
Source File: LocalRepoDao.java    From OpenHub with GNU General Public License v3.0 6 votes vote down vote up
@Override
public LocalRepo readEntity(Cursor cursor, int offset) {
    LocalRepo entity = new LocalRepo( //
        cursor.getLong(offset + 0), // id
        cursor.getString(offset + 1), // name
        cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // description
        cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // language
        cursor.isNull(offset + 4) ? null : cursor.getInt(offset + 4), // stargazersCount
        cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5), // watchersCount
        cursor.isNull(offset + 6) ? null : cursor.getInt(offset + 6), // forksCount
        cursor.isNull(offset + 7) ? null : cursor.getShort(offset + 7) != 0, // fork
        cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // ownerLogin
        cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9) // ownerAvatarUrl
    );
    return entity;
}
 
Example 3
Source File: DB.java    From LaunchTime with GNU General Public License v3.0 6 votes vote down vote up
public boolean isTinyCategory(String catID) {

        SQLiteDatabase db = this.getReadableDatabase();

        Cursor cursor = db.query(CATEGORIES_TABLE, new String[]{FLAGS}, CATID + "=?", new String[]{catID}, null, null, null, null);
        boolean tiny = false;
        try {
            if (cursor.moveToNext()) {
                tiny = ((cursor.getShort(cursor.getColumnIndex(FLAGS)) & FLAGS_ISTINY) == FLAGS_ISTINY);
            }
        } catch (Exception e) {
            Log.e("LaunchDB", "tiny error.", e);
        } finally {
            cursor.close();
        }
        return tiny;
    }
 
Example 4
Source File: BookMarkRepoDao.java    From OpenHub with GNU General Public License v3.0 6 votes vote down vote up
@Override
public BookMarkRepo readEntity(Cursor cursor, int offset) {
    BookMarkRepo entity = new BookMarkRepo( //
        cursor.getLong(offset + 0), // id
        cursor.getString(offset + 1), // name
        cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // description
        cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // language
        cursor.isNull(offset + 4) ? null : cursor.getInt(offset + 4), // stargazersCount
        cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5), // watchersCount
        cursor.isNull(offset + 6) ? null : cursor.getInt(offset + 6), // forksCount
        cursor.isNull(offset + 7) ? null : cursor.getShort(offset + 7) != 0, // fork
        cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // ownerLogin
        cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // ownerAvatarUrl
        cursor.isNull(offset + 10) ? null : new java.util.Date(cursor.getLong(offset + 10)) // markTime
    );
    return entity;
}
 
Example 5
Source File: PrimitiveFieldsStorIOSQLiteGetResolver.java    From storio with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
@NonNull
public PrimitiveFields mapFromCursor(@NonNull StorIOSQLite storIOSQLite, @NonNull Cursor cursor) {
    PrimitiveFields object = new PrimitiveFields();

    object.field1 = cursor.getInt(cursor.getColumnIndex("field1")) == 1;
    object.field2 = cursor.getShort(cursor.getColumnIndex("field2"));
    object.field3 = cursor.getInt(cursor.getColumnIndex("field3"));
    object.field4 = cursor.getLong(cursor.getColumnIndex("field4"));
    object.field5 = cursor.getFloat(cursor.getColumnIndex("field5"));
    object.field6 = cursor.getDouble(cursor.getColumnIndex("field6"));
    object.field7 = cursor.getString(cursor.getColumnIndex("field7"));
    object.field8 = cursor.getBlob(cursor.getColumnIndex("field8"));

    return object;
}
 
Example 6
Source File: PrimitiveMethodsConstructorStorIOSQLiteGetResolver.java    From storio with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
@NonNull
public PrimitiveMethodsConstructor mapFromCursor(@NonNull StorIOSQLite storIOSQLite, @NonNull Cursor cursor) {

    boolean field1 = cursor.getInt(cursor.getColumnIndex("field1")) == 1;
    short field2 = cursor.getShort(cursor.getColumnIndex("field2"));
    int field3 = cursor.getInt(cursor.getColumnIndex("field3"));
    long field4 = cursor.getLong(cursor.getColumnIndex("field4"));
    float field5 = cursor.getFloat(cursor.getColumnIndex("field5"));
    double field6 = cursor.getDouble(cursor.getColumnIndex("field6"));
    String field7 = cursor.getString(cursor.getColumnIndex("field7"));
    byte[] field8 = cursor.getBlob(cursor.getColumnIndex("field8"));

    PrimitiveMethodsConstructor object = new PrimitiveMethodsConstructor(field1, field2, field3, field4, field5, field6, field7, field8);

    return object;
}
 
Example 7
Source File: StatisticsDao.java    From BrainPhaser with GNU General Public License v3.0 5 votes vote down vote up
/** @inheritdoc */
@Override
public Statistics readEntity(Cursor cursor, int offset) {
    Statistics entity = new Statistics( //
        cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
        cursor.isNull(offset + 1) ? null : cursor.getShort(offset + 1) != 0, // succeeded
        cursor.isNull(offset + 2) ? null : new java.util.Date(cursor.getLong(offset + 2)), // time
        cursor.getLong(offset + 3), // userId
        cursor.getLong(offset + 4) // challengeId
    );
    return entity;
}
 
Example 8
Source File: NoteEntityDao.java    From CrazyDaily with Apache License 2.0 5 votes vote down vote up
@Override
public NoteEntity readEntity(Cursor cursor, int offset) {
    NoteEntity entity = new NoteEntity( //
        cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
        cursor.isNull(offset + 1) ? null : imagesConverter.convertToEntityProperty(cursor.getString(offset + 1)), // images
        cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // videoUrl
        cursor.getString(offset + 3), // text
        cursor.getShort(offset + 4) != 0, // isCanDownload
        cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5) // flag
    );
    return entity;
}
 
Example 9
Source File: BoxedTypesFieldsIgnoreNullStorIOContentResolverGetResolver.java    From storio with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
@NonNull
public BoxedTypesFieldsIgnoreNull mapFromCursor(@NonNull StorIOContentResolver storIOContentResolver, @NonNull Cursor cursor) {
    BoxedTypesFieldsIgnoreNull object = new BoxedTypesFieldsIgnoreNull();

    if (!cursor.isNull(cursor.getColumnIndex("field1"))) {
        object.field1 = cursor.getInt(cursor.getColumnIndex("field1")) == 1;
    }
    if (!cursor.isNull(cursor.getColumnIndex("field2"))) {
        object.field2 = cursor.getShort(cursor.getColumnIndex("field2"));
    }
    if (!cursor.isNull(cursor.getColumnIndex("field3"))) {
        object.field3 = cursor.getInt(cursor.getColumnIndex("field3"));
    }
    if (!cursor.isNull(cursor.getColumnIndex("field4"))) {
        object.field4 = cursor.getLong(cursor.getColumnIndex("field4"));
    }
    if (!cursor.isNull(cursor.getColumnIndex("field5"))) {
        object.field5 = cursor.getFloat(cursor.getColumnIndex("field5"));
    }
    if (!cursor.isNull(cursor.getColumnIndex("field6"))) {
        object.field6 = cursor.getDouble(cursor.getColumnIndex("field6"));
    }

    return object;
}
 
Example 10
Source File: AuthUserDao.java    From OpenHub with GNU General Public License v3.0 5 votes vote down vote up
@Override
public AuthUser readEntity(Cursor cursor, int offset) {
    AuthUser entity = new AuthUser( //
        cursor.getString(offset + 0), // accessToken
        new java.util.Date(cursor.getLong(offset + 1)), // authTime
        cursor.getInt(offset + 2), // expireIn
        cursor.getString(offset + 3), // scope
        cursor.getShort(offset + 4) != 0, // selected
        cursor.getString(offset + 5), // loginId
        cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // name
        cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // avatar
    );
    return entity;
}
 
Example 11
Source File: CursorHelper.java    From libcommon with Apache License 2.0 5 votes vote down vote up
public static short get(@Nullable final Cursor cursor,
	@NonNull final String columnName, final short defaultValue) {

	short result = defaultValue;
	if ((cursor != null) && !cursor.isClosed()) {
		try {
			result = cursor.getShort(cursor.getColumnIndexOrThrow(columnName));
		} catch (final Exception e) {
			if (DEBUG) Log.w(TAG, e);
		}
	}
	return result;
}
 
Example 12
Source File: MusicInfoDao.java    From SweetMusicPlayer with Apache License 2.0 5 votes vote down vote up
/** @inheritdoc */
@Override
public MusicInfo readEntity(Cursor cursor, int offset) {
    MusicInfo entity = new MusicInfo( //
        cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // songId
        cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // albumId
        cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2), // artistId
        cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title
        cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // artist
        cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5), // duration
        cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // path
        cursor.isNull(offset + 7) ? null : cursor.getShort(offset + 7) != 0 // favorite
    );
    return entity;
}
 
Example 13
Source File: MappingFactory.java    From Android-ORM with Apache License 2.0 5 votes vote down vote up
static Object getColumnValue(Cursor c, int index, int colType) {
    Object paramValue = null;
    if (MappingFactory.COL_INT == colType) {
        paramValue = c.getInt(index);
    }
    else if (MappingFactory.COL_LONG == colType) {
        paramValue = c.getLong(index);
    }
    else if (MappingFactory.COL_SHORT == colType) {
        paramValue = c.getShort(index);
    }
    else if (MappingFactory.COL_STRING == colType) {
        paramValue = c.getString(index);
    }
    else if (MappingFactory.COL_FLOAT == colType) {
        paramValue = c.getFloat(index);
    }
    else if (MappingFactory.COL_DOUBLE == colType) {
        paramValue = c.getDouble(index);
    }
    else if (MappingFactory.COL_BOOLEAN == colType) {
        int temp = c.getInt(index);
        paramValue = temp == 0 ? false : true;
    }
    else if (MappingFactory.COL_BLOB == colType) {
        paramValue = c.getBlob(index);
    }
    return paramValue;
}
 
Example 14
Source File: BoxedTypesPrivateFieldsIgnoreNullStorIOContentResolverGetResolver.java    From storio with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
@NonNull
public BoxedTypesPrivateFieldsIgnoreNull mapFromCursor(@NonNull StorIOContentResolver storIOContentResolver, @NonNull Cursor cursor) {

    Boolean field1 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field1"))) {
        field1 = cursor.getInt(cursor.getColumnIndex("field1")) == 1;
    }
    Short field2 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field2"))) {
        field2 = cursor.getShort(cursor.getColumnIndex("field2"));
    }
    Integer field3 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field3"))) {
        field3 = cursor.getInt(cursor.getColumnIndex("field3"));
    }
    Long field4 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field4"))) {
        field4 = cursor.getLong(cursor.getColumnIndex("field4"));
    }
    Float field5 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field5"))) {
        field5 = cursor.getFloat(cursor.getColumnIndex("field5"));
    }
    Double field6 = null;
    if (!cursor.isNull(cursor.getColumnIndex("field6"))) {
        field6 = cursor.getDouble(cursor.getColumnIndex("field6"));
    }

    BoxedTypesPrivateFieldsIgnoreNull object = new BoxedTypesPrivateFieldsIgnoreNull(field1, field2, field3, field4, field5, field6);

    return object;
}
 
Example 15
Source File: WordBeanDao.java    From Dictionary with Apache License 2.0 5 votes vote down vote up
@Override
public WordBean readEntity(Cursor cursor, int offset) {
    WordBean entity = new WordBean( //
        cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
        cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // name
        cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // en_sympol
        cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // am_symbol
        cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // en_mp3
        cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // am_mp3
        cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // groupName
        cursor.getShort(offset + 7) != 0 // done
    );
    return entity;
}
 
Example 16
Source File: BookSourceBeanDao.java    From HaoReader with GNU General Public License v3.0 4 votes vote down vote up
@Override
public BookSourceBean readEntity(Cursor cursor, int offset) {
    BookSourceBean entity = new BookSourceBean( //
        cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // bookSourceUrl
        cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // bookSourceName
        cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // bookSourceGroup
        cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // bookSourceType
        cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // bookSourceRuleType
        cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // checkUrl
        cursor.getInt(offset + 6), // serialNumber
        cursor.getInt(offset + 7), // weight
        cursor.isNull(offset + 8) ? null : cursor.getShort(offset + 8) != 0, // enable
        cursor.isNull(offset + 9) ? null : cursor.getShort(offset + 9) != 0, // enableFind
        cursor.isNull(offset + 10) ? null : cursor.getShort(offset + 10) != 0, // validFind
        cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // ruleFindUrl
        cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // ruleSearchUrl
        cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // ruleSearchList
        cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // ruleSearchName
        cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // ruleSearchAuthor
        cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // ruleSearchKind
        cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // ruleSearchLastChapter
        cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // ruleSearchIntroduce
        cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // ruleSearchCoverUrl
        cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // ruleSearchNoteUrl
        cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // ruleBookName
        cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // ruleBookAuthor
        cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // ruleBookLastChapter
        cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // ruleCoverUrl
        cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // ruleIntroduce
        cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26), // ruleChapterUrl
        cursor.isNull(offset + 27) ? null : cursor.getString(offset + 27), // ruleChapterUrlNext
        cursor.isNull(offset + 28) ? null : cursor.getString(offset + 28), // ruleChapterList
        cursor.isNull(offset + 29) ? null : cursor.getString(offset + 29), // ruleChapterName
        cursor.isNull(offset + 30) ? null : cursor.getString(offset + 30), // ruleContentUrl
        cursor.isNull(offset + 31) ? null : cursor.getString(offset + 31), // ruleContentUrlNext
        cursor.isNull(offset + 32) ? null : cursor.getString(offset + 32), // ruleBookContent
        cursor.isNull(offset + 33) ? null : cursor.getString(offset + 33), // rulePersistedVariables
        cursor.isNull(offset + 34) ? null : cursor.getString(offset + 34) // httpUserAgent
    );
    return entity;
}
 
Example 17
Source File: SqliteStorageManager.java    From gsn with GNU General Public License v3.0 4 votes vote down vote up
public ArrayList<StreamElement> executeQueryGetLatestValues(String tableName, int num, long minTimestamp) throws SQLException{

		Serializable[] fieldValues;
		DataField[] structure = tableToStructure(tableName);
		ArrayList<StreamElement> result = new ArrayList<StreamElement>();
		String query = "Select * from " + tableName + " where timed > " + minTimestamp + " order by _id desc limit ?";
		Cursor cursor = database.rawQuery(query, new String[]{num + ""});

		while (cursor.moveToNext()) {
			fieldValues = new Serializable[structure.length];
			for (int i = 0; i < structure.length; i++) {
				byte dtype = structure[i].getDataTypeID();
				String name = structure[i].getName().toLowerCase(Locale.ENGLISH);
				switch (dtype){
					case DataTypes.VARCHAR:
					case DataTypes.CHAR:
					case DataTypes.BINARY:
						fieldValues[i] = cursor.getString(cursor.getColumnIndex(name));
						break;
					case DataTypes.TIME:
					case DataTypes.BIGINT:
						fieldValues[i] = cursor.getLong(cursor.getColumnIndex(name));
						break;
					case DataTypes.DOUBLE:
						fieldValues[i] = cursor.getDouble(cursor.getColumnIndex(name));
						break;
					case DataTypes.FLOAT:
						fieldValues[i] = cursor.getFloat(cursor.getColumnIndex(name));
						break;
					case DataTypes.INTEGER:
						fieldValues[i] = cursor.getInt(cursor.getColumnIndex(name));
						break;
					case DataTypes.SMALLINT:
					case DataTypes.TINYINT:
						fieldValues[i] = cursor.getShort(cursor.getColumnIndex(name));
				}
			}
			long time = cursor.getLong(cursor.getColumnIndex("timed"));

			StreamElement se = new StreamElement(structure, fieldValues, time);
			result.add(se);
		}
		cursor.close();
		return result;
	}
 
Example 18
Source File: ShortType.java    From QuantumFlux with Apache License 2.0 4 votes vote down vote up
@Override
public Object getColumnValue(Cursor cursor, int columnIndex) {
    return cursor.getShort(columnIndex);
}
 
Example 19
Source File: DatabaseHandler.java    From TwistyTimer with GNU General Public License v3.0 4 votes vote down vote up
public boolean getBoolean(Cursor cursor, int columnIndex) {
    return ! (cursor.isNull(columnIndex) || cursor.getShort(columnIndex) == 0);
}
 
Example 20
Source File: ShortColumnConverter.java    From BigApp_Discuz_Android with Apache License 2.0 4 votes vote down vote up
@Override
public Short getFieldValue(final Cursor cursor, int index) {
    return cursor.isNull(index) ? null : cursor.getShort(index);
}