Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 7c4a8451033fb559bfa3165793b544ae29b8239c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*******************************************************************************
 * Copyright (c) 2000, 2003 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Common Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.debug.core.variables;


public class SimpleLaunchVariable implements ISimpleLaunchVariable {
	
	protected IVariableInitializer fVariableInitializer= null;
	protected String fName= null;
	protected String fValue= null;
	
	/**
	 * Creates a new launch configuration variable with the given initializer or <code>null</code>
	 * if none is available.
	 * @param initializer the initializer that should be used to calculate this variable's
	 * value if no value is set or <code>null</code> if no initializer is defined.
	 * @param initialValue the variable's initial value or <code>null</code> if no initial value
	 * should be set.
	 */
	public SimpleLaunchVariable(String name, IVariableInitializer initializer, String initialValue) {
		this(name);
		fVariableInitializer= initializer;
		fValue= initialValue;
	}
	
	/**
	 * Creates a new launch configuration varible with the given name.
	 * @param name
	 */
	public SimpleLaunchVariable(String name) {
		fName= name;
	}
	
	/**
	 * Creates a new variable with no name. Do not call.
	 */
	private SimpleLaunchVariable() {
	}

	/**
	 * @see ISimpleLaunchVariable#getInitializer()
	 */
	public IVariableInitializer getInitializer() {
		return fVariableInitializer;
	}
	
	/**
	 * @see ISimpleLaunchVariable#getName()
	 */
	public String getName() {
		return fName;
	}

	/**
	 * @see ISimpleLaunchVariable#getText()
	 */
	public String getText() {
		if (fValue == null && getInitializer() != null) {
			fValue= getInitializer().getText();
		}
		return fValue;
	}

	/**
	 * @see ISimpleLaunchVariable#setText(String)
	 */
	public void setText(String value) {
		fValue= value;
	}

}

Back to the top