public static final class WebSocket.CloseCode extends Object
WebSocket
close status code.
Some codes specified in the WebSocket Protocol are defined as named constants here. Others can be retrieved on demand.
This is a
value-based class;
use of identity-sensitive operations (including reference equality
(==
), identity hash code, or synchronization) on instances of
CloseCode
may have unpredictable results and should be avoided.
Modifier and Type | Field | Description |
---|---|---|
static WebSocket.CloseCode |
CANNOT_ACCEPT |
Indicates that an endpoint is terminating the connection because it
has received a type of data it cannot accept (e.g., an endpoint that
understands only text data MAY send this if it receives a binary
message).
|
static WebSocket.CloseCode |
GOING_AWAY |
Indicates that an endpoint is "going away", such as a server going
down or a browser having navigated away from a page.
|
static WebSocket.CloseCode |
NORMAL_CLOSURE |
Indicates a normal close, meaning that the purpose for which the
connection was established has been fulfilled.
|
static WebSocket.CloseCode |
NOT_CONSISTENT |
Indicates that an endpoint is terminating the connection because it
has received data within a message that was not consistent with the
type of the message (e.g., non-UTF-8 [RFC3629] data within a text
message).
|
static WebSocket.CloseCode |
PROTOCOL_ERROR |
Indicates that an endpoint is terminating the connection due to a
protocol error.
|
static WebSocket.CloseCode |
TOO_BIG |
Indicates that an endpoint is terminating the connection because it
has received a message that is too big for it to process.
|
static WebSocket.CloseCode |
UNEXPECTED_CONDITION |
Indicates that an endpoint is terminating the connection because it
encountered an unexpected condition that prevented it from fulfilling
the request.
|
static WebSocket.CloseCode |
VIOLATED_POLICY |
Indicates that an endpoint is terminating the connection because it
has received a message that violates its policy.
|
Modifier and Type | Method | Description |
---|---|---|
boolean |
equals(Object o) |
Compares this close code to the specified object.
|
int |
getCode() |
Returns a numerical representation of this close code.
|
int |
hashCode() |
Returns a hash code value for the object.
|
static WebSocket.CloseCode |
of(int code) |
Returns a
CloseCode from its numerical representation. |
String |
toString() |
Returns a human-readable representation of this close code.
|
public static final WebSocket.CloseCode CANNOT_ACCEPT
Numerical representation: 1003
public static final WebSocket.CloseCode GOING_AWAY
Numerical representation: 1001
public static final WebSocket.CloseCode NORMAL_CLOSURE
Numerical representation: 1000
public static final WebSocket.CloseCode NOT_CONSISTENT
Numerical representation: 1007
public static final WebSocket.CloseCode PROTOCOL_ERROR
Numerical representation: 1002
public static final WebSocket.CloseCode TOO_BIG
Numerical representation: 1009
public static final WebSocket.CloseCode UNEXPECTED_CONDITION
Numerical representation: 1011
public static final WebSocket.CloseCode VIOLATED_POLICY
CANNOT_ACCEPT
or TOO_BIG
) or if
there is a need to hide specific details about the policy.
Numerical representation: 1008
public static WebSocket.CloseCode of(int code)
CloseCode
from its numerical representation.
The given code
should be in the range 1000 <= code
<= 4999
, and should not be equal to any of the following codes:
1004
, 1005
, 1006
and 1015
.
code
- numerical representationIllegalArgumentException
- if code
violates any of the requirements abovepublic int getCode()
public boolean equals(Object o)
equals
in class Object
o
- the object to compare this CloseCode
againsttrue
iff the argument is a close code with the same
numerical representation as this oneObject.hashCode()
,
HashMap
public int hashCode()
Object
HashMap
.
The general contract of hashCode
is:
hashCode
method
must consistently return the same integer, provided no information
used in equals
comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.
equals(Object)
method, then calling the hashCode
method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode
method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hash tables.
As much as is reasonably practical, the hashCode method defined
by class Object
does return distinct integers for
distinct objects. (The hashCode may or may not be implemented
as some function of an object's memory address at some point
in time.)
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2016, Oracle and/or its affiliates. All rights reserved.
DRAFT 9-internal+0-2016-10-04-161205.jjg.dev.8159855.tools-spi