Iterator OsidList Pattern

Adapts a Java Iterator into an OsidList — bridge lazy sources into the OSID list interface.

Overview

The iterator OsidList wraps a Java Iterator<T> so that any lazily-produced sequence — a database cursor, a stream, a generator — can be exposed as an OsidList without loading all elements into memory first. Elements are pulled from the underlying iterator one at a time as the caller invokes getNext().

Because the source is lazy, available() may return 0 even when more elements remain. Callers should rely on hasNext() for exhaustion checks rather than available() when using this implementation.

Javadoc Reference

net.okapia.osid.jamocha.spi

Class Declaration Pattern

public final class IteratorOsidObjectList
extends Object
implements OsidObjectList

Constructor Pattern

IteratorOsidObjectList(Iterator<OsidObject> iterator)
ParameterTypeDescription
iterator Iterator<OsidObject> the source iterator to drain on iteration

Static Factory Method Pattern

static OsidObjectList of(Iterator<OsidObject> iterator)
ParameterTypeDescription
iterator Iterator<OsidObject> the source iterator

Returns OsidObjectList