1bc28c63afad53424112f1363fb0bca3689ba9be
[phpeclipse.git] / net.sourceforge.phpeclipse / 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 org.eclipse.core.runtime.IConfigurationElement;
13 import org.eclipse.core.runtime.IPath;
14 import net.sourceforge.phpdt.externaltools.variable.IVariableLocationExpander;
15 import net.sourceforge.phpdt.externaltools.variable.ExpandVariableContext;
16
17 /**
18  * Represents the variable for the path location
19  */
20 public final class PathLocationVariable extends ExternalToolVariable {
21         private static final DefaultLocationExpander defaultExpander = new DefaultLocationExpander();
22         
23         private IVariableLocationExpander expander = null;
24
25         /**
26          * Creates a path location variable
27          * 
28          * @param tag the variable tag
29          * @param description a short description of what the variable will expand to
30          * @param element the configuration element
31          */
32         /*package*/ PathLocationVariable(String tag, String description, IConfigurationElement element) {
33                 super(tag, description, element);
34         }
35
36         /**
37          * Returns the object that can expand the variable
38          * into a path location.
39          */
40         public IVariableLocationExpander getExpander() {
41                 if (expander == null) {
42                         expander = (IVariableLocationExpander) createObject(ExternalToolVariableRegistry.TAG_EXPANDER_CLASS);
43                         if (expander == null)
44                                 expander = defaultExpander;
45                 }
46                 return expander;
47         }
48
49
50         /**
51          * Default variable location implementation which does 
52          * not expand variables, but just returns <code>null</code>.
53          */     
54         private static final class DefaultLocationExpander implements IVariableLocationExpander {
55                 /* (non-Javadoc)
56                  * Method declared on IVariableLocationExpander.
57                  */
58                 public IPath getPath(String varTag, String varValue, ExpandVariableContext context) {
59                         return null;
60                 }
61         }
62 }