Examples: Resource list

The following examples show various ways of working with resource lists:

Example: Getting and printing the contents of a ResourceList

One example of a concrete subclass of ResourceList is com.ibm.as400.resource.RJobList, which represents a list of iSeries™ jobs. RJobList supports many selection IDs and sort IDs, each of which can be used to filter or sort the list.This example 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();

Code example disclaimer

The following disclaimer applies to all of the IBM® Toolbox for Java™ examples:

IBM grants you a nonexclusive copyright license to use all programming code examples from which you can generate similar function tailored to your own specific needs.

All sample code is provided by IBM for illustrative purposes only. These examples have not been thoroughly tested under all conditions. IBM, therefore, cannot guarantee or imply reliability, serviceability, or function of these programs.

All programs contained herein are provided to you "AS IS" without any warranties of any kind. The implied warranties of non-infringement, merchantability and fitness for a particular purpose are expressly disclaimed.