public abstract class ResourceList
extends java.lang.Object
implements java.io.Serializable
A ResourceList is always either open or closed. The ResourceList
must be open in order to access its contents. Call open()
to explicitly open the ResourceList. Otherwise, most
access methods will implicitly open the ResourceList if needed.
When you are finished using the ResourceList, call
close()
to ensure that it cleans up system
resources as needed.
The contents of a ResourceList are 0 or more
Resource
objects.
Use resourceAt()
to access a specific
Resource from the list. All indices are 0-based.
In order to provide immediate access to the ResourceList's
contents and manage memory efficiently, most ResourceLists are
loaded incrementally. This means that neither all of the contents
nor the exact length
is available when the ResourceList
is first opened. Some subclasses may load the contents on demand,
others may load them asynchronously. At some point, depending on
the subclass implementation, the ResourceList will be
complete
. This means that all of its contents
are available and the exact length is known.
Call waitForResource()
to ensure that a
particular Resource is made available. Call waitForComplete()
to ensure that all of the contents and the exact length
are made available.
ResourceLists can be filtered using selection values. Every selection value is identified using a selection ID. Similarly, ResourceLists can be sorted using sort values. Every sort value is identified using a sort ID. Any given subclass of ResourceList will normally document the selection IDs and sort IDs that it supports.
One example of a concrete subclass of ResourceList is
RJobList
, which
represents a list of server jobs. RJobList supports many
selection
IDs and sort
IDs, each of which can be used to filter or sort the list.
Here is an example which prints the contents of an RJobList:
// Create an RJobList object to represent a list of jobs. AS400 system = new AS400("MYSYSTEM", "MYUSERID", "MYPASSWORD"); RJobList jobList = new RJobList(system);
// Filter the list to include only interactive jobs. jobList.setSelectionValue(RJobList.JOB_TYPE, RJob.JOB_TYPE_INTERACTIVE);
// Sort the list by user name, then job name. Object[] sortValue = new Object[] { RJob.USER_NAME, RJob.JOB_NAME }; jobList.setSortValue(sortValue);
// Open the list and wait for it to complete. jobList.open(); jobList.waitForComplete();
// Read and print the contents of the list. long length = jobList.getListLength(); for(long i = 0; i < length; ++i) { System.out.println(jobList.resourceAt(i)); }
// Close the list. jobList.close();
In addition to using concrete subclasses directly, you can write generic code to work with any ResourceList subclass. Such code may improve reusability and maintainability and will work with future ResourceList subclasses without modification. Here is an example of generic code which prints the some of the contents of a ResourceList:
void printContents(ResourceList resourceList, long numberOfItems) throws ResourceException { // Open the list and wait for the requested number of items // to become available. resourceList.open(); resourceList.waitForResource(numberOfItems);
for(long i = 0; i < numberOfItems; ++i) { System.out.println(resourceList.resourceAt(i)); } }
Every selection, sort, and resource attribute has an
associated meta data
object which describes various properties such as the
default value and possible values. In addition, every ResourceList and
meta data object has an associated Presentation
object which provides translated information about the ResourceList,
selection, sort, or attribute. You can use the Presentation information to
present this information to end users. This example prints a ResourceList
and its sort values using their Presentations:
void printCurrentSort(ResourceList resourceList) throws ResourceException { // Get the presentation for the ResourceList and print its full name. Presentation resourceListPresentation = resourceList.getPresentation(); System.out.println(resourceListPresentation.getFullName());
// Get the current sort value. Object[] sortIDs = resourceList.getSortValue();
// Print each sort ID. for(int i = 0; i < sortIDs.length; ++i) { ResourceMetaData sortMetaData = resourceList.getSortMetaData(sortIDs[i]); System.out.println("Sorting by " + sortMetaData.getName()); } }
Use ResourceListDetailsPane
or ResourceListPane
to present a ResourceList in a graphical user interface. Use
ResourceListRowData
to present a ResourceList in a servlet.
Subclass notes:
If you are extending this class to override the mechanism for getting
selection values, consider whether you need to support bidirectional
character conversion. If you do not plan to support bidirectional character
conversion, then you only need to override
getSelectionValue(Object)
.
If you do plan to support bidirectional character conversion, then you need
to override isBidiEnabled()
to return true
and getSelectionValue(Object, int)
.
In either case, the overriding method should call the superclass's method of the same name and perform extra processing only when null is returned:
public Object getSelectionValue(Object selectionID) throws ResourceException { // Call the superclass first. Object value = super.getSelectionValue(selectionID); if (value == null) {
// Establish the connection if needed. if (! isConnectionEstablished()) establishConnection();
// Go get the selection value. value = ...; } return value; }
Extending this class to override the mechanism for setting
selection values works in a similar fashion. If you do not plan to support bidirectional character
conversion, then you only need to override
setSelectionValue(Object, Object)
.
If you do plan to support bidirectional character conversion, then you need
to override isBidiEnabled()
to return true
and setSelectionValue(Object, Object, int)
.
Again, the overriding method should call the superclass's method of the same name and then perform extra processing:
public void setSelectionValue(Object selectionID, Object value) throws ResourceException { // Call the superclass first. super.setSelectionValue(selectionID, values);
// Establish the connection if needed. if (! isConnectionEstablished()) establishConnection();
// Set the selection value. // ... }
Resource
,
Serialized FormConstructor and Description |
---|
ResourceList()
Deprecated.
Constructs a ResourceList object.
|
ResourceList(Presentation presentation,
ResourceMetaData[] attributeMetaData,
ResourceMetaData[] selectionMetaData,
ResourceMetaData[] sortMetaData)
Deprecated.
Constructs a ResourceList object.
|
Modifier and Type | Method and Description |
---|---|
void |
addActiveStatusListener(ActiveStatusListener listener)
Deprecated.
Adds an ActiveStatusListener.
|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Deprecated.
Adds a PropertyChangeListener.
|
void |
addResourceListListener(ResourceListListener listener)
Deprecated.
Adds a ResourceListListener.
|
void |
addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Deprecated.
Adds a VetoableChangeListener.
|
protected boolean |
arePropertiesFrozen()
Deprecated.
Indicates if properties are frozen.
|
void |
close()
Deprecated.
Closes the list.
|
protected void |
establishConnection()
Deprecated.
Establishes the connection to the system, if any.
|
protected void |
fireBusy()
Deprecated.
Fires a busy active status event.
|
protected void |
fireIdle()
Deprecated.
Fires a idle active status event.
|
protected void |
fireLengthChanged(long length)
Deprecated.
Fires a lengthChanged() resource list event.
|
protected void |
fireListClosed()
Deprecated.
Fires a listClosed() ResourceListEvent.
|
protected void |
fireListCompleted()
Deprecated.
Fires a listCompleted() ResourceListEvent.
|
protected void |
fireListInError()
Deprecated.
Fires a listInError() ResourceListEvent.
|
protected void |
fireListOpened()
Deprecated.
Fires a listOpened() ResourceListEvent.
|
protected void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
Deprecated.
Fires a property change event.
|
protected void |
fireResourceAdded(Resource resource,
long index)
Deprecated.
Fires a resourceAdded() ResourceListEvent.
|
protected void |
fireVetoableChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
Deprecated.
Fires a vetoable change event.
|
protected void |
freezeProperties()
Deprecated.
Freezes any property changes.
|
ResourceMetaData[] |
getAttributeMetaData()
Deprecated.
Returns the attribute meta data for the resources in the contents
of the list.
|
ResourceMetaData |
getAttributeMetaData(java.lang.Object attributeID)
Deprecated.
Returns the attribute meta data for a specific attribute of a
resource in the contents of the list.
|
long |
getListLength()
Deprecated.
Returns the total number of resources in the list.
|
Presentation |
getPresentation()
Deprecated.
Returns the presentation information.
|
ResourceMetaData[] |
getSelectionMetaData()
Deprecated.
Returns the selection meta data.
|
ResourceMetaData |
getSelectionMetaData(java.lang.Object selectionID)
Deprecated.
Returns the selection meta data for a specific selection.
|
java.lang.Object |
getSelectionValue(java.lang.Object selectionID)
Deprecated.
Returns the current value of a selection.
|
java.lang.Object |
getSelectionValue(java.lang.Object selectionID,
int bidiStringType)
Deprecated.
Returns the current value of a selection.
|
ResourceMetaData[] |
getSortMetaData()
Deprecated.
Returns the sort meta data.
|
ResourceMetaData |
getSortMetaData(java.lang.Object sortID)
Deprecated.
Returns the sort meta data for a specific sort.
|
boolean |
getSortOrder(java.lang.Object sortID)
Deprecated.
Returns the current order for a particular sort.
|
java.lang.Object[] |
getSortValue()
Deprecated.
Returns the current value of the sort.
|
AS400 |
getSystem()
Deprecated.
Returns the system.
|
protected boolean |
isBidiEnabled()
Deprecated.
Indicates if this resource is enabled for bidirectional character conversion.
|
boolean |
isComplete()
Deprecated.
Indicates if the list is completely loaded.
|
protected boolean |
isConnectionEstablished()
Deprecated.
Indicates if a connection to the system is established.
|
boolean |
isInError()
Deprecated.
Indicates if the list has not been completely loaded due
to an error.
|
boolean |
isOpen()
Deprecated.
Indicates if the list is open.
|
boolean |
isResourceAvailable(long index)
Deprecated.
Indicates if the resource is available.
|
void |
open()
Deprecated.
Opens the list.
|
void |
refreshContents()
Deprecated.
Refreshes the contents of the list.
|
void |
refreshStatus()
Deprecated.
Refreshes the status of the list.
|
void |
removeActiveStatusListener(ActiveStatusListener listener)
Deprecated.
Removes an ActiveStatusListener.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Deprecated.
Removes a PropertyChangeListener.
|
void |
removeResourceListListener(ResourceListListener listener)
Deprecated.
Removes a ResourceListListener.
|
void |
removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Deprecated.
Removes a VetoableChangeListener.
|
Resource |
resourceAt(long index)
Deprecated.
Returns the resource specified by the index.
|
java.util.Enumeration |
resources()
Deprecated.
Returns an Enumeration of the
Resource
objects. |
protected void |
setAttributeMetaData(ResourceMetaData[] attributeMetaData)
Deprecated.
Sets the attribute meta data.
|
protected void |
setPresentation(Presentation presentation)
Deprecated.
Sets the presentation.
|
void |
setSelectionValue(java.lang.Object selectionID,
java.lang.Object value)
Deprecated.
Sets the current value of a selection.
|
void |
setSelectionValue(java.lang.Object selectionID,
java.lang.Object value,
int bidiStringType)
Deprecated.
Sets the current value of a selection.
|
void |
setSortOrder(java.lang.Object sortID,
boolean sortOrder)
Deprecated.
Sets the order for a sort.
|
void |
setSortValue(java.lang.Object[] sortValue)
Deprecated.
Sets the current value of the sort.
|
void |
setSystem(AS400 system)
Deprecated.
Sets the system.
|
java.lang.String |
toString()
Deprecated.
Returns the presentation full name, if any.
|
void |
waitForComplete()
Deprecated.
Waits until the list is completely loaded.
|
void |
waitForResource(long index)
Deprecated.
Waits until the resource is available or the list is
complete.
|
public ResourceList()
public ResourceList(Presentation presentation, ResourceMetaData[] attributeMetaData, ResourceMetaData[] selectionMetaData, ResourceMetaData[] sortMetaData)
presentation
- The presentation.attributeMetaData
- The attribute meta data, or null if not applicable.selectionMetaData
- The selection meta data, or null if not applicable.sortMetaData
- The sort meta data, or null if not applicable.public void addActiveStatusListener(ActiveStatusListener listener)
listener
- The listener.public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The listener.public void addResourceListListener(ResourceListListener listener)
listener
- The listener.public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
listener
- The listener.protected boolean arePropertiesFrozen()
public void close() throws ResourceException
ResourceException
- If an error occurs.protected void establishConnection() throws ResourceException
ResourceException
- If an error occurs.protected void fireBusy()
protected void fireIdle()
protected void fireLengthChanged(long length)
length
- The length.protected void fireListClosed()
protected void fireListCompleted()
protected void fireListInError()
protected void fireListOpened()
protected void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
propertyName
- The property name.oldValue
- The old value.newValue
- The new value.protected void fireResourceAdded(Resource resource, long index)
resource
- The resource.index
- The index.protected void fireVetoableChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue) throws java.beans.PropertyVetoException
propertyName
- The property name.oldValue
- The old value.newValue
- The new value.java.beans.PropertyVetoException
- If the property change is vetoed.protected void freezeProperties() throws ResourceException
Subclasses can override this method and put initialization code here that is dependent on properties being set. Any subclass that overrides this method should include a call to super.freezeProperties().
ResourceException
- If an error occurs.public ResourceMetaData getAttributeMetaData(java.lang.Object attributeID)
attributeID
- Identifies the attribute.public ResourceMetaData[] getAttributeMetaData()
public long getListLength() throws ResourceException
This will implicitly open the list if needed.
ResourceException
- If an error occurs.public Presentation getPresentation()
public ResourceMetaData getSelectionMetaData(java.lang.Object selectionID)
selectionID
- Identifies the selection.public ResourceMetaData[] getSelectionMetaData()
public java.lang.Object getSelectionValue(java.lang.Object selectionID) throws ResourceException
selectionID
- Identifies the selection.ResourceException
- If an error occurs.public java.lang.Object getSelectionValue(java.lang.Object selectionID, int bidiStringType) throws ResourceException
selectionID
- Identifies the selection.bidiStringType
- The bidi string type as defined by the CDRA (Character Data
Representation Architecture). See
BidiStringType
for more information and valid values.ResourceException
- If an error occurs.public ResourceMetaData getSortMetaData(java.lang.Object sortID)
sortID
- Identifies the sort.public ResourceMetaData[] getSortMetaData()
public boolean getSortOrder(java.lang.Object sortID) throws ResourceException
sortID
- The sort ID.ResourceException
- If an error occurs.public java.lang.Object[] getSortValue() throws ResourceException
ResourceException
- If an error occurs.public AS400 getSystem()
protected boolean isBidiEnabled()
public boolean isComplete()
protected boolean isConnectionEstablished()
public boolean isInError()
public boolean isOpen()
public boolean isResourceAvailable(long index) throws ResourceException
index
- The index.ResourceException
- If an error occurs.public void open() throws ResourceException
ResourceException
- If an error occurs.public void refreshContents() throws ResourceException
This will implicitly open the list if needed.
ResourceException
- If an error occurs.public void refreshStatus() throws ResourceException
This method does not refresh the contents of the list. Use
refreshContents()
to refresh
the contents of the list.
This will implicitly open the list if needed.
ResourceException
- If an error occurs.public void removeActiveStatusListener(ActiveStatusListener listener)
listener
- The listener.public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The listener.public void removeResourceListListener(ResourceListListener listener)
listener
- The listener.public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
listener
- The listener.public Resource resourceAt(long index) throws ResourceException
This will implicitly open the list if needed.
index
- The index.ResourceException
- If an error occurs.public java.util.Enumeration resources() throws ResourceException
Resource
objects. This may be a more convenient mechanism to iterate through
the Resource objects, and is provided as an alternative to using the
other methods in this class.
If the contents of the ResourceList are changed while the Enumeration is in use, the enumerated Resource objects may not be consistent.
ResourceException
- If an error occurs.protected void setAttributeMetaData(ResourceMetaData[] attributeMetaData)
attributeMetaData
- The attribute meta data.public void setSelectionValue(java.lang.Object selectionID, java.lang.Object value) throws ResourceException
selectionID
- Identifies the selection.value
- The selection value, or null to remove
the selection.ResourceException
- If an error occurs.public void setSelectionValue(java.lang.Object selectionID, java.lang.Object value, int bidiStringType) throws ResourceException
selectionID
- Identifies the selection.value
- The selection value, or null to remove
the selection.bidiStringType
- The bidi string type as defined by the CDRA (Character Data
Representation Architecture). See
BidiStringType
for more information and valid values.ResourceException
- If an error occurs.protected void setPresentation(Presentation presentation)
presentation
- The presentation.public void setSortOrder(java.lang.Object sortID, boolean sortOrder) throws ResourceException
sortID
- The sort ID.sortOrder
- true for ascending, false for descending.ResourceException
- If an error occurs.public void setSortValue(java.lang.Object[] sortValue) throws ResourceException
sortValue
- An array of sort IDs.ResourceException
- If an error occurs.public void setSystem(AS400 system) throws java.beans.PropertyVetoException
system
- The system.java.beans.PropertyVetoException
- If the change is vetoed.public java.lang.String toString()
toString
in class java.lang.Object
public void waitForComplete() throws ResourceException
This will implicitly open the list if needed.
ResourceException
- If an error occurs.public void waitForResource(long index) throws ResourceException
This will implicitly open the list if needed.
index
- The index.ResourceException
- If an error occurs.