Fixed: 1777185 - Remote Debug option 'Open with ...' should work
[phpeclipse.git] / net.sourceforge.phpeclipse.externaltools / src / net / sourceforge / phpdt / externaltools / internal / registry / ArgumentVariable.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.IVariableTextExpander;
14
15 import org.eclipse.core.runtime.IConfigurationElement;
16
17 /**
18  * Represents the variable for the argument
19  */
20 public final class ArgumentVariable extends ExternalToolVariable {
21         private static final DefaultTextExpander defaultExpander = new DefaultTextExpander();
22
23         private IVariableTextExpander expander = null;
24
25         /**
26          * Creates an argument variable
27          * 
28          * @param tag
29          *            the variable tag
30          * @param description
31          *            a short description of what the variable will expand to
32          * @param element
33          *            the configuration element
34          */
35         /* package */ArgumentVariable(String tag, String description,
36                         IConfigurationElement element) {
37                 super(tag, description, element);
38         }
39
40         /**
41          * Returns the object that can expand the variable as text.
42          */
43         public IVariableTextExpander getExpander() {
44                 if (expander == null) {
45                         try {
46                                 expander = (IVariableTextExpander) createObject(ExternalToolVariableRegistry.TAG_EXPANDER_CLASS);
47                         } catch (ClassCastException exception) {
48                         }
49                         if (expander == null) {
50                                 expander = defaultExpander;
51                         }
52                 }
53                 return expander;
54         }
55
56         /**
57          * Default variable text expander implementation which does not expand
58          * variables, but just returns <code>null</code>.
59          */
60         private static final class DefaultTextExpander implements
61                         IVariableTextExpander {
62                 /*
63                  * (non-Javadoc) Method declared on IVariableTextExpander.
64                  */
65                 public String getText(String varTag, String varValue,
66                                 ExpandVariableContext context) {
67                         return null;
68                 }
69         }
70 }