Class Response

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  Response.Status
      This interface acts as a namespace for the built-in status codes of the jDISC core.
    • Constructor Summary

      Constructors 
      Constructor Description
      Response​(int status)
      Creates a new instance of this class.
      Response​(int status, java.lang.Throwable error)
      Creates a new instance of this class.
    • Constructor Detail

      • Response

        public Response​(int status)
        Creates a new instance of this class.
        Parameters:
        status - The status code to assign to this.
      • Response

        public Response​(int status,
                        java.lang.Throwable error)
        Creates a new instance of this class.
        Parameters:
        status - The status code to assign to this.
        error - The error to assign to this.
    • Method Detail

      • context

        public java.util.Map<java.lang.String,​java.lang.Object> context()

        Returns the named application context objects. This data is not intended for network transport, rather they are intended for passing shared data between components of an Application.

        Modifying the context map is a thread-unsafe operation -- any changes made after calling ResponseHandler.handleResponse(Response) might never become visible to other threads, and might throw ConcurrentModificationExceptions in other threads.

        Returns:
        The context map.
      • headers

        public HeaderFields headers()

        Returns the set of header fields of this Request. These are the meta-data of the Request, and are not applied to any internal Container logic. Modifying headers is a thread-unsafe operation -- any changes made after calling ResponseHandler.handleResponse(Response) might never become visible to other threads, and might throw ConcurrentModificationExceptions in other threads.

        Returns:
        The header fields.
      • getStatus

        public int getStatus()

        Returns the status code of this response. This is an integer result code of the attempt to understand and satisfy the corresponding Request. It is encouraged, although not enforced, to use the built-in Response.Status codes whenever possible.

        Returns:
        The status code.
        See Also:
        setStatus(int)
      • setStatus

        public Response setStatus​(int status)

        Sets the status code of this response. This is an integer result code of the attempt to understand and satisfy the corresponding Request. It is encouraged, although not enforced, to use the built-in Response.Status codes whenever possible.

        Because access to this field is not guarded by any lock, any changes made after calling ResponseHandler.handleResponse(Response) might never become visible to other threads.

        Parameters:
        status - The status code to set.
        Returns:
        This, to allow chaining.
        See Also:
        getStatus()
      • getError

        public java.lang.Throwable getError()

        Returns the error of this response, or null if none has been set. This is typically non-null if the status indicates an unsuccessful response.

        Returns:
        The error.
        See Also:
        getError()
      • setError

        public Response setError​(java.lang.Throwable error)

        Sets the error of this response. It is encouraged, although not enforced, to use this field to attach additional information to an unsuccessful response.

        Because access to this field is not guarded by any lock, any changes made after calling ResponseHandler.handleResponse(Response) might never become visible to other threads.

        Parameters:
        error - The error to set.
        Returns:
        This, to allow chaining.
        See Also:
        getError()