KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > launching > VariableClasspathEntry


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
12 package org.eclipse.jdt.internal.launching;
13
14 import org.eclipse.core.runtime.CoreException;
15 import org.eclipse.debug.core.ILaunchConfiguration;
16 import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
17 import org.w3c.dom.Document JavaDoc;
18 import org.w3c.dom.Element JavaDoc;
19
20
21 /**
22  * Specialization for a String variable classpath entry
23  */

24 public class VariableClasspathEntry extends AbstractRuntimeClasspathEntry {
25     public static final String JavaDoc TYPE_ID = "org.eclipse.jdt.launching.classpathentry.variableClasspathEntry"; //$NON-NLS-1$
26
private String JavaDoc variableString;
27     
28     /**
29      * Constructor
30      */

31     public VariableClasspathEntry() {}
32     
33     /**
34      * Constructor
35      * @param variableString
36      */

37     public VariableClasspathEntry(String JavaDoc variableString) {
38         this.variableString = variableString;
39     }
40     
41     /* (non-Javadoc)
42      * @see org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry#buildMemento(org.w3c.dom.Document, org.w3c.dom.Element)
43      */

44     protected void buildMemento(Document JavaDoc document, Element JavaDoc memento) throws CoreException {
45         memento.setAttribute("variableString", variableString); //$NON-NLS-1$
46
memento.setAttribute("path", Integer.toString(getClasspathProperty())); //$NON-NLS-1$
47
}
48     
49     /* (non-Javadoc)
50      * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#initializeFrom(org.w3c.dom.Element)
51      */

52     public void initializeFrom(Element JavaDoc memento) throws CoreException {
53         variableString = memento.getAttribute("variableString"); //$NON-NLS-1$
54
String JavaDoc property = memento.getAttribute("path"); //$NON-NLS-1$
55
if(property != null && !"".equals(property)) { //$NON-NLS-1$
56
try {
57                 setClasspathProperty(Integer.parseInt(property));
58             }
59             catch(NumberFormatException JavaDoc nfe) {/*do nothing, but don't throw an exception*/}
60         }
61         
62     }
63     
64     /* (non-Javadoc)
65      * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getTypeId()
66      */

67     public String JavaDoc getTypeId() {
68         return TYPE_ID;
69     }
70     
71     /* (non-Javadoc)
72      * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getRuntimeClasspathEntries(org.eclipse.debug.core.ILaunchConfiguration)
73      */

74     public IRuntimeClasspathEntry[] getRuntimeClasspathEntries(ILaunchConfiguration configuration) throws CoreException {
75         return new IRuntimeClasspathEntry[0];
76     }
77     
78     /* (non-Javadoc)
79      * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getName()
80      */

81     public String JavaDoc getName() {
82         return variableString;
83     }
84     
85     /* (non-Javadoc)
86      * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getType()
87      */

88     public int getType() {
89         return OTHER;
90     }
91     /**
92      * @return Returns the variableString.
93      */

94     public String JavaDoc getVariableString() {
95         return variableString;
96     }
97     /**
98      * @param variableString The variableString to set.
99      */

100     public void setVariableString(String JavaDoc variableString) {
101         this.variableString = variableString;
102     }
103
104     /* (non-Javadoc)
105      * @see java.lang.Object#hashCode()
106      */

107     public int hashCode() {
108         if (variableString != null) {
109             return variableString.hashCode();
110         }
111         return 0;
112     }
113
114     /* (non-Javadoc)
115      * @see java.lang.Object#equals(java.lang.Object)
116      */

117     public boolean equals(Object JavaDoc obj) {
118         if (obj instanceof VariableClasspathEntry) {
119             VariableClasspathEntry other= (VariableClasspathEntry)obj;
120             if (variableString != null) {
121                 return variableString.equals(other.variableString);
122             }
123         }
124         return false;
125     }
126 }
127
Popular Tags