org.chromium.sdk/src/org/chromium/sdk/internal/tools/v8/DebuggerCommand.java
changeset 2 e4420d2515f1
child 355 8726e95bcbba
equal deleted inserted replaced
1:ef76fc2ac88c 2:e4420d2515f1
       
     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.tools.v8;
       
     6 
       
     7 import java.util.HashMap;
       
     8 import java.util.Map;
       
     9 
       
    10 /**
       
    11  * Known V8 VM debugger commands and events.
       
    12  */
       
    13 public enum DebuggerCommand {
       
    14   CONTINUE("continue"),
       
    15   EVALUATE("evaluate"),
       
    16   BACKTRACE("backtrace"),
       
    17   FRAME("frame"),
       
    18   SCRIPTS("scripts"),
       
    19   SOURCE("source"),
       
    20   SCOPE("scope"),
       
    21   SETBREAKPOINT("setbreakpoint"),
       
    22   CHANGEBREAKPOINT("changebreakpoint"),
       
    23   CLEARBREAKPOINT("clearbreakpoint"),
       
    24   LOOKUP("lookup"),
       
    25   SUSPEND("suspend"),
       
    26   VERSION("version"),
       
    27 
       
    28   // Events
       
    29   BREAK("break"),
       
    30   EXCEPTION("exception"),
       
    31   AFTER_COMPILE("afterCompile"),
       
    32   ;
       
    33 
       
    34   public final String value;
       
    35 
       
    36   DebuggerCommand(String value) {
       
    37     this.value = value;
       
    38   }
       
    39 
       
    40   private static final Map<String, DebuggerCommand> valueToCommandMap =
       
    41       new HashMap<String, DebuggerCommand>();
       
    42 
       
    43   static {
       
    44     for (DebuggerCommand c : values()) {
       
    45       valueToCommandMap.put(c.value, c);
       
    46     }
       
    47   }
       
    48 
       
    49   /**
       
    50    * @param value the DebuggerCommand string value
       
    51    * @return the DebuggerCommand instance or null if none corresponds to value
       
    52    */
       
    53   public static DebuggerCommand forString(String value) {
       
    54     if (value == null) {
       
    55       return null;
       
    56     }
       
    57     return valueToCommandMap.get(value);
       
    58   }
       
    59 
       
    60 }