/**
* Gets column value by index.
*
* @param index starts with zero
* @return a int data from the database
* @throws IOException
*/
public int getInteger(int index)throws IOException;
/**
* Gets column value by index.
*
* @param index starts with zero
* @return a long data from the database
* @throws IOException
*/
public long getLong(int index)throws IOException;
--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/2fb942eb-aec7-40a1-902a-d20e5781ce43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
/** * Fills a map with the data of the current row of database Cursor * * @param c * The database cursor from a query. * @param m * The map to fill. * @throws IOException */ protected void fillMap(Cursor c, Map m) throws IOException { Row row = c.getRow(); int len = c.getColumnCount(); for (int i = 0; i < len; i++) {
String colName = c.getColumnName(i); ColType colType = colTypes.get(colName);
if (colType == null) { continue; } switch (colType) { case FLOAT: if (isNotNullValue(row, i)) m.put(colName, row.getFloat(i)); break; case DOUBLE: if (isNotNullValue(row, i)) m.put(colName, row.getDouble(i)); break; case BLOB: m.put(colName, row.getBlob(i)); break; case STRING: case VARCHAR: m.put(colName, row.getString(i)); break; case INTEGER: if ("id".equals(colName) || colName.startsWith("id")) { // if it's the object's id or foreign key id m.put(colName, row.getLong(i)); } else { if (isNotNullValue(row, i)) m.put(colName, row.getInteger(i)); } break; case LONG: if (isNotNullValue(row, i)) m.put(colName, row.getLong(i)); break; case SHORT: if (isNotNullValue(row, i)) m.put(colName, row.getShort(i)); break; default: }
} }
private boolean isNotNullValue(Row row, int ind) throws IOException { return !"null".equals(row.getString(ind));
}map.get("my_value_key"); if (params[i] == null) {
strParams[i] = null;
} else {
strParams[i] = params[i].toString();
}
/** * Gets generic insert args for insert statement for the given map of row data. * * @param m * Map containing row data to insert. Maps column names to column values. * @return Object[] array that can be used in Database.execute() * */ private Object[] insertArgs(Map m) { List largs = new ArrayList(); for (Map.Entry<String, ColType> e : colTypes.entrySet()) { if ("id".equals(e.getKey()) && m.get("id") == null) { continue; } if ("id".equals(e.getKey()) && NumberUtil.longValue(m.get("id")) <= 0) { continue; } largs.add("" + m.get(e.getKey())); }
return largs.toArray(); }