001: /*******************************************************************************
002: * Copyright (c) 2000, 2007 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.jdt.internal.ui.wizards.buildpaths;
011:
012: import org.eclipse.core.runtime.Assert;
013: import org.eclipse.core.runtime.IPath;
014:
015: import org.eclipse.jdt.core.JavaCore;
016:
017: public class CPVariableElement {
018:
019: private String fName;
020: private IPath fPath;
021:
022: /**
023: * @param name the variable name
024: * @param path the path
025: */
026: public CPVariableElement(String name, IPath path) {
027: Assert.isNotNull(name);
028: Assert.isNotNull(path);
029: fName = name;
030: fPath = path;
031: }
032:
033: /**
034: * Gets the path
035: * @return Returns a IPath
036: */
037: public IPath getPath() {
038: return fPath;
039: }
040:
041: /**
042: * Sets the path
043: * @param path The path to set
044: */
045: public void setPath(IPath path) {
046: Assert.isNotNull(path);
047: fPath = path;
048: }
049:
050: /**
051: * Gets the name
052: * @return Returns a String
053: */
054: public String getName() {
055: return fName;
056: }
057:
058: /**
059: * Sets the name
060: * @param name The name to set
061: */
062: public void setName(String name) {
063: Assert.isNotNull(name);
064: fName = name;
065: }
066:
067: /*
068: * @see Object#equals()
069: */
070: public boolean equals(Object other) {
071: if (other != null && other.getClass().equals(getClass())) {
072: CPVariableElement elem = (CPVariableElement) other;
073: return fName.equals(elem.fName);
074: }
075: return false;
076: }
077:
078: /*
079: * @see Object#hashCode()
080: */
081: public int hashCode() {
082: return fName.hashCode();
083: }
084:
085: /**
086: * @return <code>true</code> iff variable is read-only
087: */
088: public boolean isReadOnly() {
089: return JavaCore.isClasspathVariableReadOnly(fName);
090: }
091:
092: /**
093: * @return whether this variable is deprecated
094: */
095: public boolean isDeprecated() {
096: return JavaCore.getClasspathVariableDeprecationMessage(fName) != null;
097: }
098:
099: /**
100: * @return the deprecation message, or <code>null</code> iff the variable is not deprecated
101: */
102: public String getDeprecationMessage() {
103: return BuildPathSupport.getDeprecationMessage(fName);
104: }
105: }
|