本文整理汇总了Java中io.realm.RealmFieldType类的典型用法代码示例。如果您正苦于以下问题:Java RealmFieldType类的具体用法?Java RealmFieldType怎么用?Java RealmFieldType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RealmFieldType类属于io.realm包,在下文中一共展示了RealmFieldType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addColumn
import io.realm.RealmFieldType; //导入依赖的package包/类
/**
* Adds a column to the table dynamically.
*
* @param type the column type.
* @param name the field/column name.
* @param isNullable {@code true} if column can contain null values, {@code false} otherwise.
* @return the index of the new column.
*/
public long addColumn(RealmFieldType type, String name, boolean isNullable) {
verifyColumnName(name);
switch (type) {
case INTEGER:
case BOOLEAN:
case STRING:
case BINARY:
case DATE:
case FLOAT:
case DOUBLE:
return nativeAddColumn(nativePtr, type.getNativeValue(), name, isNullable);
case INTEGER_LIST:
case BOOLEAN_LIST:
case STRING_LIST:
case BINARY_LIST:
case DATE_LIST:
case FLOAT_LIST:
case DOUBLE_LIST:
return nativeAddPrimitiveListColumn(nativePtr, type.getNativeValue() - 128, name, isNullable);
default:
throw new IllegalArgumentException("Unsupported type: " + type);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:34,代码来源:Table.java
示例2: getInstance
import io.realm.RealmFieldType; //导入依赖的package包/类
private static SortDescriptor getInstance(
FieldDescriptor.SchemaProxy proxy,
Table table,
String[] fieldDescriptions,
@Nullable Sort[] sortOrders,
Set<RealmFieldType> legalInternalTypes,
Set<RealmFieldType> legalTerminalTypes,
String message) {
//noinspection ConstantConditions
if (fieldDescriptions == null || fieldDescriptions.length == 0) {
throw new IllegalArgumentException("You must provide at least one field name.");
}
long[][] columnIndices = new long[fieldDescriptions.length][];
// Force aggressive parsing of the FieldDescriptors, so that only valid SortDescriptor objects are created.
for (int i = 0; i < fieldDescriptions.length; i++) {
FieldDescriptor descriptor = FieldDescriptor.createFieldDescriptor(proxy, table, fieldDescriptions[i], legalInternalTypes, null);
checkFieldType(descriptor, legalTerminalTypes, message, fieldDescriptions[i]);
columnIndices[i] = descriptor.getColumnIndices();
}
return new SortDescriptor(table, columnIndices, sortOrders);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:SortDescriptor.java
示例3: createWithPrimaryKey
import io.realm.RealmFieldType; //导入依赖的package包/类
/**
* Create an object in the given table which has a primary key column defined, and set the primary key with given
* value.
*
* @param table the table where the object is created. This table must be atached to {@link OsSharedRealm}.
* @return a newly created {@code UncheckedRow}.
*/
public static UncheckedRow createWithPrimaryKey(Table table, @Nullable Object primaryKeyValue) {
long primaryKeyColumnIndex = getAndVerifyPrimaryKeyColumnIndex(table);
RealmFieldType type = table.getColumnType(primaryKeyColumnIndex);
final OsSharedRealm sharedRealm = table.getSharedRealm();
if (type == RealmFieldType.STRING) {
if (primaryKeyValue != null && !(primaryKeyValue instanceof String)) {
throw new IllegalArgumentException("Primary key value is not a String: " + primaryKeyValue);
}
return new UncheckedRow(sharedRealm.context, table,
nativeCreateNewObjectWithStringPrimaryKey(sharedRealm.getNativePtr(), table.getNativePtr(),
primaryKeyColumnIndex, (String) primaryKeyValue));
} else if (type == RealmFieldType.INTEGER) {
long value = primaryKeyValue == null ? 0 : Long.parseLong(primaryKeyValue.toString());
return new UncheckedRow(sharedRealm.context, table,
nativeCreateNewObjectWithLongPrimaryKey(sharedRealm.getNativePtr(), table.getNativePtr(),
primaryKeyColumnIndex, value, primaryKeyValue == null));
} else {
throw new RealmException("Cannot check for duplicate rows for unsupported primary key type: " + type);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:OsObject.java
示例4: createRowWithPrimaryKey
import io.realm.RealmFieldType; //导入依赖的package包/类
/**
* Create an object in the given table which has a primary key column defined, and set the primary key with given
* value.
* This is used for the fast bulk insertion.
*
* @param table the table where the object is created.
* @param primaryKeyColumnIndex the column index of primary key field.
* @param primaryKeyValue the primary key value.
* @return a newly created {@code UncheckedRow}.
*/
// FIXME: Proxy could just pass the pk index here which is much faster.
public static long createRowWithPrimaryKey(Table table, long primaryKeyColumnIndex, Object primaryKeyValue) {
RealmFieldType type = table.getColumnType(primaryKeyColumnIndex);
final OsSharedRealm sharedRealm = table.getSharedRealm();
if (type == RealmFieldType.STRING) {
if (primaryKeyValue != null && !(primaryKeyValue instanceof String)) {
throw new IllegalArgumentException("Primary key value is not a String: " + primaryKeyValue);
}
return nativeCreateRowWithStringPrimaryKey(sharedRealm.getNativePtr(), table.getNativePtr(),
primaryKeyColumnIndex, (String) primaryKeyValue);
} else if (type == RealmFieldType.INTEGER) {
long value = primaryKeyValue == null ? 0 : Long.parseLong(primaryKeyValue.toString());
return nativeCreateRowWithLongPrimaryKey(sharedRealm.getNativePtr(), table.getNativePtr(),
primaryKeyColumnIndex, value, primaryKeyValue == null);
} else {
throw new RealmException("Cannot check for duplicate rows for unsupported primary key type: " + type);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:31,代码来源:OsObject.java
示例5: getInstanceForDistinct_multipleFields
import io.realm.RealmFieldType; //导入依赖的package包/类
@Test
public void getInstanceForDistinct_multipleFields() {
RealmFieldType stringType = RealmFieldType.STRING;
long stringColumn = table.addColumn(stringType, stringType.name());
table.addSearchIndex(stringColumn);
RealmFieldType intType = RealmFieldType.INTEGER;
long intColumn = table.addColumn(intType, intType.name());
table.addSearchIndex(intColumn);
SortDescriptor sortDescriptor = SortDescriptor.getInstanceForDistinct(null, table, new String[] {
stringType.name(), intType.name()});
assertEquals(2, sortDescriptor.getColumnIndices().length);
assertNull(sortDescriptor.getAscendings());
assertEquals(1, sortDescriptor.getColumnIndices()[0].length);
assertEquals(stringColumn, sortDescriptor.getColumnIndices()[0][0]);
assertEquals(1, sortDescriptor.getColumnIndices()[1].length);
assertEquals(intColumn, sortDescriptor.getColumnIndices()[1][0]);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:SortDescriptorTests.java
示例6: getInstanceForSort_multipleFields
import io.realm.RealmFieldType; //导入依赖的package包/类
@Test
public void getInstanceForSort_multipleFields() {
RealmFieldType stringType = RealmFieldType.STRING;
long stringColumn = table.addColumn(stringType, stringType.name());
RealmFieldType intType = RealmFieldType.INTEGER;
long intColumn = table.addColumn(intType, intType.name());
SortDescriptor sortDescriptor = SortDescriptor.getInstanceForSort(null, table, new String[] {
stringType.name(), intType.name()}, new Sort[] {Sort.ASCENDING, Sort.DESCENDING});
assertEquals(2, sortDescriptor.getAscendings().length);
assertEquals(2, sortDescriptor.getColumnIndices().length);
assertEquals(1, sortDescriptor.getColumnIndices()[0].length);
assertEquals(stringColumn, sortDescriptor.getColumnIndices()[0][0]);
assertTrue(sortDescriptor.getAscendings()[0]);
assertEquals(1, sortDescriptor.getColumnIndices()[1].length);
assertEquals(intColumn, sortDescriptor.getColumnIndices()[1][0]);
assertFalse(sortDescriptor.getAscendings()[1]);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:SortDescriptorTests.java
示例7: getRealmRowIdentifier
import io.realm.RealmFieldType; //导入依赖的package包/类
private String getRealmRowIdentifier(int realmIndex, HashMap<Long, RealmFieldType> columnIndexRealmFieldTypeHashMap) {
String rowIdentifier = "";
RealmObjectProxy proxy = (RealmObjectProxy) adapterData.get(realmIndex);
Row row = proxy.realmGet$proxyState().getRow$realm();
for (Entry<Long, RealmFieldType> entry : columnIndexRealmFieldTypeHashMap.entrySet()) {
switch (entry.getValue()) {
case STRING:
rowIdentifier += row.getString(entry.getKey());
break;
case INTEGER:
rowIdentifier += String.valueOf(row.getLong(entry.getKey()));
break;
case BOOLEAN:
rowIdentifier += String.valueOf(row.getBoolean(entry.getKey()));
break;
default:
throw new IllegalStateException("Unsupported RealmFieldType, use only STRING, INTEGER or BOOLEAN field types");
}
}
return rowIdentifier;
}
开发者ID:Incuube,项目名称:Hyber-SDK-Android,代码行数:24,代码来源:RealmRecyclerViewAdapter.java
示例8: buildEntryFromResultObject
import io.realm.RealmFieldType; //导入依赖的package包/类
@Override
public BarEntry buildEntryFromResultObject(T realmObject, int xIndex) {
DynamicRealmObject dynamicObject = new DynamicRealmObject(realmObject);
if (dynamicObject.getFieldType(mValuesField) == RealmFieldType.LIST) {
RealmList<DynamicRealmObject> list = dynamicObject.getList(mValuesField);
float[] values = new float[list.size()];
int i = 0;
for (DynamicRealmObject o : list) {
values[i] = o.getFloat(mStackValueFieldName);
i++;
}
return new BarEntry(values,
mIndexField == null ? xIndex : dynamicObject.getInt(mIndexField));
} else {
float value = dynamicObject.getFloat(mValuesField);
return new BarEntry(value,
mIndexField == null ? xIndex : dynamicObject.getInt(mIndexField));
}
}
开发者ID:pencil-box,项目名称:NetKnight,代码行数:24,代码来源:RealmBarDataSet.java
示例9: createContent
import io.realm.RealmFieldType; //导入依赖的package包/类
private ArrayList<ArrayList<String>> createContent() {
int row = mItens.size();
int column = mTable.getColumns().size();
ArrayList<ArrayList<String>> results = new ArrayList<>();
for (int i = 0; i < row; i++) {
ArrayList<String> strings = new ArrayList<>();
DynamicRealmObject object = realm.where(mTable.getName()).findAll().get(i);
for (int j = 0; j < column; j++) {
String cel = "";
try {
if (object.get(mTable.getColumns().get(j).getName()) != null)
if (mTable.getColumns().get(j).getType() == RealmFieldType.LIST) {
cel = "RealmList<" + object.getList(mTable.getColumns().get(j).getName()).first().getType() + '>';
} else {
cel = object.get(mTable.getColumns().get(j).getName()).toString();
}
} catch (NullPointerException e) {
L.e("Except > row size: " + row + " column size: " + column + " " + i + "/" + j);
}
strings.add(cel);
}
results.add(strings);
}
return results;
}
开发者ID:ProgComRapadura,项目名称:RebDroid,代码行数:26,代码来源:ViewAdapter.java
示例10: buildEntryFromResultObject
import io.realm.RealmFieldType; //导入依赖的package包/类
@Override
public BarEntry buildEntryFromResultObject(T realmObject, float x) {
DynamicRealmObject dynamicObject = new DynamicRealmObject(realmObject);
if (dynamicObject.getFieldType(mYValuesField) == RealmFieldType.LIST) {
RealmList<DynamicRealmObject> list = dynamicObject.getList(mYValuesField);
float[] values = new float[list.size()];
int i = 0;
for (DynamicRealmObject o : list) {
values[i] = o.getFloat(mStackValueFieldName);
i++;
}
return new BarEntry(
mXValuesField == null ? x : dynamicObject.getFloat(mXValuesField), values);
} else {
float value = dynamicObject.getFloat(mYValuesField);
return new BarEntry(mXValuesField == null ? x : dynamicObject.getFloat(mXValuesField), value);
}
}
开发者ID:PhilJay,项目名称:MPAndroidChart-Realm,代码行数:23,代码来源:RealmBarDataSet.java
示例11: isNullLink
import io.realm.RealmFieldType; //导入依赖的package包/类
@Override
public boolean isNullLink(long columnIndex) {
RealmFieldType columnType = getColumnType(columnIndex);
if (columnType == RealmFieldType.OBJECT || columnType == RealmFieldType.LIST) {
return super.isNullLink(columnIndex);
} else {
return false; // Unsupported types always return false
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:CheckedRow.java
示例12: setNull
import io.realm.RealmFieldType; //导入依赖的package包/类
/**
* Sets null to a row pointer with checking if a column is nullable, except when the column type
* is binary.
*
* @param columnIndex 0 based index value of the cell column.
*/
@Override
public void setNull(long columnIndex) {
RealmFieldType columnType = getColumnType(columnIndex);
if (columnType == RealmFieldType.BINARY) {
super.setBinaryByteArray(columnIndex, null);
} else {
super.setNull(columnIndex);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:CheckedRow.java
示例13: getModelList
import io.realm.RealmFieldType; //导入依赖的package包/类
@Override
public OsList getModelList(long columnIndex) {
RealmFieldType fieldType = getTable().getColumnType(columnIndex);
if (fieldType != RealmFieldType.LIST) {
throw new IllegalArgumentException(
String.format(Locale.US, "Field '%s' is not a 'RealmList'.",
getTable().getColumnName(columnIndex)));
}
return super.getModelList(columnIndex);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:CheckedRow.java
示例14: getValueList
import io.realm.RealmFieldType; //导入依赖的package包/类
@Override
public OsList getValueList(long columnIndex, RealmFieldType fieldType) {
final RealmFieldType actualFieldType = getTable().getColumnType(columnIndex);
if (fieldType != actualFieldType) {
throw new IllegalArgumentException(
String.format(Locale.US, "The type of field '%1$s' is not 'RealmFieldType.%2$s'.",
getTable().getColumnName(columnIndex), fieldType.name()));
}
return super.getValueList(columnIndex, fieldType);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:CheckedRow.java
示例15: FieldDescriptor
import io.realm.RealmFieldType; //导入依赖的package包/类
/**
* @param fieldDescription fieldName or link path to a field name.
* @param validInternalColumnTypes valid internal link types.
* @param validFinalColumnTypes valid field types for the last field in a linked field
*/
protected FieldDescriptor(
String fieldDescription, Set<RealmFieldType>
validInternalColumnTypes,
Set<RealmFieldType> validFinalColumnTypes) {
this.fields = parseFieldDescription(fieldDescription);
int nFields = fields.size();
if (nFields <= 0) {
throw new IllegalArgumentException("Invalid query: Empty field descriptor");
}
this.validInternalColumnTypes = validInternalColumnTypes;
this.validFinalColumnTypes = validFinalColumnTypes;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:FieldDescriptor.java
示例16: setCompilationResults
import io.realm.RealmFieldType; //导入依赖的package包/类
/**
* Store the results of compiling the field description.
* Subclasses call this as the last action in
*
* @param finalClassName the name of the final table in the field description.
* @param finalColumnName the name of the final column in the field description.
* @param finalColumnType the type of the final column in the field description: MAY NOT BE {@code null}!
* @param columnIndices the array of columnIndices.
* @param nativeTablePointers the array of table pointers
*/
protected final void setCompilationResults(
String finalClassName,
String finalColumnName,
RealmFieldType finalColumnType,
long[] columnIndices,
long[] nativeTablePointers) {
if ((validFinalColumnTypes != null) && (validFinalColumnTypes.size() > 0)) {
verifyColumnType(finalClassName, finalColumnName, finalColumnType, validFinalColumnTypes);
}
this.finalColumnName = finalColumnName;
this.finalColumnType = finalColumnType;
this.columnIndices = columnIndices;
this.nativeTablePointers = nativeTablePointers;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:FieldDescriptor.java
示例17: verifyColumnType
import io.realm.RealmFieldType; //导入依赖的package包/类
private void verifyColumnType(String className, String columnName, RealmFieldType columnType, Set<RealmFieldType> validTypes) {
if (!validTypes.contains(columnType)) {
throw new IllegalArgumentException(String.format(Locale.US,
"Invalid query: field '%s' in class '%s' is of invalid type '%s'.",
columnName, className, columnType.toString()));
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:FieldDescriptor.java
示例18: compileFieldDescription
import io.realm.RealmFieldType; //导入依赖的package包/类
@Override
protected void compileFieldDescription(List<String> fields) {
final int nFields = fields.size();
long[] columnIndices = new long[nFields];
Table currentTable = table;
String currentClassName = null;
String currentColumnName = null;
RealmFieldType currentColumnType = null;
for (int i = 0; i < nFields; i++) {
currentColumnName = fields.get(i);
if ((currentColumnName == null) || (currentColumnName.length() <= 0)) {
throw new IllegalArgumentException(
"Invalid query: Field descriptor contains an empty field. A field description may not begin with or contain adjacent periods ('.').");
}
currentClassName = currentTable.getClassName();
final long columnIndex = currentTable.getColumnIndex(currentColumnName);
if (columnIndex < 0) {
throw new IllegalArgumentException(
String.format(Locale.US, "Invalid query: field '%s' not found in table '%s'.", currentColumnName, currentClassName));
}
currentColumnType = currentTable.getColumnType(columnIndex);
if (i < nFields - 1) {
verifyInternalColumnType(currentClassName, currentColumnName, currentColumnType);
currentTable = currentTable.getLinkTarget(columnIndex);
}
columnIndices[i] = columnIndex;
}
setCompilationResults(currentClassName, currentColumnName, currentColumnType, columnIndices, new long[nFields]);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:36,代码来源:DynamicFieldDescriptor.java
示例19: getTableWithStringPrimaryKey
import io.realm.RealmFieldType; //导入依赖的package包/类
private Table getTableWithStringPrimaryKey() {
sharedRealm = OsSharedRealm.getInstance(config);
sharedRealm.beginTransaction();
OsObjectStore.setSchemaVersion(sharedRealm,0); // Create meta table
Table t = sharedRealm.createTable(Table.getTableNameForClass("TestTable"));
long column = t.addColumn(RealmFieldType.STRING, "colName", true);
t.addSearchIndex(column);
OsObjectStore.setPrimaryKeyForObject(sharedRealm, "TestTable", "colName");
return t;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:PrimaryKeyTests.java
示例20: getTableWithIntegerPrimaryKey
import io.realm.RealmFieldType; //导入依赖的package包/类
private Table getTableWithIntegerPrimaryKey() {
sharedRealm = OsSharedRealm.getInstance(config);
sharedRealm.beginTransaction();
OsObjectStore.setSchemaVersion(sharedRealm,0); // Create meta table
Table t = sharedRealm.createTable(Table.getTableNameForClass("TestTable"));
long column = t.addColumn(RealmFieldType.INTEGER, "colName");
t.addSearchIndex(column);
OsObjectStore.setPrimaryKeyForObject(sharedRealm, "TestTable", "colName");
return t;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:PrimaryKeyTests.java
注:本文中的io.realm.RealmFieldType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论