Package org.simpleframework.http.socket
Class Reason
- java.lang.Object
-
- org.simpleframework.http.socket.Reason
-
public class Reason extends java.lang.Object
TheReason
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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CloseCode
getCode()
This is used to get the RFC 6455 code describing the type of close event.java.lang.String
getText()
This is used to get the textual description for the closure.java.lang.String
toString()
This is used to provide a textual representation of the reason.
-
-
-
Constructor Detail
-
Reason
public Reason(CloseCode code)
Constructor for theReason
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, java.lang.String text)
Constructor for theReason
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 frametext
- 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 java.lang.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 java.lang.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 classjava.lang.Object
- Returns:
- this returns a string representation of the reason
-
-