1 11 package org.eclipse.ant.core; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.core.variables.VariablesPlugin; 15 16 21 public class Property { 22 23 private String name; 24 private String value; 25 private String className; 26 private IAntPropertyValueProvider valueProvider; 27 private String pluginLabel; 28 private ClassLoader loader; 29 private boolean eclipseRuntime= true; 30 31 public Property(String name, String value) { 32 this.name= name; 33 this.value= value; 34 } 35 36 public Property() { 37 } 38 39 43 public String getName() { 44 return name; 45 } 46 47 51 public void setName(String name) { 52 this.name= name; 53 } 54 55 58 public boolean equals(Object other) { 59 if (other.getClass().equals(getClass())) { 60 Property elem= (Property)other; 61 return name.equals(elem.getName()); 62 } 63 return false; 64 } 65 66 69 public int hashCode() { 70 return name.hashCode(); 71 } 72 73 78 public String getValue() { 79 return getValue(true); 80 } 81 82 89 public String getValue(boolean substituteVariables) { 90 if (className != null) { 91 Class cls = null; 92 try { 93 cls = loader.loadClass(className); 94 } catch (ClassNotFoundException e) { 95 AntCorePlugin.log(e); 96 return null; 97 } 98 try { 99 valueProvider = (IAntPropertyValueProvider)cls.newInstance(); 100 } catch (InstantiationException e) { 101 AntCorePlugin.log(e); 102 return null; 103 } catch (IllegalAccessException ex) { 104 AntCorePlugin.log(ex); 105 return null; 106 } 107 loader= null; 108 className= null; 109 } 110 111 if (valueProvider != null) { 112 return valueProvider.getAntPropertyValue(name); 113 } 114 if (substituteVariables) { 115 try { 116 String expanded = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(value); 117 return expanded; 118 } catch (CoreException e) { 119 } 120 } else { 121 return value; 122 } 123 return value; 124 } 125 126 130 public void setValue(String value) { 131 this.value = value; 132 } 133 134 141 public boolean isDefault() { 142 return pluginLabel != null; 143 } 144 145 152 public void setPluginLabel(String pluginLabel) { 153 this.pluginLabel = pluginLabel; 154 } 155 156 163 public String getPluginLabel() { 164 return this.pluginLabel; 165 } 166 167 177 public void setValueProvider(String className, ClassLoader loader) { 178 this.className= className; 179 this.loader= loader; 180 } 181 182 185 public String toString() { 186 StringBuffer buff= new StringBuffer ("\""); buff.append(getName()); 188 buff.append("\"= \""); buff.append(getValue(false)); 190 buff.append("\""); return buff.toString(); 192 } 193 194 201 public boolean isEclipseRuntimeRequired() { 202 return eclipseRuntime; 203 } 204 205 public void setEclipseRuntimeRequired(boolean eclipseRuntime) { 206 this.eclipseRuntime= eclipseRuntime; 207 } 208 } 209 | Popular Tags |