Methods Summary |
---|
public void | addRow(java.lang.Object[] columnValues)Adds a new row to the end with the given column values. Not safe
for concurrent use.
if (columnValues.length != columnCount) {
throw new IllegalArgumentException("columnNames.length = "
+ columnCount + ", columnValues.length = "
+ columnValues.length);
}
int start = rowCount++ * columnCount;
ensureCapacity(start + columnCount);
System.arraycopy(columnValues, 0, data, start, columnCount);
|
public void | addRow(java.lang.Iterable columnValues)Adds a new row to the end with the given column values. Not safe
for concurrent use.
int start = rowCount * columnCount;
int end = start + columnCount;
ensureCapacity(end);
if (columnValues instanceof ArrayList<?>) {
addRow((ArrayList<?>) columnValues, start);
return;
}
int current = start;
Object[] localData = data;
for (Object columnValue : columnValues) {
if (current == end) {
// TODO: null out row?
throw new IllegalArgumentException(
"columnValues.size() > columnNames.length");
}
localData[current++] = columnValue;
}
if (current != end) {
// TODO: null out row?
throw new IllegalArgumentException(
"columnValues.size() < columnNames.length");
}
// Increase row count here in case we encounter an exception.
rowCount++;
|
private void | addRow(java.util.ArrayList columnValues, int start)Optimization for {@link ArrayList}.
int size = columnValues.size();
if (size != columnCount) {
throw new IllegalArgumentException("columnNames.length = "
+ columnCount + ", columnValues.size() = " + size);
}
rowCount++;
Object[] localData = data;
for (int i = 0; i < size; i++) {
localData[start + i] = columnValues.get(i);
}
|
private void | ensureCapacity(int size)Ensures that this cursor has enough capacity.
if (size > data.length) {
Object[] oldData = this.data;
int newSize = data.length * 2;
if (newSize < size) {
newSize = size;
}
this.data = new Object[newSize];
System.arraycopy(oldData, 0, this.data, 0, oldData.length);
}
|
private java.lang.Object | get(int column)Gets value at the given column for the current row.
if (column < 0 || column >= columnCount) {
throw new CursorIndexOutOfBoundsException("Requested column: "
+ column + ", # of columns: " + columnCount);
}
if (mPos < 0) {
throw new CursorIndexOutOfBoundsException("Before first row.");
}
if (mPos >= rowCount) {
throw new CursorIndexOutOfBoundsException("After last row.");
}
return data[mPos * columnCount + column];
|
public byte[] | getBlob(int column)
Object value = get(column);
return (byte[]) value;
|
public java.lang.String[] | getColumnNames()
return columnNames;
|
public int | getCount()
return rowCount;
|
public double | getDouble(int column)
Object value = get(column);
if (value == null) return 0.0d;
if (value instanceof Number) return ((Number) value).doubleValue();
return Double.parseDouble(value.toString());
|
public float | getFloat(int column)
Object value = get(column);
if (value == null) return 0.0f;
if (value instanceof Number) return ((Number) value).floatValue();
return Float.parseFloat(value.toString());
|
public int | getInt(int column)
Object value = get(column);
if (value == null) return 0;
if (value instanceof Number) return ((Number) value).intValue();
return Integer.parseInt(value.toString());
|
public long | getLong(int column)
Object value = get(column);
if (value == null) return 0;
if (value instanceof Number) return ((Number) value).longValue();
return Long.parseLong(value.toString());
|
public short | getShort(int column)
Object value = get(column);
if (value == null) return 0;
if (value instanceof Number) return ((Number) value).shortValue();
return Short.parseShort(value.toString());
|
public java.lang.String | getString(int column)
Object value = get(column);
if (value == null) return null;
return value.toString();
|
public int | getType(int column)
return DatabaseUtils.getTypeOfObject(get(column));
|
public boolean | isNull(int column)
return get(column) == null;
|
public android.database.MatrixCursor$RowBuilder | newRow()Adds a new row to the end and returns a builder for that row. Not safe
for concurrent use.
final int row = rowCount++;
final int endIndex = rowCount * columnCount;
ensureCapacity(endIndex);
return new RowBuilder(row);
|