org.simpleframework.http.socket
Class Reason

java.lang.Object
  extended by 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.

Author:
Niall Gallagher

Constructor Summary
Reason(CloseCode code)
          Constructor for the Reason object.
Reason(CloseCode code, String text)
          Constructor for the Reason object.
 
Method Summary
 CloseCode getCode()
          This is used to get the RFC 6455 code describing the type of close event.
 String getText()
          This is used to get the textual description for the closure.
 String toString()
          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
 

Constructor Detail

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 Detail

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


Copyright © 2014. All Rights Reserved.