public static void cursorIntToContentValuesIfPresent(Cursor paramCursor, ContentValues paramContentValues, String paramString)
 {
   int i = paramCursor.getColumnIndex(paramString);
   if ((i != -1) && (!paramCursor.isNull(i))) {
     paramContentValues.put(paramString, Integer.valueOf(paramCursor.getInt(i)));
   }
 }
 /**
  * Reads a Integer out of a column in a Cursor and writes it to a ContentValues. Adds nothing to
  * the ContentValues if the column isn't present or if its value is null.
  *
  * @param cursor The cursor to read from
  * @param column The column to read
  * @param values The {@link ContentValues} to put the value into
  */
 public static void cursorIntToContentValuesIfPresent(
     Cursor cursor, ContentValues values, String column) {
   final int index = cursor.getColumnIndexOrThrow(column);
   if (!cursor.isNull(index)) {
     values.put(column, cursor.getInt(index));
   }
 }
 /**
  * Reads a Integer out of a field in a Cursor and writes it to a Map.
  *
  * @param cursor The cursor to read from
  * @param field The INTEGER field to read
  * @param values The {@link ContentValues} to put the value into, with the field as the key
  * @param key The key to store the value with in the map
  */
 public static void cursorIntToContentValues(
     Cursor cursor, String field, ContentValues values, String key) {
   int colIndex = cursor.getColumnIndex(field);
   if (!cursor.isNull(colIndex)) {
     values.put(key, cursor.getInt(colIndex));
   } else {
     values.put(key, (Integer) null);
   }
 }
  private static void construyeListaFiltros() {

    int tmpInt;
    String tmpString;

    listaFiltros = new ArrayList<DatosFiltro>();
    DatosFiltro fltAnio = new DatosFiltro("Año", "year");
    Cursor cr = getAniosDiferentes();

    while (cr.moveToNext()) {
      tmpInt = cr.getInt(0);
      tmpString = String.valueOf(tmpInt).trim();
      fltAnio.addValor(tmpInt, tmpString);
    }
    cr.close();

    listaFiltros.add(fltAnio);

    DatosFiltro fltMes = new DatosFiltro("Mes", "month");

    cr = getMesesDiferentes();

    while (cr.moveToNext()) {
      tmpInt = cr.getInt(0);
      tmpString = Utilidades.getNombreMes(tmpInt).trim();
      fltMes.addValor(tmpInt, tmpString);
    }
    cr.close();

    listaFiltros.add(fltMes);

    DatosFiltro fltTipoDeporte = new DatosFiltro("Tipo deporte", "sportType");

    cr = getTiposDeporteDiferentes();

    while (cr.moveToNext()) {
      tmpInt = cr.getInt(0);
      tmpString = Utilidades.getSportType(tmpInt).trim();
      fltTipoDeporte.addValor(tmpInt, tmpString);
    }
    cr.close();

    listaFiltros.add(fltTipoDeporte);
  }
 public static void cursorIntToContentValues(Cursor paramCursor, String paramString1, ContentValues paramContentValues, String paramString2)
 {
   int i = paramCursor.getColumnIndex(paramString1);
   if (!paramCursor.isNull(i))
   {
     paramContentValues.put(paramString2, Integer.valueOf(paramCursor.getInt(i)));
     return;
   }
   paramContentValues.put(paramString2, null);
 }
Exemple #6
0
 @Test
 public void testGetInt() throws Exception {
   List<Field.Type> types =
       Arrays.asList(Field.Type.TYPE_TINY, Field.Type.TYPE_SHORT, Field.Type.TYPE_INT24);
   for (Field.Type type : types) {
     try (Cursor cursor =
         new SimpleCursor(
             QueryResult.newBuilder()
                 .addFields(Field.newBuilder().setName("col0").setType(type).build())
                 .addRows(Row.newBuilder().addValues(ByteString.copyFromUtf8("12345")))
                 .build())) {
       cursor.next();
       Assert.assertEquals(12345, cursor.getInt("col0"));
     }
   }
 }