KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > core > AntClasspathEntry


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.ant.internal.core;
13
14 import java.io.File JavaDoc;
15 import java.net.MalformedURLException JavaDoc;
16 import java.net.URL JavaDoc;
17 import org.eclipse.ant.core.AntCorePlugin;
18 import org.eclipse.ant.core.IAntClasspathEntry;
19 import org.eclipse.core.runtime.CoreException;
20 import org.eclipse.core.variables.VariablesPlugin;
21
22 public class AntClasspathEntry implements IAntClasspathEntry {
23
24     private String JavaDoc entryString;
25     private boolean eclipseRequired= false;
26     private URL JavaDoc url= null;
27     
28     /* (non-Javadoc)
29      * @see org.eclipse.ant.core.IAntClasspathEntry#getLabel()
30      */

31     public String JavaDoc getLabel() {
32         
33         return entryString;
34     }
35
36     /* (non-Javadoc)
37      * @see org.eclipse.ant.core.IAntClasspathEntry#getEntryURL()
38      */

39     public URL JavaDoc getEntryURL() {
40         if (url != null) {
41             return url;
42         }
43         try {
44             String JavaDoc expanded = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(entryString);
45             return new URL JavaDoc("file:" + expanded); //$NON-NLS-1$
46
} catch (CoreException e) {
47             try {
48                 return new URL JavaDoc("file:" + entryString); //$NON-NLS-1$
49
} catch (MalformedURLException JavaDoc e1) {
50                 return null;
51             }
52         } catch (MalformedURLException JavaDoc e) {
53             AntCorePlugin.log(e);
54         }
55         return null;
56     }
57
58     public AntClasspathEntry(String JavaDoc entryString) {
59         this.entryString= entryString;
60     }
61     
62     public AntClasspathEntry(URL JavaDoc url) {
63         this.url= url;
64         this.entryString= new File JavaDoc(url.getPath()).getAbsolutePath();
65     }
66     
67     /* (non-Javadoc)
68      * @see java.lang.Object#equals(java.lang.Object)
69      */

70     public boolean equals(Object JavaDoc obj) {
71         if (obj instanceof IAntClasspathEntry) {
72             IAntClasspathEntry other= (IAntClasspathEntry)obj;
73             return entryString.equals(other.getLabel());
74         }
75         return false;
76         
77     }
78
79     /* (non-Javadoc)
80      * @see java.lang.Object#hashCode()
81      */

82     public int hashCode() {
83         return entryString.hashCode();
84     }
85     
86     /* (non-Javadoc)
87      * @see java.lang.Object#toString()
88      */

89     public String JavaDoc toString() {
90         return getLabel();
91     }
92
93     /* (non-Javadoc)
94      * @see org.eclipse.ant.core.IAntClasspathEntry#isEclipseRuntimeRequired()
95      */

96     public boolean isEclipseRuntimeRequired() {
97         return eclipseRequired;
98     }
99     
100     public void setEclipseRuntimeRequired(boolean eclipseRequired) {
101         this.eclipseRequired = eclipseRequired;
102     }
103 }
Popular Tags