IEnumObject interface
The IEnumObject interface represents an enumeration object that contains IObject instances. Some methods that return a list of objects, such as enumEvents( ) in the IAppEventMgr interface, return an IEnumObject object.
The IEnumObject interface defines methods for counting and accessing the IObject instances in an IEnumObject.
Package
com.kivasoft
Methods
Related Topics
enumEvents( ) in the IAppEventMgr interface
enumCount( )
Returns the number of IObject instances in an IEnumObject.
Syntax
public int enumCount()
Usage
Use enumCount( ) to determine the number of objects to process before iterating through the IObject instances in the IEnumObject.
Return Value
The number of objects in an IEnumObject.
Example
In the following example, enumEvents( ) returns all the application events registered with the Netscape Application Server in an IEnumObject. The enumCount( ) method is used in conjunction with enumNext( ) and enumReset( ) to access objects in the IEnumObject.
// suppose appEventMgr holds a valid reference to
// an IAppEventMgr instance
// Get the Enumeration object for all registered appevents
IEnumObject enumObj = appEventMgr.enumEvents();
// Retrieve the count of registered appevents
int count = enumObj.enumCount();
try {
p.writeObject("Number of Registered Events: ");
p.writeInt(count);
} catch (IOException e) {
return streamResult("Failed to write to report file<br>");
}
// Reset to the first object in the enumeration object
enumObj.enumReset(0);
// Iterate through all the enumeration instances
while (count > 0) {
// Process the objects.
}
Related Topics
enumEvents( ) in the IAppEventMgr interface
enumNext( )
enumReset( )
enumNext( )
Returns the next IObject instance in an IEnumObject.
Syntax
public IObject enumNext()
Usage
Use enumNext( ) in conjunction with enumCount( ) and enumReset( ) to iterate through an IEnumObject.
Return Value
GXE.SUCCESS if the method succeeds.
Example
In the following example, enumEvents( ) returns all the application events registered with the Netscape Application Server in an IEnumObject. The enumNext( ) method is used in conjunction with enumCount( ) and enumReset( ) to access objects in the IEnumObject.
// Suppose appEventMgr holds a valid reference to AppEvent Manager
// Get the Enumeration object for all registered appevents
IEnumObject enumObj = appEventMgr.enumEvents();
// Retrieve the count of registered appevents
int count = enumObj.enumCount();
try {
p.writeObject("Number of Registered Events: ");
p.writeInt(count);
} catch (IOException e) {
return streamResult("Failed to write to report file<br>");
}
// Reset to the first object in the enumeration object
enumObj.enumReset(0);
// Iterate through all the enumeration instances
while (count > 0) {
IObject vListObj = enumObj.enumNext();
if (vListObj instanceof IAppEventObj) {
IAppEventObj vAppEventObj = (IAppEventObj)vListObj;
// process the appevent
}
}
Related Topics
enumEvents( ) in the IAppEventMgr interface
enumCount( )
enumReset( )
enumReset( )
Resets to the first IObject instance in an IEnumObject.
Syntax
public int enumReset(
int dwFlags)
dwFlags.
Specify 0.
Usage
Use enumReset( ) before iterating through an IEnumObject. Doing so ensures that iteration begins at the first IObject instance in the IEnumObject.
Return Value
GXE.SUCCESS if the method succeeds.
Example
// Retrieve the count of objects in the IEnumObject
int count = enumObj.enumCount();
// Reset to the first object in the enumeration object
enumObj.enumReset(0);
// Iterate through all the enumeration instances
while (count > 0) {
IObject vListObj = enumObj.enumNext();
// Process the objects
Related Topics
enumEvents( ) in the IAppEventMgr interface
enumCount( )
enumNext( )
|