Top Description Fields Constructors Methods
com.sun.jna.platform.win32.COM

public Class IComEnumVariantIterator

extends Object
implements Iterable<Variant.VARIANT>, Iterator<Variant.VARIANT>, Closeable
Class Inheritance
All Implemented Interfaces
java.io.Closeable, java.lang.AutoCloseable, java.util.Iterator, java.lang.Iterable
Imports
com.sun.jna.platform.win32.OaIdl, .Variant, com.sun.jna.ptr.PointerByReference, java.io.Closeable, java.util.Iterator

Wrapper for an EnumVariant Iteration. The usecase is a for-loop in the style:
// 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.

Field Summary

Modifier and TypeField and Description
private EnumVariant
private Variant.VARIANT

Constructor Summary

AccessConstructor and Description
public
IComEnumVariantIterator(EnumVariant backingIteration)

IComEnumVariantIterator wraps the supplied EnumVariant and exposes that as an Iterable<Variant.VARIANT>/Iterator<Variant.VARIANT>.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.
protected void
finalize()

Overrides java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.
public Iterator<Variant.VARIANT>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.
public Variant.VARIANT
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.
public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).
private void
public static IComEnumVariantIterator

Returns:

IComEnumVariantIterator wrapping the enumeration queried from the supplied object
wrap
(IDispatch
IDispatch to be analysed
dispatch
)

Helper to get new enumeration from an com.sun.jna.platform.win32.COM.util.IDispatch.

Inherited from java.lang.Object:
cloneequalsgetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

backingIterationback to summary
private EnumVariant backingIteration
nextValueback to summary
private Variant.VARIANT nextValue

Constructor Detail

IComEnumVariantIteratorback to summary
public IComEnumVariantIterator(EnumVariant backingIteration)

IComEnumVariantIterator wraps the supplied EnumVariant and exposes that as an 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.

Method Detail

closeback to summary
public void close()

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
finalizeback to summary
protected void finalize() throws Throwable

Overrides java.lang.Object.finalize.

Doc from java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup.

When running in a Java virtual machine in which finalization has been disabled or removed, the garbage collector will never call finalize(). In a Java virtual machine in which finalization is enabled, the garbage collector might call finalize only after an indefinite delay.

The general contract of finalize is that it is invoked if and when the Java virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.

The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.

The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.

After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.

The finalize method is never invoked more than once by a Java virtual machine for any given object.

Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored.

Annotations
@Override
Exceptions
Throwable:
the Exception raised by this method
hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
iteratorback to summary
public Iterator<Variant.VARIANT> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<Variant.VARIANT>

an Iterator.

Annotations
@Override
nextback to summary
public Variant.VARIANT next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:Variant.VARIANT

the next element in the iteration

Annotations
@Override
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Annotations
@Override
retrieveNextback to summary
private void retrieveNext()
wrapback to summary
public static IComEnumVariantIterator wrap(IDispatch dispatch)

Helper to get new enumeration from an com.sun.jna.platform.win32.COM.util.IDispatch.

This expects, that the supplied IDispatch has a property identified by a com.sun.jna.platform.win32.OaIdl.DISPID of com.sun.jna.platform.win32.OaIdl#DISPID_NEWENUM

Parameters
dispatch:IDispatch

IDispatch to be analysed

Returns:IComEnumVariantIterator

IComEnumVariantIterator wrapping the enumeration queried from the supplied object