Class CommandResult

java.lang.Object
org.deltava.commands.CommandResult
All Implemented Interfaces:
Serializable

public class CommandResult extends Object implements Serializable
Returns the results of a web Command. All commands need to return an object of this class when completing their execute() method, and based on the data contained within this class the controller servlet will perform further processing.
Since:
1.0
Version:
2.3
Author:
Luke
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    CommandResult(String resultPage)
    Create a new CommandResult forwarding the Controller to a new servlet.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    A helper method to "stop the clock" for execution and setTime().
    long
    Return the back-end utilization time of the last command.
    int
    Returns the HTTP status code to return.
    boolean
    Did the command complete successfully?
    long
    Return the execution time of the last command.
    The type of action the controller should perform next.
    Returns the URL the controller should forward to.
    void
    setBackEndTime(long time)
    Set the total back-end usage time for this Command.
    void
    setHttpCode(int code)
    Updates the HTTP status code to return on completion.
    void
    setSuccess(boolean success)
    Mark if the previous Command complated successfully
    void
    setTime(long time)
    Set the total execution time for this Command
    void
    Sets the result type of this command.
    void
    Set the URL to process next.
    void
    setURL(String cmdName, String opName, int id)
    Sets the URL to process next, when executing a command with parameters and a numeric ID.
    void
    setURL(String cmdName, String opName, String id)
    Sets the URL to process next, when executing a command with parameters.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CommandResult

      CommandResult(String resultPage)
      Create a new CommandResult forwarding the Controller to a new servlet.
      Parameters:
      resultPage - the resource name to forward to
  • Method Details

    • getSuccess

      public boolean getSuccess()
      Did the command complete successfully?
      Returns:
      TRUE if the command completed successfully, otherwise FALSE
      See Also:
    • getTime

      public long getTime()
      Return the execution time of the last command.
      Returns:
      the time the last command took to execute, in milliseconds
      See Also:
    • getBackEndTime

      public long getBackEndTime()
      Return the back-end utilization time of the last command.
      Returns:
      the time the back-end was used, in milliseconds. This is useful for determining usage of shared back-end resources, like JDBC or JNDI connections.
      See Also:
    • getURL

      public String getURL()
      Returns the URL the controller should forward to.
      Returns:
      the URL/resource to forward to
    • getHttpCode

      public int getHttpCode()
      Returns the HTTP status code to return.
      Returns:
      the HTTP status code
      See Also:
    • getType

      public ResultType getType()
      The type of action the controller should perform next.
      Returns:
      the action type for the controller
    • complete

      public void complete()
      A helper method to "stop the clock" for execution and setTime().
      See Also:
    • setSuccess

      public void setSuccess(boolean success)
      Mark if the previous Command complated successfully
      Parameters:
      success - TRUE if the command completed successfully, otherwise FALSE
    • setTime

      public void setTime(long time)
      Set the total execution time for this Command
      Parameters:
      time - the time in milliseconds
      See Also:
    • setBackEndTime

      public void setBackEndTime(long time)
      Set the total back-end usage time for this Command.
      Parameters:
      time - the back-end usage time in milliseconds
      See Also:
    • setHttpCode

      public void setHttpCode(int code)
      Updates the HTTP status code to return on completion.
      Parameters:
      code - the HTTP status code
      Throws:
      IllegalStateException - if result has not been set to RESULT_HTTPCODE
      See Also:
    • setURL

      public void setURL(String url)
      Set the URL to process next.
      Parameters:
      url - the URL/resource name
    • setURL

      public void setURL(String cmdName, String opName, String id)
      Sets the URL to process next, when executing a command with parameters.
      Parameters:
      cmdName - the command Name
      opName - the optional operation name
      id - the optional ID
    • setURL

      public void setURL(String cmdName, String opName, int id)
      Sets the URL to process next, when executing a command with parameters and a numeric ID.
      Parameters:
      cmdName - the command Name
      opName - the optional operation name
      id - the ID, which will be converted to hexadecimal and prepended with "0x"
    • setType

      public void setType(ResultType type)
      Sets the result type of this command. This tells the controller servlet what kind of action to perform next on the URL.
      Parameters:
      type - the result type
      Throws:
      IllegalArgumentException - if resultCode is negative or not listed in RESULT
      See Also: