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 messages returned by CommandCall do not include
help text. MessageFile provides an easy way to get help
for a messsage.
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, MessageFile
-
CommandCall()
- Constructs a CommandCall object.
-
CommandCall(AS400)
- Constructs a CommandCall object.
-
CommandCall(AS400, String)
- Constructs a CommandCall object.
-
addActionCompletedListener(ActionCompletedListener)
- Adds an ActionCompletedListener.
-
addPropertyChangeListener(PropertyChangeListener)
- Adds a PropertyChangeListener.
-
addVetoableChangeListener(VetoableChangeListener)
- Adds a VetoableChangeListener.
-
getCommand()
- Returns the command to run.
-
getMessageList()
- Returns the list of AS/400 messages returned from running the command.
-
getMessageList(int)
- Returns an AS/400 message returned from running the command.
-
getSystem()
- Returns the AS/400 on which the command is to be run.
-
removeActionCompletedListener(ActionCompletedListener)
- Removes this ActionCompletedListener from the internal list.
-
removePropertyChangeListener(PropertyChangeListener)
- Removes this PropertyChangeListener from the internal list.
-
removeVetoableChangeListener(VetoableChangeListener)
- Removes this VetoableChangeListener from the JellyBeans internal list.
-
run()
- Runs the command on the AS/400.
-
run(String)
- Sets the command string and runs it on the AS/400.
-
setCommand(String)
- Sets the command to run.
-
setSystem(AS400)
- Sets the AS/400 to run the command.
-
toString()
- Returns a short description of the object.
CommandCall
public CommandCall()
- Constructs a CommandCall object.
The system and the command string must be set later.
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.
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.
addActionCompletedListener
public synchronized void addActionCompletedListener(ActionCompletedListener listener)
- 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:
- listener - The ActionCompletedListener.
- See Also:
- removeActionCompletedListener
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener listener)
- 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:
- listener - The PropertyChangeListener.
- See Also:
- removePropertyChangeListener
addVetoableChangeListener
public void addVetoableChangeListener(VetoableChangeListener listener)
- Adds a VetoableChangeListener.
The specified VetoableChangeListeners vetoableChange method will
be called each time the value of any constrained property is changed.
- Parameters:
- listener - The VetoableChangeListener.
- See Also:
- removeVetoableChangeListener
getCommand
public String getCommand()
- Returns the command to run. It may return "" if the command has not been
previously set by the constructor, setCommand, or run.
- Returns:
- The command to run.
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.
getMessageList
public AS400Message getMessageList(int index)
- Returns an AS/400 message 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.
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.
removeActionCompletedListener
public synchronized void removeActionCompletedListener(ActionCompletedListener listener)
- Removes this ActionCompletedListener from the internal list.
If the ActionCompletedListener is not on the list, nothing is done.
- Parameters:
- listener - The ActionCompletedListener.
- See Also:
- addActionCompletedListener
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener listener)
- Removes this PropertyChangeListener from the internal list.
If the PropertyChangeListener is not on the list, nothing is done.
- Parameters:
- listener - The PropertyChangeListener.
- See Also:
- addPropertyChangeListener
removeVetoableChangeListener
public void removeVetoableChangeListener(VetoableChangeListener listener)
- Removes this VetoableChangeListener from the JellyBeans internal list.
If the VetoableChangeListener is not on the list, nothing is done.
- Parameters:
- listener - The VetoableChangeListener.
- See Also:
- addVetoableChangeListener
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.
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.
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.
setSystem
public void setSystem(AS400 system) throws ExtendedIllegalStateException, PropertyVetoException
- Sets the AS/400 to run the command. The system cannot be changed
once a connection is made to the server.
- Parameters:
- system - The AS/400 to run the command.
- Throws: PropertyVetoException
- If the change is vetoed.
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