本文整理汇总了Java中io.realm.internal.Table类的典型用法代码示例。如果您正苦于以下问题:Java Table类的具体用法?Java Table怎么用?Java Table使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Table类属于io.realm.internal包,在下文中一共展示了Table类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: insert
import io.realm.internal.Table; //导入依赖的package包/类
public static long insert(Realm realm, some.test.Simple object, Map<RealmModel,Long> cache) {
if (object instanceof RealmObjectProxy && ((RealmObjectProxy) object).realmGet$proxyState().getRealm$realm() != null && ((RealmObjectProxy) object).realmGet$proxyState().getRealm$realm().getPath().equals(realm.getPath())) {
return ((RealmObjectProxy) object).realmGet$proxyState().getRow$realm().getIndex();
}
Table table = realm.getTable(some.test.Simple.class);
long tableNativePtr = table.getNativePtr();
SimpleColumnInfo columnInfo = (SimpleColumnInfo) realm.getSchema().getColumnInfo(some.test.Simple.class);
long rowIndex = OsObject.createRow(table);
cache.put(object, rowIndex);
String realmGet$name = ((SimpleRealmProxyInterface) object).realmGet$name();
if (realmGet$name != null) {
Table.nativeSetString(tableNativePtr, columnInfo.nameIndex, rowIndex, realmGet$name, false);
}
Table.nativeSetLong(tableNativePtr, columnInfo.ageIndex, rowIndex, ((SimpleRealmProxyInterface) object).realmGet$age(), false);
return rowIndex;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:SimpleRealmProxy.java
示例2: insertOrUpdate
import io.realm.internal.Table; //导入依赖的package包/类
public static long insertOrUpdate(Realm realm, some.test.Simple object, Map<RealmModel,Long> cache) {
if (object instanceof RealmObjectProxy && ((RealmObjectProxy) object).realmGet$proxyState().getRealm$realm() != null && ((RealmObjectProxy) object).realmGet$proxyState().getRealm$realm().getPath().equals(realm.getPath())) {
return ((RealmObjectProxy) object).realmGet$proxyState().getRow$realm().getIndex();
}
Table table = realm.getTable(some.test.Simple.class);
long tableNativePtr = table.getNativePtr();
SimpleColumnInfo columnInfo = (SimpleColumnInfo) realm.getSchema().getColumnInfo(some.test.Simple.class);
long rowIndex = OsObject.createRow(table);
cache.put(object, rowIndex);
String realmGet$name = ((SimpleRealmProxyInterface) object).realmGet$name();
if (realmGet$name != null) {
Table.nativeSetString(tableNativePtr, columnInfo.nameIndex, rowIndex, realmGet$name, false);
} else {
Table.nativeSetNull(tableNativePtr, columnInfo.nameIndex, rowIndex, false);
}
Table.nativeSetLong(tableNativePtr, columnInfo.ageIndex, rowIndex, ((SimpleRealmProxyInterface) object).realmGet$age(), false);
return rowIndex;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:SimpleRealmProxy.java
示例3: insert
import io.realm.internal.Table; //导入依赖的package包/类
public static void insert(Realm realm, Iterator<? extends RealmModel> objects, Map<RealmModel,Long> cache) {
Table table = realm.getTable(some.test.Booleans.class);
long tableNativePtr = table.getNativePtr();
BooleansColumnInfo columnInfo = (BooleansColumnInfo) realm.getSchema().getColumnInfo(some.test.Booleans.class);
some.test.Booleans object = null;
while (objects.hasNext()) {
object = (some.test.Booleans) objects.next();
if (cache.containsKey(object)) {
continue;
}
if (object instanceof RealmObjectProxy && ((RealmObjectProxy) object).realmGet$proxyState().getRealm$realm() != null && ((RealmObjectProxy) object).realmGet$proxyState().getRealm$realm().getPath().equals(realm.getPath())) {
cache.put(object, ((RealmObjectProxy) object).realmGet$proxyState().getRow$realm().getIndex());
continue;
}
long rowIndex = OsObject.createRow(table);
cache.put(object, rowIndex);
Table.nativeSetBoolean(tableNativePtr, columnInfo.doneIndex, rowIndex, ((BooleansRealmProxyInterface) object).realmGet$done(), false);
Table.nativeSetBoolean(tableNativePtr, columnInfo.isReadyIndex, rowIndex, ((BooleansRealmProxyInterface) object).realmGet$isReady(), false);
Table.nativeSetBoolean(tableNativePtr, columnInfo.mCompletedIndex, rowIndex, ((BooleansRealmProxyInterface) object).realmGet$mCompleted(), false);
Table.nativeSetBoolean(tableNativePtr, columnInfo.anotherBooleanIndex, rowIndex, ((BooleansRealmProxyInterface) object).realmGet$anotherBoolean(), false);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:BooleansRealmProxy.java
示例4: insertOrUpdate
import io.realm.internal.Table; //导入依赖的package包/类
public static void insertOrUpdate(Realm realm, Iterator<? extends RealmModel> objects, Map<RealmModel,Long> cache) {
Table table = realm.getTable(some.test.Booleans.class);
long tableNativePtr = table.getNativePtr();
BooleansColumnInfo columnInfo = (BooleansColumnInfo) realm.getSchema().getColumnInfo(some.test.Booleans.class);
some.test.Booleans object = null;
while (objects.hasNext()) {
object = (some.test.Booleans) objects.next();
if (cache.containsKey(object)) {
continue;
}
if (object instanceof RealmObjectProxy && ((RealmObjectProxy) object).realmGet$proxyState().getRealm$realm() != null && ((RealmObjectProxy) object).realmGet$proxyState().getRealm$realm().getPath().equals(realm.getPath())) {
cache.put(object, ((RealmObjectProxy) object).realmGet$proxyState().getRow$realm().getIndex());
continue;
}
long rowIndex = OsObject.createRow(table);
cache.put(object, rowIndex);
Table.nativeSetBoolean(tableNativePtr, columnInfo.doneIndex, rowIndex, ((BooleansRealmProxyInterface) object).realmGet$done(), false);
Table.nativeSetBoolean(tableNativePtr, columnInfo.isReadyIndex, rowIndex, ((BooleansRealmProxyInterface) object).realmGet$isReady(), false);
Table.nativeSetBoolean(tableNativePtr, columnInfo.mCompletedIndex, rowIndex, ((BooleansRealmProxyInterface) object).realmGet$mCompleted(), false);
Table.nativeSetBoolean(tableNativePtr, columnInfo.anotherBooleanIndex, rowIndex, ((BooleansRealmProxyInterface) object).realmGet$anotherBoolean(), false);
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:BooleansRealmProxy.java
示例5: get
import io.realm.internal.Table; //导入依赖的package包/类
<E extends RealmModel> E get(@Nullable Class<E> clazz, @Nullable String dynamicClassName, long rowIndex) {
final boolean isDynamicRealmObject = dynamicClassName != null;
// 'clazz' is non-null when 'dynamicClassName' is null.
//noinspection ConstantConditions
final Table table = isDynamicRealmObject ? getSchema().getTable(dynamicClassName) : getSchema().getTable(clazz);
E result;
if (isDynamicRealmObject) {
@SuppressWarnings("unchecked")
E dynamicObj = (E) new DynamicRealmObject(this,
(rowIndex != Table.NO_MATCH) ? table.getCheckedRow(rowIndex) : InvalidRow.INSTANCE);
result = dynamicObj;
} else {
result = configuration.getSchemaMediator().newInstance(clazz, this,
(rowIndex != Table.NO_MATCH) ? table.getUncheckedRow(rowIndex) : InvalidRow.INSTANCE,
getSchema().getColumnInfo(clazz), false, Collections.<String>emptyList());
}
return result;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:BaseRealm.java
示例6: Realm
import io.realm.internal.Table; //导入依赖的package包/类
/**
* The constructor is private to enforce the use of the static one.
*
* @param cache the {@link RealmCache} associated to this Realm instance.
* @throws IllegalArgumentException if trying to open an encrypted Realm with the wrong key.
*/
private Realm(RealmCache cache) {
super(cache, createExpectedSchemaInfo(cache.getConfiguration().getSchemaMediator()));
schema = new ImmutableRealmSchema(this,
new ColumnIndices(configuration.getSchemaMediator(), sharedRealm.getSchemaInfo()));
// FIXME: This is to work around the different behaviour between the read only Realms in the Object Store and
// in current java implementation. Opening a read only Realm with some missing schemas is allowed by Object
// Store and realm-cocoa. In that case, any query based on the missing schema should just return an empty
// results. Fix this together with https://github.com/realm/realm-java/issues/2953
if (configuration.isReadOnly()) {
RealmProxyMediator mediator = configuration.getSchemaMediator();
Set<Class<? extends RealmModel>> classes = mediator.getModelClasses();
for (Class<? extends RealmModel> clazz : classes) {
String tableName = Table.getTableNameForClass(mediator.getSimpleClassName(clazz));
if (!sharedRealm.hasTable(tableName)) {
sharedRealm.close();
throw new RealmMigrationNeededException(configuration.getPath(),
String.format(Locale.US, "Cannot open the read only Realm. '%s' is missing.",
Table.getClassNameForTable(tableName)));
}
}
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:Realm.java
示例7: createObjectInternal
import io.realm.internal.Table; //导入依赖的package包/类
/**
* Same as {@link #createObject(Class)} but this does not check the thread.
*
* @param clazz the Class of the object to create.
* @param acceptDefaultValue if {@code true}, default value of the object will be applied and
* if {@code false}, it will be ignored.
* @return the new object.
* @throws RealmException if the primary key is defined in the model class or an object cannot be created.
*/
// Called from proxy classes.
<E extends RealmModel> E createObjectInternal(
Class<E> clazz,
boolean acceptDefaultValue,
List<String> excludeFields) {
Table table = schema.getTable(clazz);
// Checks and throws the exception earlier for a better exception message.
if (OsObjectStore.getPrimaryKeyForObject(
sharedRealm, configuration.getSchemaMediator().getSimpleClassName(clazz)) != null) {
throw new RealmException(String.format(Locale.US, "'%s' has a primary key, use" +
" 'createObject(Class<E>, Object)' instead.", table.getClassName()));
}
return configuration.getSchemaMediator().newInstance(clazz, this,
OsObject.create(table),
schema.getColumnInfo(clazz),
acceptDefaultValue, excludeFields);
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:Realm.java
示例8: setObject
import io.realm.internal.Table; //导入依赖的package包/类
/**
* Sets a reference to another object on the given field.
*
* @param fieldName field name.
* @param value object to link to.
* @throws IllegalArgumentException if field name doesn't exist, it doesn't link to other Realm objects, the type
* of DynamicRealmObject doesn't match or it belongs to a different Realm.
*/
public void setObject(String fieldName, @Nullable DynamicRealmObject value) {
proxyState.getRealm$realm().checkIfValid();
long columnIndex = proxyState.getRow$realm().getColumnIndex(fieldName);
if (value == null) {
proxyState.getRow$realm().nullifyLink(columnIndex);
} else {
if (value.proxyState.getRealm$realm() == null || value.proxyState.getRow$realm() == null) {
throw new IllegalArgumentException("Cannot link to objects that are not part of the Realm.");
}
if (proxyState.getRealm$realm() != value.proxyState.getRealm$realm()) {
throw new IllegalArgumentException("Cannot add an object from another Realm instance.");
}
Table table = proxyState.getRow$realm().getTable().getLinkTarget(columnIndex);
Table inputTable = value.proxyState.getRow$realm().getTable();
if (!table.hasSameSchema(inputTable)) {
throw new IllegalArgumentException(String.format(Locale.US,
"Type of object is wrong. Was %s, expected %s",
inputTable.getName(), table.getName()));
}
proxyState.getRow$realm().setLink(columnIndex, value.proxyState.getRow$realm().getIndex());
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:32,代码来源:DynamicRealmObject.java
示例9: getTable
import io.realm.internal.Table; //导入依赖的package包/类
Table getTable(Class<? extends RealmModel> clazz) {
Table table = classToTable.get(clazz);
if (table != null) { return table; }
Class<? extends RealmModel> originalClass = Util.getOriginalModelClass(clazz);
if (isProxyClass(originalClass, clazz)) {
// If passed 'clazz' is the proxy, try again with model class.
table = classToTable.get(originalClass);
}
if (table == null) {
String tableName = Table.getTableNameForClass(
realm.getConfiguration().getSchemaMediator().getSimpleClassName(originalClass));
table = realm.getSharedRealm().getTable(tableName);
classToTable.put(originalClass, table);
}
if (isProxyClass(originalClass, clazz)) {
// 'clazz' is the proxy class for 'originalClass'.
classToTable.put(clazz, table);
}
return table;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:RealmSchema.java
示例10: getSchemaForClass
import io.realm.internal.Table; //导入依赖的package包/类
RealmObjectSchema getSchemaForClass(Class<? extends RealmModel> clazz) {
RealmObjectSchema classSchema = classToSchema.get(clazz);
if (classSchema != null) { return classSchema; }
Class<? extends RealmModel> originalClass = Util.getOriginalModelClass(clazz);
if (isProxyClass(originalClass, clazz)) {
// If passed 'clazz' is the proxy, try again with model class.
classSchema = classToSchema.get(originalClass);
}
if (classSchema == null) {
Table table = getTable(clazz);
classSchema = new ImmutableRealmObjectSchema(realm, this, table, getColumnInfo(originalClass));
classToSchema.put(originalClass, classSchema);
}
if (isProxyClass(originalClass, clazz)) {
// 'clazz' is the proxy class for 'originalClass'.
classToSchema.put(clazz, classSchema);
}
return classSchema;
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:RealmSchema.java
示例11: setGetClassName
import io.realm.internal.Table; //导入依赖的package包/类
@Test
public void setGetClassName() {
final String[] validClassNames = {
TestHelper.getRandomString(1),
"Darby",
TestHelper.getRandomString(Table.CLASS_NAME_MAX_LENGTH)
};
if (type == ObjectSchemaType.IMMUTABLE) {
thrown.expect(UnsupportedOperationException.class);
DOG_SCHEMA.setClassName(validClassNames[0]);
return;
}
assertEquals("Dog", DOG_SCHEMA.getClassName());
for (String validClassName : validClassNames) {
DOG_SCHEMA.setClassName(validClassName);
assertEquals(validClassName, DOG_SCHEMA.getClassName());
assertTrue(realmSchema.contains(validClassName));
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:RealmObjectSchemaTests.java
示例12: index
import io.realm.internal.Table; //导入依赖的package包/类
@Test
public void index() {
Table table = realm.getTable(AnnotationIndexTypes.class);
assertTrue(table.hasSearchIndex(table.getColumnIndex("indexString")));
assertFalse(table.hasSearchIndex(table.getColumnIndex("notIndexString")));
assertTrue(table.hasSearchIndex(table.getColumnIndex("indexInt")));
assertFalse(table.hasSearchIndex(table.getColumnIndex("notIndexInt")));
assertTrue(table.hasSearchIndex(table.getColumnIndex("indexByte")));
assertFalse(table.hasSearchIndex(table.getColumnIndex("notIndexByte")));
assertTrue(table.hasSearchIndex(table.getColumnIndex("indexShort")));
assertFalse(table.hasSearchIndex(table.getColumnIndex("notIndexShort")));
assertTrue(table.hasSearchIndex(table.getColumnIndex("indexLong")));
assertFalse(table.hasSearchIndex(table.getColumnIndex("notIndexLong")));
assertTrue(table.hasSearchIndex(table.getColumnIndex("indexBoolean")));
assertFalse(table.hasSearchIndex(table.getColumnIndex("notIndexBoolean")));
assertTrue(table.hasSearchIndex(table.getColumnIndex("indexDate")));
assertFalse(table.hasSearchIndex(table.getColumnIndex("notIndexDate")));
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:RealmAnnotationTests.java
示例13: createTable
import io.realm.internal.Table; //导入依赖的package包/类
public static Table createTable(OsSharedRealm sharedRealm, String name, AdditionalTableSetup additionalSetup) {
boolean wasInTransaction = sharedRealm.isInTransaction();
if (!wasInTransaction) {
sharedRealm.beginTransaction();
}
try {
Table table = sharedRealm.createTable(name);
if (additionalSetup != null) {
additionalSetup.execute(table);
}
return table;
} catch (RuntimeException e) {
if (!wasInTransaction) {
sharedRealm.cancelTransaction();
}
throw e;
} finally {
if (!wasInTransaction && sharedRealm.isInTransaction()) {
sharedRealm.commitTransaction();
}
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:TestHelper.java
示例14: create
import io.realm.internal.Table; //导入依赖的package包/类
@Test
public void create() {
final String[] validClassNames = {
TestHelper.getRandomString(1),
"Darby",
TestHelper.getRandomString(Table.CLASS_NAME_MAX_LENGTH)
};
if (type == SchemaType.IMMUTABLE) {
thrown.expect(UnsupportedOperationException.class);
realmSchema.create(validClassNames[0]);
return;
}
for (String validClassName : validClassNames) {
realmSchema.create(validClassName);
assertTrue(realmSchema.contains(validClassName));
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:RealmSchemaTests.java
示例15: createWithPrimaryKeyField_invalidClassNameThrows
import io.realm.internal.Table; //导入依赖的package包/类
@Test
public void createWithPrimaryKeyField_invalidClassNameThrows() {
if (type == SchemaType.IMMUTABLE) {
return;
}
String[] invalidNames = { null, "", TestHelper.getRandomString(Table.CLASS_NAME_MAX_LENGTH + 1) };
for (String name : invalidNames) {
try {
realmSchema.createWithPrimaryKeyField(name, "pkField", int.class);
fail();
} catch (IllegalArgumentException ignored) {
}
assertFalse(String.format("'%s' failed", name), realmSchema.contains(name));
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:RealmSchemaTests.java
示例16: setter_binary_long_values
import io.realm.internal.Table; //导入依赖的package包/类
@Test
public void setter_binary_long_values() {
byte[] longBinary = new byte[Table.MAX_BINARY_SIZE];
byte[] tooLongBinary = new byte[Table.MAX_BINARY_SIZE + 1];
realm.beginTransaction();
AllTypes allTypes = realm.createObject(AllTypes.class);
allTypes.setColumnBinary(longBinary);
realm.commitTransaction();
assertEquals(longBinary.length, allTypes.getColumnBinary().length);
realm.beginTransaction();
try {
allTypes.setColumnBinary(tooLongBinary);
fail();
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage(), CoreMatchers.containsString("which exceeds the max binary size"));
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:RealmObjectTests.java
示例17: setter_string_long_values
import io.realm.internal.Table; //导入依赖的package包/类
@Test
public void setter_string_long_values() {
byte[] tooLongBinary = new byte[Table.MAX_STRING_SIZE + 1];
Arrays.fill(tooLongBinary, (byte) 'a');
String longString = new String(tooLongBinary, 0, Table.MAX_STRING_SIZE, Charset.forName("US-ASCII"));
String tooLongString = new String(tooLongBinary, 0, Table.MAX_STRING_SIZE + 1, Charset.forName("US-ASCII"));
realm.beginTransaction();
AllTypes allTypes = realm.createObject(AllTypes.class);
allTypes.setColumnString(longString);
realm.commitTransaction();
assertEquals(longString.length(), allTypes.getColumnString().length());
realm.beginTransaction();
try {
allTypes.setColumnString(tooLongString);
fail();
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage(), CoreMatchers.containsString("which exceeds the max string length"));
}
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:RealmObjectTests.java
示例18: executeSQL
import io.realm.internal.Table; //导入依赖的package包/类
public <T> T executeSQL(String databaseId, String query, ExecuteResultHandler<T> executeResultHandler) {
final SharedGroup group = openSharedGroupForImplicitTransactions(databaseId);
//noinspection TryWithIdenticalCatches,TryFinallyCanBeTryWithResources
try {
final ImplicitTransaction transaction = group.beginImplicitTransaction();
query = query.trim();
final Matcher selectMatcher = SELECT_PATTERN.matcher(query);
if (selectMatcher.matches()) {
final String tableName = selectMatcher.group(1);
final Table table = transaction.getTable(tableName);
return executeResultHandler.handleSelect(table, true);
}
// TODO 読み出し以外にも対応する
return null;
} finally {
group.close();
}
}
开发者ID:gjyaiya,项目名称:StethoRealm,代码行数:23,代码来源:RealmPeerManager.java
示例19: get
import io.realm.internal.Table; //导入依赖的package包/类
@Override
public RealmObjectSchema get(String className) {
checkNotEmpty(className, EMPTY_STRING_MSG);
String internalClassName = Table.getTableNameForClass(className);
if (!realm.getSharedRealm().hasTable(internalClassName)) { return null; }
Table table = realm.getSharedRealm().getTable(internalClassName);
return new ImmutableRealmObjectSchema(realm, this, table, getColumnInfo(className));
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:ImmutableRealmSchema.java
示例20: createObject
import io.realm.internal.Table; //导入依赖的package包/类
/**
* Instantiates and adds a new object to the Realm.
*
* @param className the class name of the object to create.
* @return the new object.
* @throws RealmException if the object could not be created.
*/
public DynamicRealmObject createObject(String className) {
checkIfValid();
Table table = schema.getTable(className);
String pkField = OsObjectStore.getPrimaryKeyForObject(sharedRealm, className);
// Check and throw the exception earlier for a better exception message.
if (pkField != null) {
throw new RealmException(String.format(Locale.US,
"'%s' has a primary key field '%s', use 'createObject(String, Object)' instead.",
className, pkField));
}
return new DynamicRealmObject(this, CheckedRow.getFromRow(OsObject.create(table)));
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:DynamicRealm.java
注:本文中的io.realm.internal.Table类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论