KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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  *******************************************************************************/

11 package org.eclipse.core.internal.variables;
12
13 import org.eclipse.core.variables.IValueVariable;
14
15 /**
16  * Implementation of a value variable.
17  */

18 public class ValueVariable extends StringVariable implements IValueVariable {
19     
20     /**
21      * Variable value or <code>null</code> if none
22      */

23     private String JavaDoc fValue;
24     
25     /**
26      * Whether this variable is read only. If true, users cannot change the value.
27      */

28     private boolean fReadOnly;
29     
30     /**
31      * Constructs a new value variable with the given name, description, read only
32      * property and string value. Value can be null.
33      *
34      * @param name variable name
35      * @param description variable description or <code>null</code>
36      * @param readOnly whether the variable should be a read only variable
37      * @param value the initial value of the variable or <code>null</code>
38      */

39     public ValueVariable(String JavaDoc name, String JavaDoc description, boolean readOnly, String JavaDoc value) {
40         super(name, description, null);
41         fReadOnly = readOnly;
42         fValue = value;
43     }
44     
45     /* (non-Javadoc)
46      * @see org.eclipse.core.variables.IValueVariable#setValue(java.lang.String)
47      */

48     public void setValue(String JavaDoc value) {
49         if (!isReadOnly()){
50             fValue = value;
51             StringVariableManager.getDefault().notifyChanged(this);
52         }
53     }
54     
55     /* (non-Javadoc)
56      * @see org.eclipse.core.variables.IValueVariable#getValue()
57      */

58     public String JavaDoc getValue() {
59         return fValue;
60     }
61
62     /* (non-Javadoc)
63      * @see org.eclipse.core.variables.IValueVariable#isReadOnly()
64      */

65     public boolean isReadOnly() {
66         return fReadOnly;
67     }
68     
69     /* (non-Javadoc)
70      * @see org.eclipse.core.variables.IValueVariable#isContributed()
71      */

72     public boolean isContributed() {
73         return false;
74     }
75
76 }
77
Popular Tags