javawebparts.misc.chain
Class Result

java.lang.Object
  |
  +--javawebparts.misc.chain.Result

public class Result
extends java.lang.Object

This class is returned by a Command or Chain. It can be returned by any of the three methds in the Command interface, and can optionally include additional information for the callers' use.

Author:
Frank W. Zammetti.

Field Summary
static int ABORT
          This value is returned by a Command when the Chain should be stopped due to an expected logical reason, and it is also returned by a Chain when any Command returns this value.
private  int code
          The result of the Command execution.
private  java.lang.String extraInfo
          This is arbitrary extra information that a Command can return for the callers' use.
static int FAIL
          This value is returned by a Command when the Chain should be stopped due to an unexpected failure reason, and it is also returned by a Chain when any Command returns this value.
static int JUMP_TO_COMMAND
          This value is returned by a Command when the Chain should jump to a named Command.
static int REDO_COMMAND
          This value is returned by a Command when the Command should execute again.
static int RESTART_CHAIN
          This value is returned by a Command when the Chain should be restarted.
static int SUCCESS
          This value is returned by a Command to indicate the Chain should continue, and it is also returned by a Chain when it completes successfully.
private  java.lang.String targetCommand
          A command ID to be returned along with the result code.
 
Constructor Summary
Result(int inCode)
          Construct a Result with the given result code and no additional information.
Result(int inCode, java.lang.String inExtraInfo)
          Construct a Result with the given result code and one piece of additional information.
Result(int inCode, java.lang.String inExtraInfo, java.lang.String inTargetCommand)
          Construct a Result with the given result code and one piece of additional information and a target Command to jump to or call.
 
Method Summary
 int getCode()
          Gets the result code stored in this Result.
 java.lang.String getExtraInfo()
          Gets the extra info stored in this Result.
 java.lang.String getTargetCommand()
          Gets the target Command to be stored in this Result.
 void setCode(int inCode)
          Sets the result code of this Resule.
 void setExtraInfo(java.lang.String inExtraInfo)
          Sets the extra info stored in this Result.
 void setTargetCommand(java.lang.String inTargetCommand)
          Sets the target Command stored in this Result.
 java.lang.String toString()
          Overridden toString method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SUCCESS

public static final int SUCCESS
This value is returned by a Command to indicate the Chain should continue, and it is also returned by a Chain when it completes successfully. It is also returned by a Command when its init() or cleanup() method is called and it executes successfully.

See Also:
Constant Field Values

FAIL

public static final int FAIL
This value is returned by a Command when the Chain should be stopped due to an unexpected failure reason, and it is also returned by a Chain when any Command returns this value. Note that a failure is different from an Abort because a failure is an unexpected condition that is not supposed to happen, where an abort is when the logic of a Command needs to terminate the Chain. It is also returned by a Command when its init() or cleanup() method is called and it executes successfully.

See Also:
Constant Field Values

ABORT

public static final int ABORT
This value is returned by a Command when the Chain should be stopped due to an expected logical reason, and it is also returned by a Chain when any Command returns this value. Note that a failure is different from an Abort because a failure is an unexpected condition that is not supposed to happen, where an abort is when the logic of a Command needs to terminate the Chain. It is also returned by a Command when its init() or cleanup() method is called and it executes successfully.

See Also:
Constant Field Values

RESTART_CHAIN

public static final int RESTART_CHAIN
This value is returned by a Command when the Chain should be restarted.

See Also:
Constant Field Values

REDO_COMMAND

public static final int REDO_COMMAND
This value is returned by a Command when the Command should execute again. This should of course be used with caution as it can easily result in an endless loop.

See Also:
Constant Field Values

JUMP_TO_COMMAND

public static final int JUMP_TO_COMMAND
This value is returned by a Command when the Chain should jump to a named Command. Think of this like a goto statement.

See Also:
Constant Field Values

code

private int code
The result of the Command execution.


targetCommand

private java.lang.String targetCommand
A command ID to be returned along with the result code. Some results will need this, like JUMP_TO_COMMAND and CALL_COMMAND for instance.


extraInfo

private java.lang.String extraInfo
This is arbitrary extra information that a Command can return for the callers' use.

Constructor Detail

Result

public Result(int inCode)
Construct a Result with the given result code and no additional information.

Parameters:
inCode - The result code to be stored in this Result.

Result

public Result(int inCode,
              java.lang.String inExtraInfo)
Construct a Result with the given result code and one piece of additional information.

Parameters:
inCode - The result code to be stored in this Result.
inExtraInfo - The extra info to be stored in this Result.

Result

public Result(int inCode,
              java.lang.String inExtraInfo,
              java.lang.String inTargetCommand)
Construct a Result with the given result code and one piece of additional information and a target Command to jump to or call.

Parameters:
inCode - The result code to be stored in this Result.
inExtraInfo - The extra info to be stored in this Result.
inTargetCommand - The target Command to be stored in this Result.
Method Detail

setCode

public void setCode(int inCode)
Sets the result code of this Resule.

Parameters:
inCode - The result code to be stored in this Result.

getCode

public int getCode()
Gets the result code stored in this Result.

Returns:
The result code stored in this Result.

setExtraInfo

public void setExtraInfo(java.lang.String inExtraInfo)
Sets the extra info stored in this Result.

Parameters:
inExtraInfo - The extra info to be stored in this Result.

getExtraInfo

public java.lang.String getExtraInfo()
Gets the extra info stored in this Result.

Returns:
The extra info stored in this Result.

setTargetCommand

public void setTargetCommand(java.lang.String inTargetCommand)
Sets the target Command stored in this Result.

Parameters:
inTargetCommand - The target command to be stored in this Result.

getTargetCommand

public java.lang.String getTargetCommand()
Gets the target Command to be stored in this Result.

Returns:
The target Command stored in this Result.

toString

public java.lang.String toString()
Overridden toString method.

Overrides:
toString in class java.lang.Object
Returns:
String representation of this bean.


Copyright © 2005 Frank W. Zammetti