com.ibm.as400.access
Class CommandList

java.lang.Object
  extended by com.ibm.as400.access.CommandList
All Implemented Interfaces:
Serializable

public class CommandList
extends Object
implements Serializable

The CommandList class represents a list of CL command (*CMD) objects on the system. This class allows the user to retrieve a list of Command objects which can then be used to retrieve information about each individual CL command in the list.

The following example demonstrates the use of CommandList:

    AS400 system = new AS400("mySystem");

    // Generate a list of commands that start with "CRT".
    CommandList list = new CommandList(system, "QSYS", "CRT*");
    try
    {
        Command[] cmdList = list.generateList();
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
  

See Also:
Command, Serialized Form

Field Summary
Modifier and Type Field and Description
static String ALL
          Constant used to retrieve all commands in a given library.
 
Constructor Summary
Constructor and Description
CommandList()
          Constructs a CommandList object.
CommandList(AS400 system, String library, String command)
          Constructs a CommandList object.
 
Method Summary
Modifier and Type Method and Description
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a PropertyChangeListener.
 Command[] generateList()
          Generate a list of commands.
 String getCommand()
          Returns the command name used to generate a list for.
 String getLibrary()
          Returns the library where the command(s) reside.
 AS400 getSystem()
          Returns the system from which to retrieve the command list.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes the PropertyChangeListener.
 void setCommand(String command)
          Sets the command name filter used to generate the list.
 void setLibrary(String library)
          Sets the library where the command(s) reside.
 void setSystem(AS400 system)
          Sets the system from which to retrieve the command list.
 String toString()
          Returns a String representation of this CommandList.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALL

public static final String ALL
Constant used to retrieve all commands in a given library.

See Also:
Constant Field Values
Constructor Detail

CommandList

public CommandList()
Constructs a CommandList object.


CommandList

public CommandList(AS400 system,
                   String library,
                   String command)
Constructs a CommandList object.

Parameters:
system - The system on which the commands resides.
library - The library in which the commands resides, e.g. "QSYS".
command - The name of a command or list of commands, e.g. "CRTUSRPRF" or "CRT*". Wildcards or the CommandList.ALL constant can be used.
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener. The specified PropertyChangeListener's propertyChange method will be called each time the value of any bound property is changed. The PropertyChangeListener object is added to a list of PropertyChangeListeners managed by this CommandList. It can be removed with removePropertyChangeListener.

Parameters:
listener - The PropertyChangeListener.

getCommand

public String getCommand()
Returns the command name used to generate a list for.

Returns:
The command, or null if no command has been set.
See Also:
setCommand(java.lang.String)

getLibrary

public String getLibrary()
Returns the library where the command(s) reside.

Returns:
The library, or null if no library has been set.
See Also:
setLibrary(java.lang.String)

getSystem

public AS400 getSystem()
Returns the system from which to retrieve the command list.

Returns:
The system from which to retrieve the commands, or null if no system has been set.
See Also:
setSystem(com.ibm.as400.access.AS400)

generateList

public Command[] generateList()
                       throws AS400Exception,
                              AS400SecurityException,
                              ErrorCompletingRequestException,
                              IOException,
                              InterruptedException,
                              ObjectDoesNotExistException
Generate a list of commands. The system, library filter, and command filter must all be set before calling this method.

Returns:
The array of Command objects generated by this CommandList. If the command list is empty, an array of size 0 is returned.
Throws:
AS400Exception
AS400SecurityException
ErrorCompletingRequestException
IOException
InterruptedException
ObjectDoesNotExistException
See Also:
setCommand(java.lang.String), setLibrary(java.lang.String), setSystem(com.ibm.as400.access.AS400)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes the PropertyChangeListener. If the PropertyChangeListener is not on the list, nothing is done.

Parameters:
listener - The PropertyChangeListener.

setCommand

public void setCommand(String command)
Sets the command name filter used to generate the list. Wildcards like "CRT*" can be used.

Parameters:
command - The command(s) for which to generate a list.
See Also:
getCommand()

setLibrary

public void setLibrary(String library)
Sets the library where the command(s) reside.

Parameters:
library - The library where the command(s) reside.
See Also:
getLibrary()

setSystem

public void setSystem(AS400 system)
Sets the system from which to retrieve the command list.

Parameters:
system - The system from which to retrieve the commands.
See Also:
getSystem()

toString

public String toString()
Returns a String representation of this CommandList.

Overrides:
toString in class Object
Returns:
The string, which includes the library and command name filter used.