Class Response

All Implemented Interfaces:
Map

public class Response extends SampMap
Represents an encoded SAMP response.
Since:
14 Jul 2008
Author:
Mark Taylor
  • Field Details

  • Constructor Details

    • Response

      public Response()
      Constructs an empty response.
    • Response

      public Response(Map map)
      Constructs a response based on an existing map.
      Parameters:
      map - map containing initial data for this object
    • Response

      public Response(String status, Map result, ErrInfo errinfo)
      Constructs a response with given status, result and error.
      Parameters:
      status - STATUS_KEY value
      result - RESULT_KEY value
      errinfo - ERROR_KEY value
  • Method Details

    • setStatus

      public void setStatus(String status)
      Sets the status value.
      Parameters:
      status - STATUS_KEY value
    • getStatus

      public String getStatus()
      Returns the status value.
      Returns:
      STATUS_KEY value
    • setResult

      public void setResult(Map result)
      Sets the result map.
      Parameters:
      result - RESULT_KEY value
    • getResult

      public Map getResult()
      Returns the result map.
      Returns:
      RESULT_KEY value
    • setErrInfo

      public void setErrInfo(Map errInfo)
      Sets the error object.
      Parameters:
      errInfo - ERROR_KEY value
      See Also:
    • getErrInfo

      public ErrInfo getErrInfo()
      Returns the error object.
      Returns:
      ERROR_KEY value as an ErrInfo
    • isOK

      public boolean isOK()
      Indicates whether the result was an unequivocal success.
      Returns:
      true iff getStatus()==OK_STATUS
    • check

      public void check()
      Description copied from class: SampMap
      Checks that this object is ready for use with the SAMP toolkit. As well as calling SampUtils.checkMap(java.util.Map) (ensuring that all keys are Strings, and all values Strings, Lists or Maps), subclass-specific invariants may be checked. In the case that there's something wrong, an informative DataException will be thrown.
      Overrides:
      check in class SampMap
    • createSuccessResponse

      public static Response createSuccessResponse(Map result)
      Returns a new response which is a success.
      Parameters:
      result - key-value map representing results of successful call
      Returns:
      new success response
    • createErrorResponse

      public static Response createErrorResponse(ErrInfo errinfo)
      Returns a new response which is an error.
      Parameters:
      errinfo - error information
      Returns:
      new error response
    • asResponse

      public static Response asResponse(Map map)
      Returns a map as a Response object.
      Parameters:
      map - map
      Returns:
      response