public final class ReasonForClosure extends Object
ReasonForClosure
is a close code (which is a number) and a close reason (which a String that may be empty).
As explained in section 7.4. Status Codes, "an endpoint may indicate a reason for closure" when sending a close frame. If it does so, the reason for closure is composed of two parts (section 5.5.1 Close):
CloseCodes
Constructor and Description |
---|
ReasonForClosure(int code,
String reason) |
Modifier and Type | Method and Description |
---|---|
int |
getCloseCode()
Get the close code.
|
String |
getCloseReason()
Get the close reason (may be an empty string).
|
ReasonForClosure |
setCode(int code)
Change the close code.
|
ReasonForClosure |
setReason(String reason)
Change the close reason.
|
String |
toString()
Returns a string representation of the object.
|
public ReasonForClosure(int code, String reason)
code
- the close codereason
- a message that describes why the connection has been closed. It may be empty. If it is null, it is converted to the empty string.CloseCodes
public int getCloseCode()
public String getCloseReason()
public ReasonForClosure setCode(int code)
code
- the new codepublic ReasonForClosure setReason(String reason)
reason
- the new reason message. It may be empty. If it is null, it is converted to the empty string.public String toString()
Object
toString
method returns a
string that "textually represents" this object. The result should be a concise but informative
representation that is easy for a person to read. It is recommended that all subclasses override
this method.
The toString
method for class Object
returns a string consisting of the name of
the class of which the object is an instance, the at-sign character `@
', and the unsigned
hexadecimal representation of the hash code of the object. In other words, this method returns a
string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())