Skip to content

Package: ResponseStatus

ResponseStatus

nameinstructionbranchcomplexitylinemethod
ResponseStatus(String, int, int, String)
M: 14 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getResponseStatus(short)
M: 43 C: 0
0%
M: 19 C: 0
0%
M: 19 C: 0
0%
M: 20 C: 0
0%
M: 1 C: 0
0%
message()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 220 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 19 C: 0
0%
M: 1 C: 0
0%
status()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 2012, 2017 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Public License v. 2.0, which is available at
6: * http://www.eclipse.org/legal/epl-2.0.
7: *
8: * This Source Code may also be made available under the following Secondary
9: * Licenses when the conditions for such availability set forth in the
10: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11: * version 2 with the GNU Classpath Exception, which is available at
12: * https://www.gnu.org/software/classpath/license.html.
13: *
14: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15: */
16:
17: package org.glassfish.grizzly.memcached;
18:
19: /**
20: * Defines response's status of the memcached's binary protocol
21: * <p>
22: * See http://code.google.com/p/memcached/wiki/BinaryProtocolRevamped#Response_Status
23: *
24: * @author Bongjae Chang
25: */
26: public enum ResponseStatus {
27: No_Error(0x0000, "No error"),
28: Key_Not_Found(0x0001, "Key not found"),
29: Key_Exists(0x0002, "Key exists"),
30: Value_Too_Large(0x0003, "Value too large"),
31: Invalid_Arguments(0x0004, "Invalid arguments"),
32: Item_Not_Stored(0x0005, "Item not stored"),
33: Incr_Decr_On_NonNumeric_Value(0x0006, "Incr/Decr on non-numeric value"),
34: VBucket_Belongs_To_Another_Server(0x0007, "The vbucket belongs to another server"),
35: Authentication_Error(0x0008, "Authentication error"),
36: Authentication_Continue(0x0009, "Authentication continue"),
37: Authentication_Required(0x0020, "Authentication required or not successful"), // ??
38: Further_Authentication_Required(0x0021, "Further authentication steps required"), // ??
39: Unknown_Command(0x0081, "Unknown command"),
40: Out_Of_Memory(0x0082, "Out of memory"),
41: Not_Supported(0x0083, "Not supported"),
42: Internal_Error(0x0084, "Internal error"),
43: Busy(0x0085, "Busy"),
44: Temporary_Failure(0x0086, "Temporary failure");
45:
46: private final short status;
47: private final String message;
48:
49: private ResponseStatus(int status, String message) {
50: this.status = (short) (status & 0xffff);
51: this.message = message;
52: }
53:
54: public short status() {
55: return status;
56: }
57:
58: public String message() {
59: return message;
60: }
61:
62: public static ResponseStatus getResponseStatus(final short status) {
63:• switch (status) {
64: case 0x0000:
65: return No_Error;
66: case 0x0001:
67: return Key_Not_Found;
68: case 0x0002:
69: return Key_Exists;
70: case 0x0003:
71: return Value_Too_Large;
72: case 0x0004:
73: return Invalid_Arguments;
74: case 0x0005:
75: return Item_Not_Stored;
76: case 0x0006:
77: return Incr_Decr_On_NonNumeric_Value;
78: case 0x0007:
79: return VBucket_Belongs_To_Another_Server;
80: case 0x0008:
81: return Authentication_Error;
82: case 0x0009:
83: return Authentication_Continue;
84: case 0x0020:
85: return Authentication_Required;
86: case 0x0021:
87: return Further_Authentication_Required;
88: case 0x0081:
89: return Unknown_Command;
90: case 0x0082:
91: return Out_Of_Memory;
92: case 0x0083:
93: return Not_Supported;
94: case 0x0084:
95: return Internal_Error;
96: case 0x0085:
97: return Busy;
98: case 0x0086:
99: return Temporary_Failure;
100: default:
101: throw new IllegalArgumentException("invalid status");
102: }
103: }
104: }