public class IComEnumVariantIterator extends Object implements Iterable<Variant.VARIANT>, Iterator<Variant.VARIANT>, Closeable
// Aquire an IDispatch, that has a new NewEnum Property (DISPID_NEWENUM)
for(VARIANT v: IComEnumVariantIterator.wrap(dispatch)) {
// Work with the acquired Variant
// ...
// Finally free it
OleAuto.INSTANCE.VariantClear(v);
}
The IComEnumVariantIterator
iterator closes the enumeration it
wraps after the enumeration is exhausted or when the iterator is GCed,
whatever happens earlier.
Constructor and Description |
---|
IComEnumVariantIterator(EnumVariant backingIteration)
IComEnumVariantIterator wraps the supplied EnumVariant and exposes that
as an
Iterable<Variant.VARIANT> /Iterator<Variant.VARIANT> . |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected void |
finalize() |
boolean |
hasNext() |
Iterator<Variant.VARIANT> |
iterator() |
Variant.VARIANT |
next() |
void |
remove() |
static IComEnumVariantIterator |
wrap(IDispatch dispatch)
Helper to get new enumeration from an
IDispatch . |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
forEachRemaining
public IComEnumVariantIterator(EnumVariant backingIteration)
Iterable<Variant.VARIANT>
/Iterator<Variant.VARIANT>
.
The class takes possion of the supplied EnumVariant. So the EnumVariant
is Released when the enumeration is exhausted or the Iterator is GCed.backingIteration
- public static IComEnumVariantIterator wrap(IDispatch dispatch)
IDispatch
.
This expects, that the supplied IDispatch has a property identified by
a OaIdl.DISPID
of OaIdl.DISPID_NEWENUM
dispatch
- IDispatch to be analysedpublic boolean hasNext()
hasNext
in interface Iterator<Variant.VARIANT>
public Variant.VARIANT next()
next
in interface Iterator<Variant.VARIANT>
public void close()
close
in interface Closeable
close
in interface AutoCloseable
protected void finalize() throws Throwable
public Iterator<Variant.VARIANT> iterator()
iterator
in interface Iterable<Variant.VARIANT>
public void remove()
remove
in interface Iterator<Variant.VARIANT>