-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7b0ecc
commit 75124c9
Showing
3 changed files
with
52 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
This contains sample applications that are not run as part of the unit tests | ||
# Samples directory | ||
|
||
Sample applications that are not run as part of the unit tests | ||
|
||
The ADO sample is a wrapper for the ADO classes. This demonstrates how | ||
to write JACOB wrappers. | ||
|
||
The applet sample shows how to use JACOB in an applet. The trick is to | ||
initialize and use the COM object in the same thread. | ||
|
||
The test directory has numerous tests that test various features | ||
of the JACOB functionality. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,12 +19,17 @@ | |
*/ | ||
package com.jacob.com; | ||
|
||
import java.util.Enumeration; | ||
import java.util.Iterator; | ||
import java.util.stream.Stream; | ||
import java.util.stream.StreamSupport; | ||
|
||
/** | ||
* An implementation of IEnumVariant based on code submitted by Thomas Hallgren | ||
* (mailto:[email protected]) | ||
*/ | ||
public class EnumVariant extends JacobObject implements | ||
java.util.Enumeration<Variant> { | ||
Enumeration<Variant>, Iterable<Variant> { | ||
/** pointer to windows memory */ | ||
private long m_pIEnumVARIANT; | ||
|
||
|
@@ -59,7 +64,7 @@ public EnumVariant(Dispatch disp) { | |
|
||
/** | ||
* Implements java.util.Enumeration | ||
* | ||
* | ||
* @return boolean true if there are more elements in this enumeration | ||
*/ | ||
public boolean hasMoreElements() { | ||
|
@@ -74,7 +79,7 @@ public boolean hasMoreElements() { | |
|
||
/** | ||
* Implements java.util.Enumeration | ||
* | ||
* | ||
* @return next element in the enumeration | ||
*/ | ||
public Variant nextElement() { | ||
|
@@ -90,7 +95,7 @@ public Variant nextElement() { | |
|
||
/** | ||
* Get next element in collection or null if at end | ||
* | ||
* | ||
* @return Variant that is next in the collection | ||
* @deprecated use nextElement() instead | ||
*/ | ||
|
@@ -101,9 +106,41 @@ public Variant Next() { | |
return null; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* <p> | ||
* This implementation resets the EnumVariant, | ||
* so that <code>iterator()</code> can be called multiple times, | ||
* as can {@link #stream}. | ||
*/ | ||
@Override | ||
public Iterator<Variant> iterator() { | ||
Reset(); | ||
return new Iterator<Variant>() { | ||
@Override | ||
public boolean hasNext() { | ||
return hasMoreElements(); | ||
} | ||
|
||
@Override | ||
public Variant next() { | ||
return nextElement(); | ||
} | ||
}; | ||
} | ||
|
||
/** | ||
* Get a Stream from this object. | ||
* | ||
* @return Stream<Variant>. | ||
*/ | ||
public Stream<Variant> stream() { | ||
return StreamSupport.stream(this.spliterator(), false); | ||
} | ||
|
||
/** | ||
* This should be private and wrapped to protect JNI layer. | ||
* | ||
* | ||
* @param receiverArray | ||
* @return Returns the next variant object pointer as an int from windows | ||
* layer | ||
|
@@ -112,9 +149,9 @@ public Variant Next() { | |
|
||
/** | ||
* This should be private and wrapped to protect JNI layer. | ||
* | ||
* | ||
* @param count | ||
* number to skip | ||
* number to skip | ||
*/ | ||
public native void Skip(int count); | ||
|
||
|
@@ -126,13 +163,13 @@ public Variant Next() { | |
/** | ||
* now private so only this object can access was: call this to explicitly | ||
* release the com object before gc | ||
* | ||
* | ||
*/ | ||
private native void release(); | ||
|
||
/* | ||
* (non-Javadoc) | ||
* | ||
* | ||
* @see java.lang.Object#finalize() | ||
*/ | ||
@Override | ||
|
@@ -142,7 +179,7 @@ protected void finalize() { | |
|
||
/* | ||
* (non-Javadoc) | ||
* | ||
* | ||
* @see com.jacob.com.JacobObject#safeRelease() | ||
*/ | ||
@Override | ||
|
@@ -159,4 +196,5 @@ public void safeRelease() { | |
} | ||
} | ||
} | ||
|
||
} |