equal
deleted
inserted
replaced
|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
|
2 // Use of this source code is governed by a BSD-style license that can be |
|
3 // found in the LICENSE file. |
|
4 |
|
5 package org.chromium.sdk.internal; |
|
6 |
|
7 import java.util.HashMap; |
|
8 import java.util.Map; |
|
9 |
|
10 /** |
|
11 * A V8 debugger attachment/detachment operation result. |
|
12 */ |
|
13 public enum Result { |
|
14 |
|
15 /** The operation went fine. */ |
|
16 OK(0), |
|
17 |
|
18 /** The tab attachment status is illegal for the specified operation. */ |
|
19 ILLEGAL_TAB_STATE(1), |
|
20 |
|
21 /** The tab specified is not known. */ |
|
22 UNKNOWN_TAB(2), |
|
23 |
|
24 /** A generic debugger error occurred. */ |
|
25 DEBUGGER_ERROR(3), |
|
26 |
|
27 /** An unknown command was specified. */ |
|
28 UNKNOWN_COMMAND(4), ; |
|
29 |
|
30 public final int code; |
|
31 |
|
32 private static final Map<Integer, Result> codeToResult = new HashMap<Integer, Result>(); |
|
33 |
|
34 static { |
|
35 for (Result result : values()) { |
|
36 codeToResult.put(result.code, result); |
|
37 } |
|
38 } |
|
39 |
|
40 private Result(int code) { |
|
41 this.code = code; |
|
42 } |
|
43 |
|
44 /** |
|
45 * Gets a Result value for the given code. |
|
46 * |
|
47 * @param code to look up the Result for |
|
48 * @return a Result value for {@code code} or {@code null} if code is unknown |
|
49 */ |
|
50 public static Result forCode(int code) { |
|
51 return codeToResult.get(code); |
|
52 } |
|
53 } |