public class IComEnumVariantIterator extends java.lang.Object implements java.lang.Iterable<Variant.VARIANT>, java.util.Iterator<Variant.VARIANT>, java.io.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() |
java.util.Iterator<Variant.VARIANT> |
iterator() |
Variant.VARIANT |
next() |
void |
remove() |
static IComEnumVariantIterator |
wrap(IDispatch dispatch)
Helper to get new enumeration from an
IDispatch. |
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 java.util.Iterator<Variant.VARIANT>public Variant.VARIANT next()
next in interface java.util.Iterator<Variant.VARIANT>public void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableprotected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwablepublic java.util.Iterator<Variant.VARIANT> iterator()
iterator in interface java.lang.Iterable<Variant.VARIANT>public void remove()
remove in interface java.util.Iterator<Variant.VARIANT>