Package io.objectbox

Class Cursor<T>

java.lang.Object
io.objectbox.Cursor<T>
All Implemented Interfaces:
Closeable, AutoCloseable

@Beta @Internal @NotThreadSafe public abstract class Cursor<T> extends Object implements Closeable
  • Field Details

    • TRACK_CREATION_STACK

      @Internal static boolean TRACK_CREATION_STACK
      May be set by tests
    • LOG_READ_NOT_CLOSED

      @Internal static boolean LOG_READ_NOT_CLOSED
    • PUT_FLAG_FIRST

      protected static final int PUT_FLAG_FIRST
      See Also:
    • PUT_FLAG_COMPLETE

      protected static final int PUT_FLAG_COMPLETE
      See Also:
    • tx

      protected final Transaction tx
    • cursor

      protected final long cursor
    • entityInfo

      protected final EntityInfo<T> entityInfo
    • boxStoreForEntities

      protected final BoxStore boxStoreForEntities
    • readOnly

      protected final boolean readOnly
    • closed

      protected boolean closed
    • creationThrowable

      private final Throwable creationThrowable
  • Constructor Details

  • Method Details

    • nativeDestroy

      void nativeDestroy(long cursor)
    • nativeDeleteEntity

      static boolean nativeDeleteEntity(long cursor, long key)
    • nativeDeleteAll

      void nativeDeleteAll(long cursor)
    • nativeSeek

      static boolean nativeSeek(long cursor, long key)
    • nativeGetAllEntities

      List<T> nativeGetAllEntities(long cursor)
    • nativeGetEntity

      static Object nativeGetEntity(long cursor, long key)
    • nativeNextEntity

      static Object nativeNextEntity(long cursor)
    • nativeFirstEntity

      static Object nativeFirstEntity(long cursor)
    • nativeCount

      long nativeCount(long cursor, long maxCountOrZero)
    • nativeLookupKeyUsingIndex

      static long nativeLookupKeyUsingIndex(long cursor, int propertyId, String value)
    • nativeRenew

      long nativeRenew(long cursor)
    • collect313311

      protected static long collect313311(long cursor, long keyIfComplete, int flags, int idStr1, @Nullable String valueStr1, int idStr2, @Nullable String valueStr2, int idStr3, @Nullable String valueStr3, int idBA1, @Nullable byte[] valueBA1, int idLong1, long valueLong1, int idLong2, long valueLong2, int idLong3, long valueLong3, int idInt1, int valueInt1, int idInt2, int valueInt2, int idInt3, int valueInt3, int idFloat1, float valueFloat1, int idDouble1, double valueDouble1)
    • collect430000

      protected static long collect430000(long cursor, long keyIfComplete, int flags, int idStr1, @Nullable String valueStr1, int idStr2, @Nullable String valueStr2, int idStr3, @Nullable String valueStr3, int idStr4, @Nullable String valueStr4, int idBA1, @Nullable byte[] valueBA1, int idBA2, @Nullable byte[] valueBA2, int idBA3, @Nullable byte[] valueBA3)
    • collect400000

      protected static long collect400000(long cursor, long keyIfComplete, int flags, int idStr1, @Nullable String valueStr1, int idStr2, @Nullable String valueStr2, int idStr3, @Nullable String valueStr3, int idStr4, @Nullable String valueStr4)
    • collect002033

      protected static long collect002033(long cursor, long keyIfComplete, int flags, int idLong1, long valueLong1, int idLong2, long valueLong2, int idFloat1, float valueFloat1, int idFloat2, float valueFloat2, int idFloat3, float valueFloat3, int idDouble1, double valueDouble1, int idDouble2, double valueDouble2, int idDouble3, double valueDouble3)
    • collect004000

      protected static long collect004000(long cursor, long keyIfComplete, int flags, int idLong1, long valueLong1, int idLong2, long valueLong2, int idLong3, long valueLong3, int idLong4, long valueLong4)
    • collectStringArray

      protected static long collectStringArray(long cursor, long keyIfComplete, int flags, int idStringArray, @Nullable String[] stringArray)
    • collectStringList

      protected static long collectStringList(long cursor, long keyIfComplete, int flags, int idStringList, @Nullable List<String> stringList)
    • collectShortArray

      protected static long collectShortArray(long cursor, long keyIfComplete, int flags, int propertyId, @Nullable short[] value)
    • collectCharArray

      protected static long collectCharArray(long cursor, long keyIfComplete, int flags, int propertyId, @Nullable char[] value)
    • collectIntArray

      protected static long collectIntArray(long cursor, long keyIfComplete, int flags, int propertyId, @Nullable int[] value)
    • collectLongArray

      protected static long collectLongArray(long cursor, long keyIfComplete, int flags, int propertyId, @Nullable long[] value)
    • collectFloatArray

      protected static long collectFloatArray(long cursor, long keyIfComplete, int flags, int propertyId, @Nullable float[] value)
    • collectDoubleArray

      protected static long collectDoubleArray(long cursor, long keyIfComplete, int flags, int propertyId, @Nullable double[] value)
    • nativePropertyId

      int nativePropertyId(long cursor, String propertyValue)
    • nativeGetBacklinkEntities

      List<T> nativeGetBacklinkEntities(long cursor, int entityId, int propertyId, long key)
    • nativeGetBacklinkIds

      long[] nativeGetBacklinkIds(long cursor, int entityId, int propertyId, long key)
    • nativeGetRelationEntities

      List<T> nativeGetRelationEntities(long cursor, int sourceEntityId, int relationId, long key, boolean backlink)
    • nativeGetRelationIds

      long[] nativeGetRelationIds(long cursor, int sourceEntityId, int relationId, long key, boolean backlink)
    • nativeModifyRelations

      void nativeModifyRelations(long cursor, int relationId, long key, long[] targetKeys, boolean remove)
    • nativeModifyRelationsSingle

      void nativeModifyRelationsSingle(long cursor, int relationId, long key, long targetKey, boolean remove)
    • nativeSetBoxStoreForEntities

      void nativeSetBoxStoreForEntities(long cursor, Object boxStore)
    • nativeGetCursorFor

      long nativeGetCursorFor(long cursor, int entityId)
    • finalize

      protected void finalize() throws Throwable
      Explicitly call close() instead to avoid expensive finalization.
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • getId

      protected abstract long getId(T entity)
    • put

      public abstract long put(T entity)
    • getEntityInfo

      public EntityInfo<T> getEntityInfo()
    • get

      public T get(long key)
    • next

      public T next()
    • first

      public T first()
    • getAll

      public List<T> getAll()
      ~10% slower than iterating with first() and next() as done by Box.getAll().
    • deleteEntity

      public boolean deleteEntity(long key)
    • deleteAll

      public void deleteAll()
    • seek

      public boolean seek(long key)
    • count

      public long count(long maxCountOrZero)
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • getPropertyId

      public int getPropertyId(String propertyName)
    • lookupKeyUsingIndex

      long lookupKeyUsingIndex(int propertyId, String value)
      Deprecated.
      TODO only used in tests, remove in the future
      Returns:
      key or 0 if not found
    • getTx

      public Transaction getTx()
    • isObsolete

      public boolean isObsolete()
    • isClosed

      public boolean isClosed()
    • getRelationTargetCursor

      protected <TARGET> Cursor<TARGET> getRelationTargetCursor(Class<TARGET> targetClass)
      Note: this returns a secondary cursor, which does not survive standalone. Secondary native cursors are destroyed once their hosting Cursor is destroyed. Thus, use it only locally and don't store it long term.
    • renew

      public void renew()
      To be used in combination with Transaction.renew().
    • internalHandle

      @Internal long internalHandle()
    • getBacklinkEntities

      @Internal List<T> getBacklinkEntities(int entityId, Property<?> relationIdProperty, long key)
    • getBacklinkIds

      @Internal long[] getBacklinkIds(int entityId, Property<?> relationIdProperty, long key)
    • getRelationEntities

      @Internal public List<T> getRelationEntities(int sourceEntityId, int relationId, long key, boolean backlink)
    • getRelationIds

      @Internal public long[] getRelationIds(int sourceEntityId, int relationId, long key, boolean backlink)
    • modifyRelations

      @Internal public void modifyRelations(int relationId, long key, long[] targetKeys, boolean remove)
    • modifyRelationsSingle

      @Internal public void modifyRelationsSingle(int relationId, long key, long targetKey, boolean remove)
    • checkApplyToManyToDb

      protected <TARGET> void checkApplyToManyToDb(List<TARGET> relationField, Class<TARGET> targetClass)
    • toString

      public String toString()
      Overrides:
      toString in class Object