chrriis.dj.nativeswing.swtimpl
Class CommandMessage

java.lang.Object
  extended by chrriis.dj.nativeswing.swtimpl.Message
      extended by chrriis.dj.nativeswing.swtimpl.CommandMessage
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
LocalMessage

public abstract class CommandMessage
extends Message

A type of message that executes a command with optional arguments and returns a result.

Author:
Christopher Deckers
See Also:
Serialized Form

Constructor Summary
CommandMessage()
          Construct a command message.
 
Method Summary
 void asyncExec(boolean isTargetNativeSide, Object... args)
          Execute that message asynchronously with the given arguments.
abstract  Object run(Object[] args)
          Run the message.
protected  Object runCommand()
           
 Object syncExec(boolean isTargetNativeSide, Object... args)
          Execute that message synchronously with the given arguments and return the result.
 String toString()
           
 
Methods inherited from class chrriis.dj.nativeswing.swtimpl.Message
asyncSend, isValid, syncSend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CommandMessage

public CommandMessage()
Construct a command message.

Method Detail

asyncExec

public void asyncExec(boolean isTargetNativeSide,
                      Object... args)
Execute that message asynchronously with the given arguments.

Parameters:
isTargetNativeSide - true if the target is the native side, false otherwise.
args - the arguments, which must be serializable.

syncExec

public Object syncExec(boolean isTargetNativeSide,
                       Object... args)
Execute that message synchronously with the given arguments and return the result.

Parameters:
isTargetNativeSide - true if the target is the native side, false otherwise.
args - the arguments, which must be serializable.
Returns:
the result of the execution.

runCommand

protected Object runCommand()
                     throws Exception
Throws:
Exception

run

public abstract Object run(Object[] args)
                    throws Exception
Run the message.

Parameters:
args - the arguments that were specified for that command, or an empty array if none were specified.
Returns:
the result that may be passed back to the caller.
Throws:
Exception - any exception that may happen, and which would be passed back if it is a synchronous execution.

toString

public String toString()
Overrides:
toString in class Message