Class Reason

java.lang.Object
org.simpleframework.http.socket.Reason

public class Reason extends Object
The Reason object is used to hold a textual reason for connection closure and an RFC 6455 defined code. When a connection is to be closed a control frame with an opcode of close is sent with the text reason, if one is provided.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final CloseCode
    This is the close code to be sent with a control frame.
    private final String
    This is the textual description of the close reason.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for the Reason object.
    Reason(CloseCode code, String text)
    Constructor for the Reason object.
  • Method Summary

    Modifier and Type
    Method
    Description
    This is used to get the RFC 6455 code describing the type of close event.
    This is used to get the textual description for the closure.
    This is used to provide a textual representation of the reason.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • code

      private final CloseCode code
      This is the close code to be sent with a control frame.
    • text

      private final String text
      This is the textual description of the close reason.
  • Constructor Details

    • Reason

      public Reason(CloseCode code)
      Constructor for the Reason object. This is used to create a reason and a textual description of that reason to be delivered as a control frame.
      Parameters:
      code - this is the code to be sent with the frame
    • Reason

      public Reason(CloseCode code, String text)
      Constructor for the Reason object. This is used to create a reason and a textual description of that reason to be delivered as a control frame.
      Parameters:
      code - this is the code to be sent with the frame
      text - this is textual description of the close reason
  • Method Details

    • getCode

      public CloseCode getCode()
      This is used to get the RFC 6455 code describing the type of close event. It is the code that should be used by applications to determine why the connection was terminated.
      Returns:
      returns the close code for the connection
    • getText

      public String getText()
      This is used to get the textual description for the closure. In many scenarios there will be no textual reason as it is an optional attribute.
      Returns:
      this returns the description for the closure
    • toString

      public String toString()
      This is used to provide a textual representation of the reason. For consistency this will only return the enumerated value for the close code, or if none exists a "null" text string.
      Overrides:
      toString in class Object
      Returns:
      this returns a string representation of the reason