org.chromium.debug.ui/src/org/chromium/debug/ui/launcher/PluginVariablesUtil.java
changeset 2 e4420d2515f1
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.debug.ui.launcher;
       
     6 
       
     7 import org.chromium.debug.ui.ChromiumDebugUIPlugin;
       
     8 import org.eclipse.core.variables.VariablesPlugin;
       
     9 
       
    10 /**
       
    11  * Provides convenient access to the variables declared in the
       
    12  * org.eclipse.core.variables.valueVariables extension point.
       
    13  */
       
    14 class PluginVariablesUtil {
       
    15 
       
    16   /** The default server port variable id. */
       
    17   public static final String DEFAULT_PORT =
       
    18       ChromiumDebugUIPlugin.PLUGIN_ID + ".chromium_debug_port"; //$NON-NLS-1$
       
    19 
       
    20   /**
       
    21    * @param variableName to get the value for
       
    22    * @return the variable value parsed as an integer
       
    23    * @throws NumberFormatException
       
    24    *           if the value cannot be parsed as an integer
       
    25    */
       
    26   public static int getValueAsInt(String variableName) {
       
    27     return Integer.parseInt(getValue(variableName));
       
    28   }
       
    29 
       
    30   /**
       
    31    * @param variableName to get the value for
       
    32    * @return the value of the specified variable
       
    33    */
       
    34   public static String getValue(String variableName) {
       
    35     return VariablesPlugin.getDefault().getStringVariableManager()
       
    36         .getValueVariable(variableName).getValue();
       
    37   }
       
    38 
       
    39   private PluginVariablesUtil() {
       
    40     // not instantiable
       
    41   }
       
    42 }