MCPcopy Index your code
hub / github.com/apache/tomcat / Util

Class Util

java/org/apache/tomcat/websocket/Util.java:62–685  ·  view source on GitHub ↗

Utility class for internal use only within the org.apache.tomcat.websocket package.

Source from the content-addressed store, hash-verified

60 * Utility class for internal use only within the {@link org.apache.tomcat.websocket} package.
61 */
62public class Util {
63
64 private static final StringManager sm = StringManager.getManager(Util.class);
65 private static final Queue<SecureRandom> randoms = new ConcurrentLinkedQueue<>();
66
67 private Util() {
68 // Hide default constructor
69 }
70
71
72 static boolean isControl(byte opCode) {
73 return (opCode & 0x08) != 0;
74 }
75
76
77 static boolean isText(byte opCode) {
78 return opCode == Constants.OPCODE_TEXT;
79 }
80
81
82 static boolean isContinuation(byte opCode) {
83 return opCode == Constants.OPCODE_CONTINUATION;
84 }
85
86
87 static CloseCode getCloseCode(int code) {
88 if (code > 2999 && code < 5000) {
89 return CloseCodes.getCloseCode(code);
90 }
91 return switch (code) {
92 case 1000 -> CloseCodes.NORMAL_CLOSURE;
93 case 1001 -> CloseCodes.GOING_AWAY;
94 case 1002 -> CloseCodes.PROTOCOL_ERROR;
95 case 1003 -> CloseCodes.CANNOT_ACCEPT;
96 case 1004 ->
97 // Should not be used in a close frame
98 // return CloseCodes.RESERVED;
99 CloseCodes.PROTOCOL_ERROR;
100 case 1005 ->
101 // Should not be used in a close frame
102 // return CloseCodes.NO_STATUS_CODE;
103 CloseCodes.PROTOCOL_ERROR;
104 case 1006 ->
105 // Should not be used in a close frame
106 // return CloseCodes.CLOSED_ABNORMALLY;
107 CloseCodes.PROTOCOL_ERROR;
108 case 1007 -> CloseCodes.NOT_CONSISTENT;
109 case 1008 -> CloseCodes.VIOLATED_POLICY;
110 case 1009 -> CloseCodes.TOO_BIG;
111 case 1010 -> CloseCodes.NO_EXTENSION;
112 case 1011 -> CloseCodes.UNEXPECTED_CONDITION;
113 case 1012 ->
114 // Not in RFC6455
115 // return CloseCodes.SERVICE_RESTART;
116 CloseCodes.PROTOCOL_ERROR;
117 case 1013 ->
118 // Not in RFC6455
119 // return CloseCodes.TRY_AGAIN_LATER;

Callers

nothing calls this directly

Calls 1

getManagerMethod · 0.95

Tested by

no test coverage detected