|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.as400.access.CommandCall
The CommandCall class represents an AS/400 command 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 system = new AS400("Hal"); CommandCall command = new CommandCall(system); try { // Run the command "CRTLIB FRED" if (command.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 = command.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 " + command.getCommand() + " did not run!"); } // done with the system system.disconnectAllServices();
NOTE: When getting the AS400Message list from commands, users no longer have to create a MessageFile to obtain the program help text. The load() method can be used to retrieve additional message information. Then the getHelp() method can be called directly on the AS400Message object returned from getMessageList(). Here is an example:
if (command.run("myCmd") != true) { // Show messages. AS400Message[] messageList = command.getMessageList(); for (int i = 0; i < messageList.length; ++i) { //Show each message. System.out.println(messageList[i].getText()); // Load additional message information. messageList[i].load(); //Show help text. System.out.println(messageList[i].getHelp()); } }
AS400Message
,
MessageFile
, Serialized FormConstructor Summary | |
CommandCall()
Constructs a CommandCall object. |
|
CommandCall(AS400 system)
Constructs a CommandCall object. |
|
CommandCall(AS400 system,
java.lang.String command)
Constructs a CommandCall object. |
Method Summary | |
void |
addActionCompletedListener(ActionCompletedListener listener)
Adds an ActionCompletedListener. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener. |
void |
addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Adds a VetoableChangeListener. |
java.lang.String |
getCommand()
Returns the command to run. |
RJob |
getJob()
Returns an RJob object which represents the AS/400 job in which the command will be run. |
AS400Message[] |
getMessageList()
Returns the list of AS/400 messages returned from running the command. |
AS400Message |
getMessageList(int index)
Returns an AS/400 message returned from running the command. |
AS400 |
getSystem()
Returns the AS/400 on which the command is to be run. |
java.lang.Thread |
getSystemThread()
Returns the AS/400 thread on which the command would be run, if it were to be called on-thread. |
boolean |
isStayOnThread()
Indicates whether or not the AS/400 command will actually get run on the current thread. |
boolean |
isThreadSafe()
Indicates whether or not the AS/400 command will be assumed thread-safe, according to the settings specified by setThreadSafe() or the com.ibm.as400.access.CommandCall.threadSafe property. |
void |
removeActionCompletedListener(ActionCompletedListener listener)
Removes this ActionCompletedListener. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes this PropertyChangeListener. |
void |
removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Removes this VetoableChangeListener. |
boolean |
run()
Runs the command on the AS/400. |
boolean |
run(byte[] command)
Runs the command on the AS/400. |
boolean |
run(java.lang.String command)
Sets the command string and runs it on the AS/400. |
void |
setCommand(java.lang.String command)
Sets the command to run. |
void |
setSystem(AS400 system)
Sets the AS/400 to run the command. |
void |
setThreadSafe(boolean threadSafe)
Specifies whether or not the command should be assumed thread-safe. |
java.lang.String |
toString()
Returns the string representation of this command call object. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public CommandCall()
public CommandCall(AS400 system)
system
- The AS/400 on which to issue the command.public CommandCall(AS400 system, java.lang.String command)
system
- The AS/400 on which to issue the command.command
- The command to run on the AS/400. If the command is not library qualified, the library list will be used to find the command.Method Detail |
public void addActionCompletedListener(ActionCompletedListener listener)
listener
- The ActionCompletedListener.removeActionCompletedListener(com.ibm.as400.access.ActionCompletedListener)
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The PropertyChangeListener.removePropertyChangeListener(java.beans.PropertyChangeListener)
public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
listener
- The VetoableChangeListener.removeVetoableChangeListener(java.beans.VetoableChangeListener)
public java.lang.String getCommand()
public RJob getJob() throws AS400SecurityException, ErrorCompletingRequestException, java.io.IOException, java.lang.InterruptedException
AS400.disconnectService()
or AS400.disconnectAllServices()
.
public AS400Message[] getMessageList()
public AS400Message getMessageList(int index)
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.public AS400 getSystem()
public java.lang.Thread getSystemThread() throws AS400SecurityException, java.io.IOException
public boolean isStayOnThread() throws AS400SecurityException, ErrorCompletingRequestException, java.io.IOException, java.lang.InterruptedException
isThreadSafe()
public boolean isThreadSafe() throws AS400SecurityException, ErrorCompletingRequestException, java.io.IOException, java.lang.InterruptedException
setThreadSafe()
or the com.ibm.as400.access.CommandCall.threadSafe
property.
isStayOnThread()
public void removeActionCompletedListener(ActionCompletedListener listener)
listener
- The ActionCompletedListener.addActionCompletedListener(com.ibm.as400.access.ActionCompletedListener)
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The PropertyChangeListener.addPropertyChangeListener(java.beans.PropertyChangeListener)
public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
listener
- The VetoableChangeListener.addVetoableChangeListener(java.beans.VetoableChangeListener)
public boolean run() throws AS400SecurityException, ErrorCompletingRequestException, java.io.IOException, java.lang.InterruptedException
public boolean run(java.lang.String command) throws AS400SecurityException, ErrorCompletingRequestException, java.io.IOException, java.lang.InterruptedException, java.beans.PropertyVetoException
command
- The command to run on the AS/400. If the command is not library qualified, the library list will be used to find the command.public boolean run(byte[] command) throws AS400SecurityException, ErrorCompletingRequestException, java.io.IOException, java.lang.InterruptedException, java.beans.PropertyVetoException
Unlike the run method that takes a string, this method will not look up the thread safety of the command. If this command is to be run on-thread when running on the AS/400's JVM, setThreadSafe(true) must be called by the application.
command
- The command to run on the AS/400.public void setCommand(java.lang.String command) throws java.beans.PropertyVetoException
command
- The command to run on the AS/400. If the command is not library qualified, the library list will be used to find the command.public void setSystem(AS400 system) throws java.beans.PropertyVetoException
system
- The AS/400 to run the command.public void setThreadSafe(boolean threadSafe)
threadSafe
- true if the command should be assumed to be thread-safe; false otherwise.isThreadSafe()
,
isStayOnThread()
public java.lang.String toString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |