1 11 12 package org.eclipse.debug.internal.core; 13 14 import java.util.Iterator ; 15 import java.util.Map ; 16 17 import org.eclipse.core.runtime.CoreException; 18 import org.eclipse.core.runtime.IStatus; 19 import org.eclipse.core.runtime.Platform; 20 import org.eclipse.core.runtime.Status; 21 import org.eclipse.core.variables.IDynamicVariable; 22 import org.eclipse.core.variables.IDynamicVariableResolver; 23 import org.eclipse.debug.core.DebugPlugin; 24 import org.eclipse.osgi.service.environment.Constants; 25 26 29 public class EnvironmentVariableResolver implements IDynamicVariableResolver { 30 31 34 public String resolveValue(IDynamicVariable variable, String argument) throws CoreException { 35 if (argument == null) { 36 throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), IStatus.ERROR, DebugCoreMessages.EnvironmentVariableResolver_0, null)); 37 } 38 Map map= DebugPlugin.getDefault().getLaunchManager().getNativeEnvironmentCasePreserved(); 39 String value= (String ) map.get(argument); 40 if (value == null && Platform.getOS().equals(Constants.OS_WIN32)) { 41 Iterator iter = map.entrySet().iterator(); 44 while (iter.hasNext()) { 45 Map.Entry entry= ((Map.Entry ) iter.next()); 46 String key= (String ) entry.getKey(); 47 if (key.equalsIgnoreCase(argument)) { 48 return (String ) entry.getValue(); 49 } 50 } 51 } 52 return value; 53 } 54 55 } 56 | Popular Tags |