KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > variables > EclipseHomeVariableResolver


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  * Bjorn Freeman-Benson - initial API and implementation
11  *******************************************************************************/

12 package org.eclipse.core.internal.variables;
13
14 import java.net.URL JavaDoc;
15
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.core.runtime.Platform;
18 import org.eclipse.core.variables.IDynamicVariable;
19 import org.eclipse.core.variables.IDynamicVariableResolver;
20 import org.eclipse.osgi.service.datalocation.Location;
21
22 /**
23  * Resolver for ${eclipse_home}
24  *
25  * @since 3.2
26  */

27 public class EclipseHomeVariableResolver implements IDynamicVariableResolver {
28
29     public String JavaDoc resolveValue(IDynamicVariable variable, String JavaDoc argument) throws CoreException {
30         Location installLocation = Platform.getInstallLocation();
31         if (installLocation != null) {
32             URL JavaDoc url = installLocation.getURL();
33             if (url != null) {
34                 String JavaDoc file = url.getFile();
35                 if (file.length() != 0) {
36                     return file;
37                 }
38             }
39         }
40         return null;
41     }
42
43 }
44
Popular Tags