@Override public double getDouble(final int column) { return mQueueCursor.getDouble(column); }
@Override public double getDouble(int column) { return mCursor.getDouble(column); }
@Override public double getDouble(final int column) { return mQueueCursor.getDouble(column); }
@Override public double getDouble(int column) { return mCursor.getDouble(column); }
@Override public double getDouble(int columnIndex) { return mActiveCursor.getDouble(columnIndex); }
public void bind(Cursor cursor) { title.setText(cursor.getString(0)); value.setText(String.format("%g", cursor.getDouble(1))); } }
public void bind(Cursor cursor) { title.setText(cursor.getString(0)); value.setText(String.format("%g", cursor.getDouble(1))); } }
@Override @Implementation public double getDouble(int i) { return wrappedCursor.getDouble(i); }
private City getCityInfo(String city) { Cursor c = db.rawQuery("SELECT * from " + CITY_TABLE_NAME + " where city=?", new String[]{city}); if (c.moveToFirst()) { String province = c.getString(c.getColumnIndex("province")); String name = c.getString(c.getColumnIndex("city")); Double latitude = c.getDouble(c.getColumnIndex("latitude")); Double longitude = c.getDouble(c.getColumnIndex("longitude")); City item = new City(province, name, latitude, longitude); return item; } return null; }
public List<City> getAllCity() { List<City> list = new ArrayList<City>(); Cursor c = db.rawQuery("SELECT * from " + CITY_TABLE_NAME, null); while (c.moveToNext()) { String province = c.getString(c.getColumnIndex("province")); String city = c.getString(c.getColumnIndex("city")); Double latitude = c.getDouble(c.getColumnIndex("latitude")); Double longitude = c.getDouble(c.getColumnIndex("longitude")); City item = new City(province, city, latitude, longitude); list.add(item); } return list; }
public List<City> getAllCity() { List<City> list = new ArrayList<City>(); Cursor c = db.rawQuery("SELECT * from " + CITY_TABLE_NAME, null); while (c.moveToNext()) { String province = c.getString(c.getColumnIndex("province")); String city = c.getString(c.getColumnIndex("city")); Double latitude = c.getDouble(c.getColumnIndex("latitude")); Double longitude = c.getDouble(c.getColumnIndex("longitude")); City item = new City(province, city, latitude, longitude); list.add(item); } return list; }
@Override public SimpleEntityNotNull readEntity(Cursor cursor, int offset) { SimpleEntityNotNull entity = new SimpleEntityNotNull( // cursor.getLong(offset + 0), // id cursor.getShort(offset + 1) != 0, // simpleBoolean (byte) cursor.getShort(offset + 2), // simpleByte cursor.getShort(offset + 3), // simpleShort cursor.getInt(offset + 4), // simpleInt cursor.getLong(offset + 5), // simpleLong cursor.getFloat(offset + 6), // simpleFloat cursor.getDouble(offset + 7), // simpleDouble cursor.getString(offset + 8), // simpleString cursor.getBlob(offset + 9) // simpleByteArray ); return entity; }
@Test public void testGetDouble() throws Exception { assertThat(cursor.moveToFirst()).isTrue(); assertThat(cursor.getDouble(4)).isEqualTo(3.14159); }
@Override public void readEntity(Cursor cursor, SimpleEntityNotNull entity, int offset) { entity.setId(cursor.getLong(offset + 0)); entity.setSimpleBoolean(cursor.getShort(offset + 1) != 0); entity.setSimpleByte((byte) cursor.getShort(offset + 2)); entity.setSimpleShort(cursor.getShort(offset + 3)); entity.setSimpleInt(cursor.getInt(offset + 4)); entity.setSimpleLong(cursor.getLong(offset + 5)); entity.setSimpleFloat(cursor.getFloat(offset + 6)); entity.setSimpleDouble(cursor.getDouble(offset + 7)); entity.setSimpleString(cursor.getString(offset + 8)); entity.setSimpleByteArray(cursor.getBlob(offset + 9)); }
@Test public void testGetNumbersFromBlobField() throws Exception { database.execSQL("update table_name set name = '1.2'"); assertThat(cursor.moveToFirst()).isTrue(); assertThat(cursor.getInt(1)).isEqualTo(1); assertThat(cursor.getDouble(1)).isEqualTo(1.2d); assertThat(cursor.getFloat(1)).isEqualTo(1.2f); }
@Test public void testGetNumbersFromStringField() throws Exception { database.execSQL("update table_name set name = '1.2'"); assertThat(cursor.moveToFirst()).isTrue(); assertThat(cursor.getInt(1)).isEqualTo(1); assertThat(cursor.getDouble(1)).isEqualTo(1.2d); assertThat(cursor.getFloat(1)).isEqualTo(1.2f); }
protected Computer getComputer(long id) { Computer computer = null; Cursor cursor = Connector.getDatabase().query(getTableName(Computer.class), null, "id = ?", new String[] { String.valueOf(id) }, null, null, null); if (cursor.moveToFirst()) { computer = new Computer("", 0); double newPrice = cursor.getDouble(cursor.getColumnIndexOrThrow("price")); String brand = cursor.getString(cursor.getColumnIndexOrThrow("brand")); computer.setBrand(brand); computer.setPrice(newPrice); } cursor.close(); return computer; }
@Override public SimpleEntity readEntity(Cursor cursor, int offset) { SimpleEntity entity = new SimpleEntity( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id cursor.isNull(offset + 1) ? null : cursor.getShort(offset + 1) != 0, // simpleBoolean cursor.isNull(offset + 2) ? null : (byte) cursor.getShort(offset + 2), // simpleByte cursor.isNull(offset + 3) ? null : cursor.getShort(offset + 3), // simpleShort cursor.isNull(offset + 4) ? null : cursor.getInt(offset + 4), // simpleInt cursor.isNull(offset + 5) ? null : cursor.getLong(offset + 5), // simpleLong cursor.isNull(offset + 6) ? null : cursor.getFloat(offset + 6), // simpleFloat cursor.isNull(offset + 7) ? null : cursor.getDouble(offset + 7), // simpleDouble cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // simpleString cursor.isNull(offset + 9) ? null : cursor.getBlob(offset + 9) // simpleByteArray ); return entity; }
@Test public void testGetNullNumberValues() throws Exception { String sql = "UPDATE table_name set long_value=NULL, float_value=NULL, double_value=NULL"; database.execSQL(sql); assertThat(cursor.moveToFirst()).isTrue(); assertThat(cursor.getType(2)).isEqualTo(Cursor.FIELD_TYPE_NULL); assertThat(cursor.getLong(2)).isEqualTo(0); assertThat(cursor.getType(3)).isEqualTo(Cursor.FIELD_TYPE_NULL); assertThat(cursor.getFloat(3)).isEqualTo(0f); assertThat(cursor.getType(4)).isEqualTo(Cursor.FIELD_TYPE_NULL); assertThat(cursor.getDouble(4)).isEqualTo(0d); }
@Override public void readEntity(Cursor cursor, SimpleEntity entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); entity.setSimpleBoolean(cursor.isNull(offset + 1) ? null : cursor.getShort(offset + 1) != 0); entity.setSimpleByte(cursor.isNull(offset + 2) ? null : (byte) cursor.getShort(offset + 2)); entity.setSimpleShort(cursor.isNull(offset + 3) ? null : cursor.getShort(offset + 3)); entity.setSimpleInt(cursor.isNull(offset + 4) ? null : cursor.getInt(offset + 4)); entity.setSimpleLong(cursor.isNull(offset + 5) ? null : cursor.getLong(offset + 5)); entity.setSimpleFloat(cursor.isNull(offset + 6) ? null : cursor.getFloat(offset + 6)); entity.setSimpleDouble(cursor.isNull(offset + 7) ? null : cursor.getDouble(offset + 7)); entity.setSimpleString(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); entity.setSimpleByteArray(cursor.isNull(offset + 9) ? null : cursor.getBlob(offset + 9)); }