当前位置: 首页>>代码示例>>Java>>正文


Java Cursor.FIELD_TYPE_FLOAT属性代码示例

本文整理汇总了Java中android.database.Cursor.FIELD_TYPE_FLOAT属性的典型用法代码示例。如果您正苦于以下问题:Java Cursor.FIELD_TYPE_FLOAT属性的具体用法?Java Cursor.FIELD_TYPE_FLOAT怎么用?Java Cursor.FIELD_TYPE_FLOAT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.database.Cursor的用法示例。


在下文中一共展示了Cursor.FIELD_TYPE_FLOAT属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getObject

static Object getObject(Cursor cursor, int columnIndex) throws Exception
{
    int type = getType(cursor, columnIndex);
    Object value;
    switch (type)
    {
        case Cursor.FIELD_TYPE_BLOB:
            value = cursor.getBlob(columnIndex);
            break;
        case Cursor.FIELD_TYPE_FLOAT:
            value = cursor.getFloat(columnIndex);
            break;
        case Cursor.FIELD_TYPE_INTEGER:
            value = cursor.getLong(columnIndex);
            break;
        case Cursor.FIELD_TYPE_NULL:
            value = null;
            break;
        case Cursor.FIELD_TYPE_STRING:
            value = cursor.getString(columnIndex);
            break;
        default:
            value = cursor.getString(columnIndex);
    }
    return value;
}
 
开发者ID:gzxishan,项目名称:OftenPorter,代码行数:26,代码来源:TypeUtil.java

示例2: ListRow

public ListRow(OModel model, Cursor cursor) {
    this.baseModel = model;
    for (String column : cursor.getColumnNames()) {
        int index = cursor.getColumnIndex(column);
        switch (cursor.getType(index)) {
            case Cursor.FIELD_TYPE_INTEGER:
                put(column, cursor.getInt(index));
                break;
            case Cursor.FIELD_TYPE_BLOB:
                put(column, cursor.getBlob(index));
                break;
            case Cursor.FIELD_TYPE_STRING:
                put(column, cursor.getString(index));
                break;
            case Cursor.FIELD_TYPE_FLOAT:
                put(column, cursor.getFloat(index));
                break;
            case Cursor.FIELD_TYPE_NULL:
                put(column, false);
                break;
        }
    }
}
 
开发者ID:odoo-mobile-intern,项目名称:odoo-work,代码行数:23,代码来源:ListRow.java

示例3: _dumpColumns

private void _dumpColumns(Cursor cursor, String msg) {
	String[] columns = new String[cursor.getColumnCount()];
	for (int i = 0; i < cursor.getColumnCount(); i++)
		switch (cursor.getType(i)) {
		case Cursor.FIELD_TYPE_NULL:
			columns[i] = null;
			break;
		case Cursor.FIELD_TYPE_INTEGER:
			columns[i] = Integer.toString(cursor.getInt(i));
			break;
		case Cursor.FIELD_TYPE_FLOAT:
			columns[i] = Float.toString(cursor.getFloat(i));
			break;
		case Cursor.FIELD_TYPE_STRING:
			columns[i] = cursor.getString(i);
			break;
		case Cursor.FIELD_TYPE_BLOB:
			columns[i] = "[blob]";
			break;
		default:
			Util.log(this, Log.WARN, "Unknown cursor data type=" + cursor.getType(i));
		}
	Util.log(this, Log.WARN, TextUtils.join(", ", columns) + " " + msg);
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:24,代码来源:XContentResolver.java

示例4: get

/**
 * Returns an Object of the column. The receiving end is responsible for
 * casting back to a correct data type.
 *
 * An Object with larger data type will be returned in case of floating point
 * and integer numbers. I.e. they return doubles and longs respectively.
 *
 * @param columnName Name of the column within the cursor to get.
 * @return Object with the contents of the column.
 */
public Object get(String columnName) {
    int columnIndex = mCursor.getColumnIndex(columnName);
    int type = mCursor.getType(columnIndex);

    switch (type) {
        case Cursor.FIELD_TYPE_FLOAT:
            return mCursor.getDouble(columnIndex);
        case Cursor.FIELD_TYPE_INTEGER:
            return mCursor.getLong(columnIndex);
        case Cursor.FIELD_TYPE_STRING:
            return mCursor.getString(columnIndex);
        case Cursor.FIELD_TYPE_NULL:
        default:
            return null;
    }
}
 
开发者ID:zak0,项目名称:AppTycoon,代码行数:26,代码来源:LocalDatabaseHelper.java

示例5: getType

private static int getType(Cursor cursor, int columnIndex) throws Exception
{

    if (Build.VERSION.SDK_INT >= 11)
    {
        return cursor.getType(columnIndex);
    }

    SQLiteCursor sqLiteCursor = (SQLiteCursor) cursor;
    CursorWindow cursorWindow = sqLiteCursor.getWindow();
    int pos = cursor.getPosition();
    int type = -1;
    if (cursorWindow.isNull(pos, columnIndex))
    {
        type = Cursor.FIELD_TYPE_NULL;
    } else if (cursorWindow.isLong(pos, columnIndex))
    {
        type = Cursor.FIELD_TYPE_INTEGER;
    } else if (cursorWindow.isFloat(pos, columnIndex))
    {
        type = Cursor.FIELD_TYPE_FLOAT;
    } else if (cursorWindow.isString(pos, columnIndex))
    {
        type = Cursor.FIELD_TYPE_STRING;
    } else if (cursorWindow.isBlob(pos, columnIndex))
    {
        type = Cursor.FIELD_TYPE_BLOB;
    }

    return type;
}
 
开发者ID:gzxishan,项目名称:OftenPorter,代码行数:31,代码来源:TypeUtil.java

示例6: getTypeOfObject

public static int getTypeOfObject(Object obj) {
    if (obj == null) {
        return Cursor.FIELD_TYPE_NULL;
    } else if (obj instanceof byte[]) {
        return Cursor.FIELD_TYPE_BLOB;
    } else if (obj instanceof Float || obj instanceof Double) {
        return Cursor.FIELD_TYPE_FLOAT;
    } else if (obj instanceof Long || obj instanceof Integer
            || obj instanceof Short || obj instanceof Byte) {
        return Cursor.FIELD_TYPE_INTEGER;
    } else {
        return Cursor.FIELD_TYPE_STRING;
    }
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:14,代码来源:DataBaseUtils.java

示例7: cursor2Map

public static Map<String, Object> cursor2Map(Cursor cursor) {
    Map<String, Object> map = new HashMap<>();
    if (cursor != null && cursor.getColumnCount() > 0) {
        int count = cursor.getColumnCount();
        for (int i = 0; i < count; i++) {
            int type = cursor.getType(i);

            Object value = null;
            switch (type) {
                case Cursor.FIELD_TYPE_STRING:
                    value = cursor.getString(i);
                    break;
                case Cursor.FIELD_TYPE_INTEGER:
                    value = cursor.getInt(i);
                    break;
                case Cursor.FIELD_TYPE_FLOAT:
                    value = cursor.getFloat(i);
                    break;
                case Cursor.FIELD_TYPE_NULL:
                    LogUtils.d("未知的参数类型,type:" + type);
                    break;
                case Cursor.FIELD_TYPE_BLOB:
                    LogUtils.d("未知的参数类型,type:" + type);
                    break;
            }
            if (value != null) {
                String name = cursor.getColumnName(i);
                map.put(name, value);
            }
        }
    }
    return map;
}
 
开发者ID:jessie345,项目名称:RetrofitAppArchitecture,代码行数:33,代码来源:Utils.java

示例8: copyColumns

private void copyColumns(Cursor cursor, MatrixCursor result, int count) {
	try {
		Object[] columns = new Object[count];
		for (int i = 0; i < count; i++)
			switch (cursor.getType(i)) {
			case Cursor.FIELD_TYPE_NULL:
				columns[i] = null;
				break;
			case Cursor.FIELD_TYPE_INTEGER:
				columns[i] = cursor.getInt(i);
				break;
			case Cursor.FIELD_TYPE_FLOAT:
				columns[i] = cursor.getFloat(i);
				break;
			case Cursor.FIELD_TYPE_STRING:
				columns[i] = cursor.getString(i);
				break;
			case Cursor.FIELD_TYPE_BLOB:
				columns[i] = cursor.getBlob(i);
				break;
			default:
				Util.log(this, Log.WARN, "Unknown cursor data type=" + cursor.getType(i));
			}
		result.addRow(columns);
	} catch (Throwable ex) {
		Util.bug(this, ex);
	}
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:28,代码来源:XContentResolver.java

示例9: log

private static void log(final Cursor cursor) {
    if (cursor != null) {
        if (cursor.getCount() > 0) {
            L.e("----------------------start--------------------");
            L.i("数量:" + cursor.getCount() + " 列数:" + cursor.getColumnCount());
            if (cursor.moveToFirst()) {
                do {
                    for (int i = 0; i < cursor.getColumnCount(); i++) {
                        final String columnName = cursor.getColumnName(i);
                        final int columnIndex = cursor.getColumnIndex(columnName);
                        final int type = cursor.getType(columnIndex);
                        String data = "", ty = "";
                        if (type == Cursor.FIELD_TYPE_NULL) {
                            ty = "NULL";
                            data = "空值";
                        } else if (type == Cursor.FIELD_TYPE_BLOB) {
                            ty = "BLOB";
                            final byte[] bytes = cursor.getBlob(columnIndex);
                            data = String.valueOf(bytes) + " " + bytes.length * 1f / 1024f + "KB";
                        } else if (type == Cursor.FIELD_TYPE_FLOAT) {
                            ty = "FLOAT";
                            data = String.valueOf(cursor.getFloat(columnIndex));
                        } else if (type == Cursor.FIELD_TYPE_INTEGER) {
                            ty = "INTEGER";
                            data = String.valueOf(cursor.getInt(columnIndex));
                        } else if (type == FIELD_TYPE_STRING) {
                            ty = "STRING";
                            data = cursor.getString(columnIndex);
                        }

                        L.i("第" + i + "列->名称:" + columnName + " 索引:" + columnIndex + " 类型:" + ty + " 值:" + data);
                    }
                } while (cursor.moveToNext());
            }
            L.e("------------------------end---------------------");
        }
        cursor.close();
    }
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:39,代码来源:ContactsPickerHelper.java

示例10: dumpCursor

/**
 * Useful for debugging during development, so that arbitrary queries can be made, and their
 * results inspected in the debugger.
 */
@SuppressWarnings("unused")
@RequiresApi(api = 11)
public static List<Map<String, String>> dumpCursor(Cursor cursor) {
    List<Map<String, String>> data = new ArrayList<>();

    if (cursor == null) {
        return data;
    }

    cursor.moveToFirst();
    while (!cursor.isAfterLast()) {
        Map<String, String> row = new HashMap<>(cursor.getColumnCount());
        for (String col : cursor.getColumnNames()) {
            int i = cursor.getColumnIndex(col);
            switch (cursor.getType(i)) {
                case Cursor.FIELD_TYPE_NULL:
                    row.put(col, null);
                    break;

                case Cursor.FIELD_TYPE_INTEGER:
                    row.put(col, Integer.toString(cursor.getInt(i)));
                    break;

                case Cursor.FIELD_TYPE_FLOAT:
                    row.put(col, Double.toString(cursor.getFloat(i)));
                    break;

                case Cursor.FIELD_TYPE_STRING:
                    row.put(col, cursor.getString(i));
                    break;

                case Cursor.FIELD_TYPE_BLOB:
                    row.put(col, new String(cursor.getBlob(i), Charset.defaultCharset()));
                    break;
            }
        }
        data.add(row);
        cursor.moveToNext();
    }

    cursor.close();
    return data;
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:47,代码来源:Utils.java

示例11: processCollectedSensorData

@WorkerThread
void processCollectedSensorData() throws JSONException {
    if (mPublisher == null || !mPublisher.isReady()) {
        return;
    }

    // Query the data we wish to push to the cloud
    long lastSyndId = DatalogDbHelper.getLastSyncId(this);
    Cursor cursor = mDatabase.query(DatalogDbHelper.TABLE_NAME,
            null,
            DatalogDbHelper.DatalogEntry._ID + " > " + lastSyndId,
            null,
            null,
            null,
            BaseColumns._ID + " ASC");
    Log.i(TAG, "publishing " + cursor.getCount() + " log entries");

    final int columnCount = cursor.getColumnCount();
    for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
        JSONObject entryObject = new JSONObject();
        // Add the device ID to the JSON record.
        //
        // FIXME: There should be a way to get Google Cloud IOT to do this on its
        // end, so I don't need to trust the IDs.
        entryObject.put("deviceId", mDeviceId);
        long id = 0;
        for (int i = 0; i < columnCount; i++) {
            String columnName = cursor.getColumnName(i);
            if (columnName != null) {
                // Note the most recent ID we've transmitted, but don't include
                // the ID column in the JSON message
                if (columnName.equals(BaseColumns._ID)) {
                    id = cursor.getLong(i);
                    continue;
                }
                if (cursor.getType(i) == Cursor.FIELD_TYPE_FLOAT) {
                    entryObject.put(columnName, cursor.getDouble(i));
                } else {
                    entryObject.put(columnName, cursor.getString(i));
                }
            }
        }
        // Push message to the cloud
        mPublisher.publish(entryObject.toString());
        Log.d(TAG, "Sent entry: " + (cursor.getPosition()+1) + "/" +
                cursor.getCount());
        if (id > lastSyndId)
            DatalogDbHelper.setLastSyncId(this, id);
    }
    cursor.close();
}
 
开发者ID:jpuderer,项目名称:Taxi-Datalogger,代码行数:51,代码来源:CloudPublisherService.java

示例12: query

@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
        String sortOrder) {
    Uri fileUri = getFileUriWhenReady(uri);
    if (fileUri == null) return null;

    // Workaround for a bad assumption that particular MediaStore columns exist by certain third
    // party applications.
    // http://crbug.com/467423.
    Cursor source = super.query(fileUri, projection, selection, selectionArgs, sortOrder);

    String[] columnNames = source.getColumnNames();
    String[] newColumnNames = columnNamesWithData(columnNames);
    if (columnNames == newColumnNames) return source;

    MatrixCursor cursor = new MatrixCursor(newColumnNames, source.getCount());

    source.moveToPosition(-1);
    while (source.moveToNext()) {
        MatrixCursor.RowBuilder row = cursor.newRow();
        for (int i = 0; i < columnNames.length; i++) {
            switch (source.getType(i)) {
                case Cursor.FIELD_TYPE_INTEGER:
                    row.add(source.getInt(i));
                    break;
                case Cursor.FIELD_TYPE_FLOAT:
                    row.add(source.getFloat(i));
                    break;
                case Cursor.FIELD_TYPE_STRING:
                    row.add(source.getString(i));
                    break;
                case Cursor.FIELD_TYPE_BLOB:
                    row.add(source.getBlob(i));
                    break;
                case Cursor.FIELD_TYPE_NULL:
                default:
                    row.add(null);
                    break;
            }
        }
    }

    source.close();
    return cursor;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:45,代码来源:ChromeFileProvider.java


注:本文中的android.database.Cursor.FIELD_TYPE_FLOAT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。