Class AbstractLocalCursor<T>

java.lang.Object
org.rumbledb.runtime.cursor.AbstractLocalCursor<T>
Type Parameters:
T - the value type returned by this cursor
All Implemented Interfaces:
AutoCloseable, Cursor<T>
Direct Known Subclasses:
AtMostOneLocalCursor, ConcatLocalCursor, ContextOrArgumentLocalCursor, FlatMappingLocalCursor, IteratorLocalCursor, MappingLocalCursor

public abstract class AbstractLocalCursor<T> extends Object implements Cursor<T>
Lifecycle template for local cursors.

Implementations only manage evaluation-specific state in the four local methods. This class opens a cursor on its first read, enforces the single-use lifecycle, and performs best-effort cleanup if opening fails.

  • Constructor Details

    • AbstractLocalCursor

      protected AbstractLocalCursor(@NonNull @NonNull ExceptionMetadata metadata)
  • Method Details

    • hasNext

      public final boolean hasNext()
      Specified by:
      hasNext in interface Cursor<T>
      Returns:
      whether another value is available Opens the cursor if needed, then returns whether another value is available.
    • next

      public final T next()
      Specified by:
      next in interface Cursor<T>
      Returns:
      the next value Opens the cursor if needed, then returns the next value.
    • close

      public final void close()
      Description copied from interface: Cursor
      Releases resources owned by this evaluation. This method is idempotent.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Cursor<T>
    • openLocal

      protected abstract void openLocal()
    • hasNextLocal

      protected abstract boolean hasNextLocal()
    • nextLocal

      protected abstract T nextLocal()
    • closeLocal

      protected abstract void closeLocal()
    • invalidState

      protected final RuntimeException invalidState(String message)
      Creates the exception used for invalid lifecycle calls.
      Parameters:
      message - the lifecycle error
      Returns:
      the exception to throw
    • getMetadata

      protected final ExceptionMetadata getMetadata()