コード例 #1
0
  public static ContentValues deflate(TableDetails tableDetails, Object dataModelObject) {
    List<TableDetails.ColumnDetails> columns = tableDetails.getColumns();
    ContentValues contentValues = new ContentValues(columns.size());

    for (int i = 0; i < columns.size(); i++) {
      TableDetails.ColumnDetails columnDetails = columns.get(i);

      if (columnDetails.isAutoIncrement()) continue;

      try {
        columnDetails.setContentValue(contentValues, dataModelObject);
      } catch (IllegalAccessException e) {
        throw new QuantumFluxException(
            "Unable to access protected field, change the access level: "
                + columnDetails.getColumnName());
      }
    }

    return contentValues;
  }
コード例 #2
0
  public static ContentValues[] deflateAll(TableDetails tableDetails, Object... dataModelObjects) {
    List<TableDetails.ColumnDetails> columns = tableDetails.getColumns();
    ContentValues[] contentValuesArray = new ContentValues[dataModelObjects.length];
    for (int i = 0; i < dataModelObjects.length; i++) {
      contentValuesArray[i] = new ContentValues(columns.size());
    }

    for (int i = 0; i < columns.size(); i++) {
      TableDetails.ColumnDetails columnDetails = columns.get(i);

      if (columnDetails.isAutoIncrement()) continue;

      for (int j = 0; j < dataModelObjects.length; j++) {
        try {
          columnDetails.setContentValue(contentValuesArray[j], dataModelObjects[j]);
        } catch (IllegalAccessException e) {
          throw new QuantumFluxException(
              "Unable to access protected field, change the access level: "
                  + columnDetails.getColumnName());
        }
      }
    }
    return contentValuesArray;
  }