KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > wizards > buildpaths > CPVariableElement


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.jdt.internal.ui.wizards.buildpaths;
12
13 import org.eclipse.core.runtime.Assert;
14 import org.eclipse.core.runtime.IPath;
15
16 import org.eclipse.jdt.core.JavaCore;
17
18
19 public class CPVariableElement {
20
21     private String JavaDoc fName;
22     private IPath fPath;
23     
24     /**
25      * @param name the variable name
26      * @param path the path
27      */

28     public CPVariableElement(String JavaDoc name, IPath path) {
29         Assert.isNotNull(name);
30         Assert.isNotNull(path);
31         fName= name;
32         fPath= path;
33     }
34     
35     /**
36      * Gets the path
37      * @return Returns a IPath
38      */

39     public IPath getPath() {
40         return fPath;
41     }
42
43     /**
44      * Sets the path
45      * @param path The path to set
46      */

47     public void setPath(IPath path) {
48         Assert.isNotNull(path);
49         fPath= path;
50     }
51
52     /**
53      * Gets the name
54      * @return Returns a String
55      */

56     public String JavaDoc getName() {
57         return fName;
58     }
59
60     /**
61      * Sets the name
62      * @param name The name to set
63      */

64     public void setName(String JavaDoc name) {
65         Assert.isNotNull(name);
66         fName= name;
67     }
68     
69     /*
70      * @see Object#equals()
71      */

72     public boolean equals(Object JavaDoc other) {
73         if (other != null && other.getClass().equals(getClass())) {
74             CPVariableElement elem= (CPVariableElement)other;
75             return fName.equals(elem.fName);
76         }
77         return false;
78     }
79     
80     /*
81      * @see Object#hashCode()
82      */

83     public int hashCode() {
84         return fName.hashCode();
85     }
86     
87     /**
88      * @return <code>true</code> iff variable is read-only
89      */

90     public boolean isReadOnly() {
91         return JavaCore.isClasspathVariableReadOnly(fName);
92     }
93
94     /**
95      * @return whether this variable is deprecated
96      */

97     public boolean isDeprecated() {
98         return JavaCore.getClasspathVariableDeprecationMessage(fName) != null;
99     }
100
101     /**
102      * @return the deprecation message, or <code>null</code> iff the variable is not deprecated
103      */

104     public String JavaDoc getDeprecationMessage() {
105         return BuildPathSupport.getDeprecationMessage(fName);
106     }
107 }
108
Popular Tags