|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.ibm.as400.access.list.OpenList
Abstract base class that wraps a list of resources on the iSeries server. OpenList classes are Java wrappers for system APIs that are known as "Open List APIs" or "QGY APIs".
The way an open list works is that a request is initially sent to the server with selection, filter, and sort information that is to be applied to the list of resources. The server compiles a list of resources that satisfy the requested set of selection parameters. The OpenList class can then retrieve the list all at once, or in pieces, depending upon the memory and performance requirements of the application.
The server can be told explicitly to compile the list of resources by calling open(). If open()
is not called explicitly by the application, an implicit call to open() is made by any of the
following methods: getLength(), getItems(), and getItems(int,int).
Once the list is open, the application can retrieve resources from the list using either
getItems() or getItems(offset, length). One returns an
Enumeration, the other returns an array and allows for arbitrarily indexing into the list on the server.
The type of resource returned is determined by the type of subclass that extends OpenList. For
example, the SpooledFileOpenList class returns SpooledFileListItem objects when getItems() is called.
When an OpenList object is no longer needed by the application, close() should be called to free up resources
on the server. If close() is not explicitly called, an attempt will be made to automatically close
the list when the OpenList object is garbage collected.
| Field Summary | |
protected static ProgramParameter |
EMPTY_ERROR_CODE_PARM
Constant that can be used for APIs that have an error code parameter. |
protected AS400 |
system_
The system object specified on this OpenList's constructor. |
| Constructor Summary | |
protected |
OpenList(AS400 system)
Called by subclasses to construct an OpenList object. |
| Method Summary | |
protected abstract byte[] |
callOpenListAPI()
This method should be implemented by subclasses to call a particular QGY API and return the 80-byte list information parameter. |
void |
close()
Closes the list on the server. |
protected void |
finalize()
Attempts to close the list on the system when this OpenList object is garbage collected. |
protected abstract java.lang.Object[] |
formatOutputData(byte[] data,
int recordsReturned,
int recordLength)
Returns the actual array of Objects that getItems(int,int) returns. |
protected abstract int |
getBestGuessReceiverSize(int number)
Returns the initial size in bytes of the receiver variable for a particular implementation of an Open List API. |
int |
getEnumerationBlockSize()
Returns the number of items that Enumerations returned by this OpenList's getItems()
method will attempt to retrieve from the server and cache. |
java.util.Enumeration |
getItems()
Returns the list of items. |
java.lang.Object[] |
getItems(int listOffset,
int number)
Returns an array of items, which can be a subset of the entire list built on the server. |
int |
getLength()
Returns the number of items in the list the server has built. |
AS400 |
getSystem()
Returns the system object used by this OpenList. |
boolean |
isOpen()
Returns whether or not this list is open. |
void |
open()
Loads the list of items on the system. |
protected void |
resetHandle()
Resets the handle to indicate we should close the list the next time we do something, usually as a result of one of the selection criteria being changed, since that should build a new list on the server. |
void |
setEnumerationBlockSize(int blockSize)
Sets the number of items that Enumerations returned by this OpenList's getItems()
method will attempt to retrieve from the server and cache. |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static final ProgramParameter EMPTY_ERROR_CODE_PARM
ProgramCall pc = new ProgramCall(system, "/LIBRARY.LIB/PROGRAM.PGM", parameters);
if (!pc.run())
{
AS400Message[] errorMessages = pc.getMessageList();
throw new AS400Exception(errorMessages);
}
protected AS400 system_
getSystem()| Constructor Detail |
protected OpenList(AS400 system)
system - The system. This cannot be null.| Method Detail |
protected abstract byte[] callOpenListAPI()
throws AS400Exception,
AS400SecurityException,
ErrorCompletingRequestException,
java.lang.InterruptedException,
java.io.IOException,
ObjectDoesNotExistException
AS400Exception
AS400SecurityException
ErrorCompletingRequestException
java.lang.InterruptedException
java.io.IOException
ObjectDoesNotExistException
public void close()
throws AS400Exception,
AS400SecurityException,
ErrorCompletingRequestException,
java.lang.InterruptedException,
java.io.IOException,
ObjectDoesNotExistException
Any Enumerations created by this OpenList by calling getItems will close, so
that a call to nextElement() will throw a NoSuchElementException when they reach the end of their
enumeration cache block.
AS400Exception - If there is a problem closing the list when the QGYCLST API is called.
AS400SecurityException
ErrorCompletingRequestException
java.lang.InterruptedException
java.io.IOException
ObjectDoesNotExistException
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwable
protected abstract java.lang.Object[] formatOutputData(byte[] data,
int recordsReturned,
int recordLength)
throws AS400Exception,
AS400SecurityException,
ErrorCompletingRequestException,
java.lang.InterruptedException,
java.io.IOException,
ObjectDoesNotExistException
data - The output data from the receiver variable from the call to the QGYGTLE (Get List Entries) API.recordsReturned - The number of records returned, as reported in the open list information returned on the call to QGYGTLE.recordLength - The length of a record, in bytes, as reported in the open list information returned on the call to QGYGTLE.
AS400Exception
AS400SecurityException
ErrorCompletingRequestException
java.lang.InterruptedException
java.io.IOException
ObjectDoesNotExistExceptionprotected abstract int getBestGuessReceiverSize(int number)
number - The number of records in the list on the server. This is useful if the subclass
needs to return a receiver size based on how many records are in the list.
public int getEnumerationBlockSize()
getItems()
method will attempt to retrieve from the server and cache. A larger number will result in fewer
calls to the server but will take more memory.
public int getLength()
throws AS400Exception,
AS400SecurityException,
ErrorCompletingRequestException,
java.lang.InterruptedException,
java.io.IOException,
ObjectDoesNotExistException,
OpenListException
open() to instruct the server to build the list
if it hasn't been built already.
AS400Exception
AS400SecurityException
ErrorCompletingRequestException
java.lang.InterruptedException
java.io.IOException
ObjectDoesNotExistException
OpenListExceptionopen()
public java.util.Enumeration getItems()
throws AS400Exception,
AS400SecurityException,
ErrorCompletingRequestException,
java.lang.InterruptedException,
java.io.IOException,
ObjectDoesNotExistException,
OpenListException
setEnumerationBlockSize() method. This method implicity calls open() to instruct
the server to build the list if it hasn't been built already.
Note that if this OpenList is closed, the Enumeration returned by this method will also be closed, such that a subsequent call to hasMoreElements() returns false and a subsequent call to nextElement() throws a NoSuchElementException.
Calling this method in a loop without either (a) closing this OpenList or (b) calling nextElement() on the Enumerations until they are at an end, will result in a memory leak.
AS400Exception - If the AS/400 system 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.
java.lang.InterruptedException - If this thread is interrupted.
java.io.IOException - If an error occurs while communicating with the AS/400.
ObjectDoesNotExistException - If the AS/400 object does not exist.
OpenListException - If the system is unable to correctly generate the list of items.close(),
open()
public java.lang.Object[] getItems(int listOffset,
int number)
throws AS400Exception,
AS400SecurityException,
ErrorCompletingRequestException,
java.lang.InterruptedException,
java.io.IOException,
ObjectDoesNotExistException,
OpenListException
open() is made (either implicitly or explicitly),
then the items at a given offset will change, so a subsequent call to
getItems() with the same listOffset and number
will most likely not return the same items as the previous call.
listOffset - The offset into the list of items. This value must be greater than or equal to 0 and
less than the list length, or specify -1 to retrieve all of the items.number - The number of items to retrieve out of the list, starting at the specified
listOffset. This value must be greater than or equal to 0 and less than or equal
to the list length. If the listOffset is -1, this parameter is ignored.
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
java.lang.InterruptedException - If this thread is interrupted.
java.io.IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the object does not exist on the system.
OpenListException - If the system is unable to correctly generate the list of items.Job,
close(),
open()public AS400 getSystem()
public boolean isOpen()
opened;
false if this list has been closed, or was never opened in the first place, or
has had its properties changed such that it no longer accurately represents the list that
was built on the server.
public void open()
throws AS400Exception,
AS400SecurityException,
ErrorCompletingRequestException,
java.lang.InterruptedException,
java.io.IOException,
ObjectDoesNotExistException,
OpenListException
getItems() will retrieve the actual object information
and attributes for each item in the list from the system.
This method updates the list length returned by getLength().
If this list is already open, close() is called implicitly.
AS400Exception - If the system 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.
java.lang.InterruptedException - If this thread is interrupted.
java.io.IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the object does not exist on the system.
OpenListException - If the system is unable to correctly generate the list of items.
ServerStartupException - If the server cannot be started.
UnknownHostException - If the system cannot be located.getLength(),
close()protected void resetHandle()
It is better that a subclass not allow any of its selection criteria to be changed while the list is open, but that is not always desirable, which is why this method exists.
public void setEnumerationBlockSize(int blockSize)
getItems()
method will attempt to retrieve from the server and cache. A larger number will result in fewer
calls to the server but will take more memory.
blockSize - The block size. The default is 1000 items. If a number less than 1 is specified, the
default block size of 1000 is used.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||