com.ibm.as400.access
Class PrintObjectList

java.lang.Object
  extended bycom.ibm.as400.access.PrintObjectList
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AFPResourceList, OutputQueueList, PrinterFileList, PrinterList, SpooledFileList, WriterJobList

public abstract class PrintObjectList
extends Object
implements Serializable

The PrintObjectList class is an abstract base class for the various types of network print object lists.

See Also:
Serialized Form

Method Summary
 void addPrintObjectListListener(PrintObjectListListener listener)
          Adds the specified PrintObjectList listener to receive PrintObjectList events from this print object list.
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds the specified PropertyChange listener to receive PropertyChange events from this print object list.
 void addVetoableChangeListener(VetoableChangeListener listener)
          Adds the specified VetoableChange listener to receive VetoableChange events from this print object list.
 void close()
          Closes the list so that objects in the list can be garbage collected.
 PrintObject getObject(int index)
          Returns one object from the list.
 Enumeration getObjects()
          Returns an enumeration of the PrintObjects in the list.
 AS400 getSystem()
          Returns the system name.
 boolean isCompleted()
          Checks if a list that was opened asynchronously has completed.
 void openAsynchronously()
          Builds the list asynchronously.
 void openSynchronously()
          Builds the list synchronously.
 void removePrintObjectListListener(PrintObjectListListener listener)
          Removes the specified PrintObjectList listener so that it no longer receives PrintObjectList events from this print object list.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes the specified PropertyChange listener so that it no longer receives PropertyChange events from this print object list.
 void removeVetoableChangeListener(VetoableChangeListener listener)
          Removes the specified VetoableChange listener so that it no longer receives VetoableChange events from this print object list.
 void resetAttributesToRetrieve()
          Resets the list of object attributes to retrieve.
 void resetFilter()
          Resets the list filter back to default values.
 void setAttributesToRetrieve(int[] attributes)
          Sets the attributes of the object that should be returned in the list.
 void setCache(boolean f)
          Sets whether or not to internally maintain a cache of objects returned by this list.
 void setSystem(AS400 system)
          Sets the system name.
 int size()
          Returns the current size of the list.
 void waitForItem(int itemNumber)
          Blocks until the number of requested items are done being built.
 void waitForListToComplete()
          Blocks until the list is done being built.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setCache

public void setCache(boolean f)
Sets whether or not to internally maintain a cache of objects returned by this list. By default, caching is on, so that the Enumeration returned by getObjects() is populated. Under normal circumstances, code should not need to call this method.

However, if code wishes to open the list asynchronously and use a PrintObjectListListener to receive listObjectAdded() events, the objects in the list are returned on those events. So, in some cases, there is no need for this PrintObjectList to maintain a reference to all of the objects returned, since they can be processed individually by the listener. Calling this method with a value of true will save memory in these cases, but the getObjectList() method will return an empty Enumeration, so this method only becomes useful if code has registered a PrintObjectListListener with this PrintObjectList.

See Also:
addPrintObjectListListener(com.ibm.as400.access.PrintObjectListListener), getObjects(), PrintObjectListEvent.getObject(), PrintObjectListListener.listObjectAdded(com.ibm.as400.access.PrintObjectListEvent)

addPrintObjectListListener

public void addPrintObjectListListener(PrintObjectListListener listener)
Adds the specified PrintObjectList listener to receive PrintObjectList events from this print object list.

Parameters:
listener - The PrintObjectList listener.
See Also:
removePrintObjectListListener(com.ibm.as400.access.PrintObjectListListener)

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds the specified PropertyChange listener to receive PropertyChange events from this print object list.

Parameters:
listener - The PropertyChange listener.
See Also:
removePropertyChangeListener(java.beans.PropertyChangeListener)

addVetoableChangeListener

public void addVetoableChangeListener(VetoableChangeListener listener)
Adds the specified VetoableChange listener to receive VetoableChange events from this print object list.

Parameters:
listener - The VetoableChange listener.
See Also:
removeVetoableChangeListener(java.beans.VetoableChangeListener)

close

public void close()
Closes the list so that objects in the list can be garbage collected.


getObject

public PrintObject getObject(int index)
Returns one object from the list.

Parameters:
index - The index of the desired object.
Throws:
ArrayIndexOutOfBoundsException - If an invalid index is given.

getObjects

public Enumeration getObjects()
Returns an enumeration of the PrintObjects in the list.


getSystem

public final AS400 getSystem()
Returns the system name. This method is primarily provided for visual application builders that support JavaBeans.

Returns:
The server on which the objects in the list exist.

isCompleted

public boolean isCompleted()
                    throws AS400Exception,
                           AS400SecurityException,
                           ConnectionDroppedException,
                           ErrorCompletingRequestException,
                           InterruptedException,
                           IOException,
                           RequestNotSupportedException
Checks if a list that was opened asynchronously has completed. If any exception occurred while the list was being retrieved, it will be thrown here.

Returns:
true if the list is completely built; false otherwise.
Throws:
AS400Exception - If the server returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the server.
RequestNotSupportedException - If the requested function is not supported because the server operating system is not at the correct level.

openAsynchronously

public void openAsynchronously()
Builds the list asynchronously. This method starts a thread to build the list and then returns. The caller may register listeners to obtain status about the list, or call isCompleted(), waitForItem(), or waitForListToComplete().


openSynchronously

public void openSynchronously()
                       throws AS400Exception,
                              AS400SecurityException,
                              ConnectionDroppedException,
                              ErrorCompletingRequestException,
                              InterruptedException,
                              IOException,
                              RequestNotSupportedException
Builds the list synchronously. This method will not return until the list has been built completely. The caller may then call the getObjects() method to get an enumeration of the list.

Throws:
AS400Exception - If the server returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the server.
RequestNotSupportedException - If the requested function is not supported because the server operating system is not at the correct level.

removePrintObjectListListener

public void removePrintObjectListListener(PrintObjectListListener listener)
Removes the specified PrintObjectList listener so that it no longer receives PrintObjectList events from this print object list.

Parameters:
listener - The PrintObjectList listener.
See Also:
addPrintObjectListListener(com.ibm.as400.access.PrintObjectListListener)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes the specified PropertyChange listener so that it no longer receives PropertyChange events from this print object list.

Parameters:
listener - The PropertyChange listener.
See Also:
addPropertyChangeListener(java.beans.PropertyChangeListener)

removeVetoableChangeListener

public void removeVetoableChangeListener(VetoableChangeListener listener)
Removes the specified VetoableChange listener so that it no longer receives VetoableChange events from this print object list.

Parameters:
listener - The VetoableChange listener.
See Also:
addVetoableChangeListener(java.beans.VetoableChangeListener)

resetAttributesToRetrieve

public void resetAttributesToRetrieve()
Resets the list of object attributes to retrieve.


resetFilter

public void resetFilter()
Resets the list filter back to default values.


setAttributesToRetrieve

public void setAttributesToRetrieve(int[] attributes)
Sets the attributes of the object that should be returned in the list. This method can be used to speed up the listing if only interested in a few attributes for each item in the list.

Parameters:
attributes - An array of attribute IDs that define which object attributes will be retrieved for each item in the list when the list is opened.
See Also:
PrintObject

setSystem

public final void setSystem(AS400 system)
                     throws PropertyVetoException
Sets the system name. This method is primarily provided for visual application builders that support JavaBeans. Application programmers should specify the system in the constructor for the specific network print object list. For example, SpooledFileList myList = new SpooledFileList(mySystem).

Parameters:
system - The server system name.
Throws:
PropertyVetoException - If the change is vetoed.

size

public int size()
Returns the current size of the list.


waitForItem

public void waitForItem(int itemNumber)
                 throws AS400Exception,
                        AS400SecurityException,
                        ConnectionDroppedException,
                        ErrorCompletingRequestException,
                        InterruptedException,
                        IOException,
                        RequestNotSupportedException
Blocks until the number of requested items are done being built.

Parameters:
itemNumber - The number of items to wait for before returning. Must be greater than 0;
Throws:
AS400Exception - If the server returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the server.
RequestNotSupportedException - If the requested funtion is not supported because the server operating system is not at the correct level.

waitForListToComplete

public void waitForListToComplete()
                           throws AS400Exception,
                                  AS400SecurityException,
                                  ConnectionDroppedException,
                                  ErrorCompletingRequestException,
                                  InterruptedException,
                                  IOException,
                                  RequestNotSupportedException
Blocks until the list is done being built.

Throws:
AS400Exception - If the server returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the server.
RequestNotSupportedException - If the requested function is not supported because the server operating system is not at the correct level.