1 11 12 package org.eclipse.ant.internal.ui.preferences; 13 14 import java.net.MalformedURLException ; 15 import java.net.URL ; 16 import org.eclipse.ant.core.IAntClasspathEntry; 17 import org.eclipse.ant.internal.ui.AntUIPlugin; 18 import org.eclipse.core.runtime.CoreException; 19 import org.eclipse.core.variables.VariablesPlugin; 20 21 public class ClasspathEntry extends AbstractClasspathEntry { 22 23 private URL fUrl= null; 24 private String fVariableString= null; 25 private IAntClasspathEntry fEntry= null; 26 27 public ClasspathEntry(Object o, IClasspathEntry parent) { 28 fParent= parent; 29 if (o instanceof URL ) { 30 fUrl= (URL )o; 31 } else if (o instanceof String ) { 32 fVariableString= (String )o; 33 } else if (o instanceof IAntClasspathEntry) { 34 fEntry= (IAntClasspathEntry)o; 35 } 36 } 37 38 41 public boolean equals(Object obj) { 42 if (obj instanceof IAntClasspathEntry) { 43 IAntClasspathEntry other= (IAntClasspathEntry)obj; 44 return other.getLabel().equals(getLabel()); 45 } 46 return false; 47 48 } 49 50 53 public int hashCode() { 54 return getLabel().hashCode(); 55 } 56 57 60 public String toString() { 61 if (fEntry != null) { 62 return fEntry.getLabel(); 63 } 64 if (getURL() != null) { 65 return getURL().getFile(); 66 } 67 68 return getVariableString(); 69 } 70 71 protected URL getURL() { 72 return fUrl; 73 } 74 75 protected String getVariableString() { 76 return fVariableString; 77 } 78 79 82 public String getLabel() { 83 if (fEntry == null) { 84 return toString(); 85 } 86 return fEntry.getLabel(); 87 } 88 89 92 public URL getEntryURL() { 93 if (fEntry != null) { 94 return fEntry.getEntryURL(); 95 } 96 if (fUrl != null) { 97 return fUrl; 98 } 99 100 try { 101 String expanded = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(fVariableString); 102 return new URL ("file:" + expanded); } catch (CoreException e) { 104 AntUIPlugin.log(e); 105 } catch (MalformedURLException e) { 106 AntUIPlugin.log(e); 107 } 108 return null; 109 } 110 111 114 public boolean isEclipseRuntimeRequired() { 115 if (fEntry == null) { 116 return super.isEclipseRuntimeRequired(); 117 } 118 return fEntry.isEclipseRuntimeRequired(); 119 } 120 } 121 | Popular Tags |