asjava.uniobjects
Class UniCommand

java.lang.Object
  extended byasjava.uniobjects.UniBase
      extended byasjava.uniobjects.UniCommand

public class UniCommand
extends UniBase

UniCommand is used to control remote command execution. With it users can run UniVerse commands or stored procedures on the server.

Since:
UNIOBJECTS 1.0
Version:
Version 1.0
Author:
David T. Meeks

Field Summary
 
Fields inherited from class asjava.uniobjects.UniBase
inPacket, outPacket, uniConnection, uniEncryptionType, uniParentSession, uniStatus
 
Method Summary
 void cancel()
          cancels all outstanding output from the executing command.
 void exec()
          executes the command that was set up using the setCommand method.
 int getAtSelected()
          returns the value of the @SELECTED variable from the server when the command has successfully completed
 int getBlockSize()
          returns the current block size, in bytes, that is in use for server communications.
 java.lang.String getCommand()
          returns the current execution string that was set with the setCommand method.
 int getSystemReturnCode()
          returns the current value of @SYSTEM.RETURN.CODE from the server
 void nextBlock()
          returns the next block of data from the command response, if the command response size was greater than the block size established with setBlockSize After each call to nextBlock, the response method can be called to retrieve the new block of data, and the status method can be called to determine the state of execution
 void reply(java.lang.String aReplyString)
          replies to a command execution that it currently in the UniS_REPLY state.
 java.lang.String response()
          returns the output from the command exec and reply methods
 void setBlockSize(int aBlockSize)
          Sets the current block size to the value passed in
 void setCommand(java.lang.String aCommand)
          establishes the command string or stored procedure to be run on the server
 int status()
          returns the current execution status
 
Methods inherited from class asjava.uniobjects.UniBase
getEncryptionType, isCommandActive, setEncryptionType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

cancel

public void cancel()
            throws UniCommandException
cancels all outstanding output from the executing command. It can only be called when the command status, as returned by status is either UVS_REPLY or UVS_MORE. Upon completion, the command status will be set to UVS_COMPLETE, allowing another command to be executed

Throws:
UniCommandException - is thrown upon failure conditions
Since:
UNIOBJECTS 1.0
See Also:
status(), exec()

exec

public void exec()
          throws UniCommandException
executes the command that was set up using the setCommand method. The results of the execution can be obtained using the response method. The status method can be used to get the current state of the command.

Throws:
UniCommandException - is thrown with error conditions
Since:
UNIOBJECTS 1.0
See Also:
setCommand(java.lang.String), status(), response()

getAtSelected

public int getAtSelected()
returns the value of the @SELECTED variable from the server when the command has successfully completed

Returns:
integer representing the value of the @SELECTED variable
Since:
UNIOBJECTS 1.0
See Also:
exec()

getBlockSize

public int getBlockSize()
returns the current block size, in bytes, that is in use for server communications. By default, a value of 0 is set, which denotes that all data should be returned.

Returns:
integer representing the current block size, in bytes.
Since:
UNIOBJECTS 1.0
See Also:
setBlockSize(int)

getCommand

public java.lang.String getCommand()
returns the current execution string that was set with the setCommand method.

Returns:
String representing the command to be executed
Since:
UNIOBJECTS 1.0
See Also:
setCommand(java.lang.String)

status

public int status()
returns the current execution status

Overrides:
status in class UniBase
Returns:
integer representing the current Command Status. Valid values are:
  • UVS_COMPLETE (0) - command has finished execution and is awaiting next command
  • UVS_REPLY (1) - server is waiting for input data. The reply can be sent using the reply method.
  • UVS_MORE (2) - denotes that there is more data waiting to be retrieved. Will only occur if the BlockSize is set to a non-zero value from setBlockSize. The response method will return a response block of BlockSize bytes each time it is called until no more data remains, at which point, the status will be changed to UniS_COMPLETESince:
    UNIOBJECTS 1.0
    See Also:
    reply(java.lang.String), setBlockSize(int), getBlockSize(), nextBlock()

getSystemReturnCode

public int getSystemReturnCode()
returns the current value of @SYSTEM.RETURN.CODE from the server

Returns:
integer representing the current state of the @SYSTEM.RETURN.CODE
Since:
UNIOBJECTS 1.0

nextBlock

public void nextBlock()
               throws UniCommandException
returns the next block of data from the command response, if the command response size was greater than the block size established with setBlockSize After each call to nextBlock, the response method can be called to retrieve the new block of data, and the status method can be called to determine the state of execution

Throws:
UniCommandException - is thrown if an error occurs
Since:
UNIOBJECTS 1.0
See Also:
setBlockSize(int), nextBlock(), response(), status()

reply

public void reply(java.lang.String aReplyString)
           throws UniCommandException
replies to a command execution that it currently in the UniS_REPLY state. Often, a server side command may require user input. Use this method to send the input requested.

Parameters:
aReplyString - reply string to be sent to the server
Throws:
UniCommandException - is thrown if an error occurs
Since:
UNIOBJECTS 1.0
See Also:
status()

response

public java.lang.String response()
returns the output from the command exec and reply methods

Returns:
String output from the exec or reply methods
See Also:
exec(), reply(java.lang.String)

setBlockSize

public void setBlockSize(int aBlockSize)
Sets the current block size to the value passed in

Parameters:
aBlockSize - integer representing the new block size, in bytes. This is the amount of data retrieved with each response method.
Since:
UNIOBJECTS 1.0
See Also:
getBlockSize(), response()

setCommand

public void setCommand(java.lang.String aCommand)
establishes the command string or stored procedure to be run on the server

Parameters:
aCommand - command string to be executed on the server
Since:
UNIOBJECTS 1.0
See Also:
getCommand(), exec()