Created a separated 'externaltools' plugin: initial check-in
[phpeclipse.git] / net.sourceforge.phpeclipse.externaltools / src / net / sourceforge / phpdt / externaltools / internal / registry / PathLocationVariable.java
1 package net.sourceforge.phpdt.externaltools.internal.registry;
2
3 /**********************************************************************
4 Copyright (c) 2002 IBM Corp. and others. All rights reserved.
5 This file is made available under the terms of the Common Public License v1.0
6 which accompanies this distribution, and is available at
7 http://www.eclipse.org/legal/cpl-v10.html
8
9 Contributors:
10 **********************************************************************/
11
12 import net.sourceforge.phpdt.externaltools.variable.ExpandVariableContext;
13 import net.sourceforge.phpdt.externaltools.variable.IVariableLocationExpander;
14
15 import org.eclipse.core.runtime.IConfigurationElement;
16 import org.eclipse.core.runtime.IPath;
17
18 /**
19  * Represents the variable for the path location
20  */
21 public final class PathLocationVariable extends ExternalToolVariable {
22         private static final DefaultLocationExpander defaultExpander = new DefaultLocationExpander();
23         
24         private IVariableLocationExpander expander = null;
25
26         /**
27          * Creates a path location variable
28          * 
29          * @param tag the variable tag
30          * @param description a short description of what the variable will expand to
31          * @param element the configuration element
32          */
33         /*package*/ PathLocationVariable(String tag, String description, IConfigurationElement element) {
34                 super(tag, description, element);
35         }
36
37         /**
38          * Returns the object that can expand the variable
39          * into a path location.
40          */
41         public IVariableLocationExpander getExpander() {
42                 if (expander == null) {
43                         expander = (IVariableLocationExpander) createObject(ExternalToolVariableRegistry.TAG_EXPANDER_CLASS);
44                         if (expander == null)
45                                 expander = defaultExpander;
46                 }
47                 return expander;
48         }
49
50
51         /**
52          * Default variable location implementation which does 
53          * not expand variables, but just returns <code>null</code>.
54          */     
55         private static final class DefaultLocationExpander implements IVariableLocationExpander {
56                 /* (non-Javadoc)
57                  * Method declared on IVariableLocationExpander.
58                  */
59                 public IPath getPath(String varTag, String varValue, ExpandVariableContext context) {
60                         return null;
61                 }
62         }
63 }