All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.as400.access.CommandCall

java.lang.Object
   |
   +----com.ibm.as400.access.CommandCall

public class CommandCall
extends Object
implements Serializable
The CommandCall class represents an AS/400 command call object. This class allows the user to call an AS/400 CL command. Results of the command are returned in a message list.
The following example demonstrates the use of CommandCall:
// Work with commands on system "Hal"
AS400 as400 = new AS400("Hal");
CommandCall cmd = new CommandCall( as400 );
try
{
// Run the command "CRTLIB FRED"
if (cmd.run("CRTLIB FRED")!=true)
{
// Note that there was an error
System.out.println( "program failed!" );
}
// Show the messages (returned whether or not there was an error)
AS400Message[] messagelist = cmd.getMessageList();
for (int i=0; i < messagelist.length; i++)
{
// show each message
System.out.println( messagelist[i].getText() );
}
}
catch (Exception e)
{
System.out.println( "Command " + cmd.getCommand() + " did not run!" );
}
// done with the system
as400.disconnectAllServices();
 

See Also:
AS400Message

Constructor Index

 o CommandCall()
Constructs a CommandCall object.
 o CommandCall(AS400)
Constructs a CommandCall object.
 o CommandCall(AS400, String)
Constructs a CommandCall object.

Method Index

 o addActionCompletedListener(ActionCompletedListener)
Adds an ActionCompletedListener.
 o addPropertyChangeListener(PropertyChangeListener)
Adds a PropertyChangeListener.
 o addVetoableChangeListener(VetoableChangeListener)
Adds a VetoableChangeListener.
 o getCommand()
Returns the command to run.
 o getMessageList()
Returns the list of AS/400 messages returned from running the command.
 o getMessageList(int)
Returns an AS/400 messages returned from running the command.
 o getSystem()
Returns the AS/400 on which the command is to be run.
 o removeActionCompletedListener(ActionCompletedListener)
Removes this ActionCompletedListener from the internal list.
 o removePropertyChangeListener(PropertyChangeListener)
Removes this PropertyChangeListener from the internal list.
 o removeVetoableChangeListener(VetoableChangeListener)
Removes this VetoableChangeListener from the JellyBeans internal list.
 o run()
Runs the command on the AS/400.
 o run(String)
Sets the command string and runs it on the AS/400.
 o setCommand(String)
Sets the command to run.
 o setSystem(AS400)
Sets the AS/400 to run the command.
 o toString()
Returns a short description of the object.

Constructors

 o CommandCall
 public CommandCall()
Constructs a CommandCall object. The system and the command string must be set later.

 o CommandCall
 public CommandCall(AS400 system)
Constructs a CommandCall object. It uses the specified system name. The command string must be set later.

Parameters:
system - The AS/400 on which to issue the command.
 o CommandCall
 public CommandCall(AS400 system,
                    String command)
Constructs a CommandCall object. It uses the specified system name and command.

Parameters:
system - The AS/400 on which to issue the command.
command - The command to run on the AS/400. The library list will be used to find the command.

Methods

 o addActionCompletedListener
 public synchronized void addActionCompletedListener(ActionCompletedListener l)
Adds an ActionCompletedListener. The specified ActionCompletedListeners actionCompleted method will be called each time a command has run. The ActionCompletedListener object is added to a list of ActionCompletedListeners managed by this CommandCall; it can be removed with removeActionCompletedListener.

Parameters:
l - The ActionCompletedListener.
See Also:
removeActionCompletedListener
 o addPropertyChangeListener
 public void addPropertyChangeListener(PropertyChangeListener l)
Adds a PropertyChangeListener. The specified PropertyChangeListeners propertyChange method will be called each time the value of any bound property is changed. The PropertyListener object is added to a list of PropertyChangeListeners managed by this CommandCall; it can be removed with removePropertyChangeListener.

Parameters:
l - The PropertyChangeListener.
See Also:
removePropertyChangeListener
 o addVetoableChangeListener
 public void addVetoableChangeListener(VetoableChangeListener l)
Adds a VetoableChangeListener. The specified VetoableChangeListeners vetoableChange method will be called each time the value of any constrained property is changed.

Parameters:
l - The VetoableChangeListener.
See Also:
removeVetoableChangeListener
 o getCommand
 public String getCommand()
Returns the command to run. It may return null if the command has not been previously set by the constructor, setCommand, or run.

Returns:
The command to run.
 o getMessageList
 public AS400Message[] getMessageList()
Returns the list of AS/400 messages returned from running the command. It will return an empty list if the command has not been run yet.

Returns:
The array of messages returned by the AS/400 for the command.
 o getMessageList
 public AS400Message getMessageList(int index)
Returns an AS/400 messages returned from running the command.

Parameters:
index - The index into the list of messages returned by the AS/400 for the command. It must be greater than or equal to zero and less than the number of messages in the list.
Returns:
The message at the requested index returned by the AS/400 for the command.
 o getSystem
 public AS400 getSystem()
Returns the AS/400 on which the command is to be run.

Returns:
The AS/400 on which the command is to be run.
 o removeActionCompletedListener
 public synchronized void removeActionCompletedListener(ActionCompletedListener l)
Removes this ActionCompletedListener from the internal list. If the ActionCompletedListener is not on the list, nothing is done.

Parameters:
l - The ActionCompletedListener.
See Also:
addActionCompletedListener
 o removePropertyChangeListener
 public void removePropertyChangeListener(PropertyChangeListener l)
Removes this PropertyChangeListener from the internal list. If the PropertyChangeListener is not on the list, nothing is done.

Parameters:
l - The PropertyChangeListener.
See Also:
addPropertyChangeListener
 o removeVetoableChangeListener
 public void removeVetoableChangeListener(VetoableChangeListener l)
Removes this VetoableChangeListener from the JellyBeans internal list. If the VetoableChangeListener is not on the list, nothing is done.

Parameters:
l - The VetoableChangeListener.
See Also:
addVetoableChangeListener
 o run
 public boolean run() throws AS400SecurityException, ErrorCompletingRequestException, InterruptedException, ExtendedIllegalStateException, IOException
Runs the command on the AS/400. The command must be set prior to this call.

Returns:
true if command is successful; false otherwise.
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ErrorCompletingRequestException
If an error occurs before the request is completed.
Throws: InterruptedException
If this thread is interrupted.
Throws: IOException
If an error occurs while communicating with the AS/400.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
 o run
 public boolean run(String command) throws AS400SecurityException, ErrorCompletingRequestException, ExtendedIllegalStateException, InterruptedException, IOException, PropertyVetoException
Sets the command string and runs it on the AS/400.

Parameters:
command - The command to run.
Returns:
true if command is successful; false otherwise.
Throws: AS400SecurityException
If a security or authority error occurs.
Throws: ConnectionDroppedException
If the connection is dropped unexpectedly.
Throws: ErrorCompletingRequestException
If an error occurs before the request is completed.
Throws: InterruptedException
If this thread is interrupted.
Throws: IOException
If an error occurs while communicating with the AS/400.
Throws: ServerStartupException
If the AS/400 server cannot be started.
Throws: UnknownHostException
If the AS/400 system cannot be located.
Throws: PropertyVetoException
If the change is vetoed.
 o setCommand
 public void setCommand(String command) throws PropertyVetoException
Sets the command to run.

Parameters:
command - The command to run on the AS/400. The library list will be used to find the command.
Throws: PropertyVetoException
If the change is vetoed.
 o setSystem
 public void setSystem(AS400 system) throws ExtendedIllegalStateException, PropertyVetoException
Sets the AS/400 to run the command.

Parameters:
system - The AS/400 to run the command.
Throws: PropertyVetoException
If the change is vetoed.
 o toString
 public String toString()
Returns a short description of the object.

Returns:
The String describing this command call.
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index