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


Java Box类代码示例

本文整理汇总了Java中io.objectbox.Box的典型用法代码示例。如果您正苦于以下问题:Java Box类的具体用法?Java Box怎么用?Java Box使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getTableInfo

import io.objectbox.Box; //导入依赖的package包/类
private static List<TableDataResponse.TableInfo> getTableInfo(BoxStore boxStore, int index) {
    List<Class> allEntityClasses = new ArrayList<>(boxStore.getAllEntityClasses());
    Log.e("App", " allEntityClasses " + allEntityClasses);
    Box<Object> box = boxStore.boxFor(allEntityClasses.get(index));

    Log.e("App", " set box store " + boxStore);
    Log.e("App", " set box store " + box.count());
    Log.e("App", " set box store " + Arrays.toString(box.getEntityInfo().getAllProperties()));

    List<TableDataResponse.TableInfo> tableInfoList = new ArrayList<>();

    for (Property property : box.getEntityInfo().getAllProperties()) {
        TableDataResponse.TableInfo tableInfo = new TableDataResponse.TableInfo();
        tableInfo.title = property.dbName;
        tableInfo.isPrimary = true;

        tableInfoList.add(tableInfo);
    }

    return tableInfoList;
}
 
开发者ID:kosiarska,项目名称:ObjectBoxDebugBrowser,代码行数:22,代码来源:DatabaseHelper.java

示例2: setBoxStore

import io.objectbox.Box; //导入依赖的package包/类
public void setBoxStore(BoxStore boxStore) {
    this.boxStore = boxStore;
    List<Class> allEntityClasses = new ArrayList<>(boxStore.getAllEntityClasses());
    Log.e("App", " allEntityClasses " + allEntityClasses);
    Box<?> box = boxStore.boxFor(allEntityClasses.get(0));

    Log.e("App", " set box store " + boxStore);
    Log.e("App", " set box store " + box.count());
    Log.e("App", " set box store " + Arrays.toString(box.getEntityInfo().getAllProperties()));


    for (Object o : box.getAll()) {
        Field[] fields = o.getClass().getFields();
        for (Field field : fields) {

            Log.e("App", "fields " + field.getName());
        }

    }
}
 
开发者ID:kosiarska,项目名称:ObjectBoxDebugBrowser,代码行数:21,代码来源:RequestHandler.java

示例3: loadInBackground

import io.objectbox.Box; //导入依赖的package包/类
@Override
public Void loadInBackground() {
    final Box<DbEntry> box =
            ((SimpleRssReader) getContext()).getBoxStore().boxFor(DbEntry.class);

    for (int i = 0; i < mEntryUrls.size(); i++) {
        final String entryUrl = mEntryUrls.get(i);
        final String entryTitle = mEntryTitles.get(i);

        final QueryBuilder<DbEntry> queryBuilder = box.query();

        if (queryBuilder.contains(DbEntry_.entryTitle, entryTitle).build().find().isEmpty()) {
            final DbEntry entry = new DbEntry();

            entry.setEntryUrl(entryUrl);
            entry.setEntryTitle(entryTitle);

            box.put(entry);
        }

        queryBuilder.close();
    }

    return null;
}
 
开发者ID:Applications-Development,项目名称:SimpleRssReader,代码行数:26,代码来源:SavedEntriesSaveLoader.java

示例4: loadInBackground

import io.objectbox.Box; //导入依赖的package包/类
@Override
public Void loadInBackground() {
    final Box<DbEntry> box =
            ((SimpleRssReader) getContext()).getBoxStore().boxFor(DbEntry.class);
    final QueryBuilder<DbEntry> queryBuilder = box.query();

    if (mSortOrder == SORT_ORDER_DESCENDING) {
        queryBuilder.orderDesc(DbEntry_.entryTitle);
    } else {
        queryBuilder.order(DbEntry_.entryTitle);
    }

    SavedEntries.addSavedEntries(queryBuilder.build().find());
    queryBuilder.close();

    return null;
}
 
开发者ID:Applications-Development,项目名称:SimpleRssReader,代码行数:18,代码来源:SavedEntriesQueryLoader.java

示例5: LazyList

import io.objectbox.Box; //导入依赖的package包/类
LazyList(Box<E> box, long[] objectIds, boolean cacheEntities) {
    if (box == null || objectIds == null) {
        throw new NullPointerException("Illegal null parameters passed");
    }
    this.box = box;
    this.objectIds = objectIds;
    size = objectIds.length;
    if (cacheEntities) {
        entities = new ArrayList<>(size);
        for (int i = 0; i < size; i++) {
            entities.add(null);
        }
    } else {
        entities = null;
    }
}
 
开发者ID:objectbox,项目名称:objectbox-java,代码行数:17,代码来源:LazyList.java

示例6: testDateParam

import io.objectbox.Box; //导入依赖的package包/类
@Test
public void testDateParam() {
    store.close();
    assertTrue(store.deleteAllFiles());
    store = MyObjectBox.builder().baseDirectory(boxStoreDir).debugFlags(DebugFlags.LOG_QUERY_PARAMETERS).build();

    Date now = new Date();
    Order order = new Order();
    order.setDate(now);
    Box<Order> box = store.boxFor(Order.class);
    box.put(order);

    Query<Order> query = box.query().equal(Order_.date, 0).build();
    assertEquals(0, query.count());

    query.setParameter(Order_.date, now);
}
 
开发者ID:objectbox,项目名称:objectbox-java,代码行数:18,代码来源:QueryTest.java

示例7: testOldReaderWithIndex

import io.objectbox.Box; //导入依赖的package包/类
@Test
public void testOldReaderWithIndex() throws InterruptedException {
    final Box<EntityLongIndex> box = store.boxFor(EntityLongIndex.class);
    final int initialValue = 1;

    final Query<EntityLongIndex> query = box.query().equal(EntityLongIndex_.indexedLong, 0).build();
    assertNull(query.findUnique());
    System.out.println("BEFORE put: " + box.getReaderDebugInfo());
    System.out.println("count before: " + box.count());

    box.put(createEntityLongIndex(initialValue));

    System.out.println("AFTER put: " + box.getReaderDebugInfo());
    System.out.println("count after: " + box.count());

    query.setParameter(EntityLongIndex_.indexedLong, initialValue);
    assertNotNull(query.findUnique());

    query.setParameter(EntityLongIndex_.indexedLong, 0);
    assertNull(query.findUnique());
}
 
开发者ID:objectbox,项目名称:objectbox-java,代码行数:22,代码来源:IndexReaderRenewTest.java

示例8: putAndGetCustomTypes

import io.objectbox.Box; //导入依赖的package包/类
private void putAndGetCustomTypes() {
    CustomTypes customTypes = new CustomTypes();
    customTypes.customType = CustomTypes.SimpleEnum.DEFAULT;
    customTypes.customTypes = Collections.singletonList(CustomTypes.SimpleEnum.DEFAULT);

    Box<CustomTypes> box = ExampleApp.getBoxStore(this).boxFor(CustomTypes.class);
    long customTypeId = box.put(customTypes);

    CustomTypes customTypesLoaded = box.get(customTypeId);
}
 
开发者ID:greenrobot-team,项目名称:greenrobot-examples,代码行数:11,代码来源:MainActivity.java

示例9: assingField

import io.objectbox.Box; //导入依赖的package包/类
static void assingField(TableDataResponse.ColumnData columnData, Field field, String type, Box<?> box, long id) {
    try {
        columnData.dataType = type;
        columnData.value = field.get(box.get(id));
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}
 
开发者ID:kosiarska,项目名称:ObjectBoxDebugBrowser,代码行数:9,代码来源:DatabaseHelper.java

示例10: loadInBackground

import io.objectbox.Box; //导入依赖的package包/类
@Override
public List<Integer> loadInBackground() {
    final Box<DbEntry> box =
            ((SimpleRssReader) getContext()).getBoxStore().boxFor(DbEntry.class);

    for (final int index : mPositions) {
        box.remove(SavedEntries.getSavedEntryAt(index).getId());
        SavedEntries.removeSavedEntryAt(index);
    }

    return mPositions;
}
 
开发者ID:Applications-Development,项目名称:SimpleRssReader,代码行数:13,代码来源:SavedEntriesDeleteLoader.java

示例11: Query

import io.objectbox.Box; //导入依赖的package包/类
Query(Box<T> box, long queryHandle, boolean hasOrder, List<EagerRelation> eagerRelations, QueryFilter<T> filter,
      Comparator<T> comparator) {
    this.box = box;
    store = box.getStore();
    queryAttempts = store.internalQueryAttempts();
    handle = queryHandle;
    this.hasOrder = hasOrder;
    publisher = new QueryPublisher<>(this, box);
    this.eagerRelations = eagerRelations;
    this.filter = filter;
    this.comparator = comparator;
}
 
开发者ID:objectbox,项目名称:objectbox-java,代码行数:13,代码来源:Query.java

示例12: providesLocalRepository

import io.objectbox.Box; //导入依赖的package包/类
@Provides
@NonNull
@Singleton
public LocalRepository providesLocalRepository(Box<ContributorEntity> localContributorBox,
    ThreadConfiguration threadConfiguration) {
    return new LocalRepository(localContributorBox, threadConfiguration);
}
 
开发者ID:BartoszJarocki,项目名称:android-starter,代码行数:8,代码来源:DataModule.java

示例13: getBox

import io.objectbox.Box; //导入依赖的package包/类
public Box getBox() {
    return box;
}
 
开发者ID:greenrobot,项目名称:ObjectBoxRxJava,代码行数:4,代码来源:MockQuery.java

示例14: provideBoxForTrainingSet

import io.objectbox.Box; //导入依赖的package包/类
@Provides
Box<TrainingSet> provideBoxForTrainingSet() {
    return mStore.boxFor(TrainingSet.class);
}
 
开发者ID:coldsteelbr,项目名称:simple_fitness_diary,代码行数:5,代码来源:ObjectBoxModule.java

示例15: provideBoxForTrainingTrainingSession

import io.objectbox.Box; //导入依赖的package包/类
@Provides
Box<TrainingSession> provideBoxForTrainingTrainingSession() {
    return mStore.boxFor(TrainingSession.class);
}
 
开发者ID:coldsteelbr,项目名称:simple_fitness_diary,代码行数:5,代码来源:ObjectBoxModule.java


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