1 19 20 package org.openide.filesystems; 21 22 import java.beans.PropertyChangeListener ; 23 import java.beans.PropertyChangeSupport ; 24 import java.util.Collection ; 25 import java.util.Enumeration ; 26 import java.util.Vector ; 27 28 42 @Deprecated 43 public class FileSystemCapability extends Object { 44 46 public static final FileSystemCapability ALL = new FileSystemCapability() { 47 public boolean capableOf(FileSystemCapability c) { 48 return true; 49 } 50 }; 51 52 55 @Deprecated 56 public static final FileSystemCapability COMPILE = new FileSystemCapability(); 57 58 61 @Deprecated 62 public static final FileSystemCapability EXECUTE = new FileSystemCapability(); 63 64 67 @Deprecated 68 public static final FileSystemCapability DEBUG = new FileSystemCapability(); 69 70 73 @Deprecated 74 public static final FileSystemCapability DOC = new FileSystemCapability(); 75 76 public FileSystemCapability() { 77 if (DOC == null) { 78 return; 80 } 81 82 assert FileUtil.assertDeprecatedMethod(); 83 } 84 85 94 public boolean capableOf(FileSystemCapability c) { 95 return c == this; 96 } 97 98 102 @Deprecated 103 public Enumeration <? extends FileSystem> fileSystems() { 104 class FFS implements org.openide.util.Enumerations.Processor<FileSystem, FileSystem> { 105 @Deprecated 106 public FileSystem process(FileSystem fs, Collection <FileSystem> ignore) { 107 return fs.getCapability().capableOf(FileSystemCapability.this) ? fs : null; 108 } 109 } 110 111 return org.openide.util.Enumerations.filter(ExternalUtil.getRepository().fileSystems(), new FFS()); 112 } 113 114 118 @Deprecated 119 public FileObject findResource(String resName) { 120 Enumeration <? extends FileSystem> en = fileSystems(); 121 122 while (en.hasMoreElements()) { 123 FileSystem fs = en.nextElement(); 124 FileObject fo = fs.findResource(resName); 125 126 if (fo != null) { 127 return fo; 129 } 130 } 131 132 return null; 133 } 134 135 141 @Deprecated 142 public Enumeration <? extends FileObject> findAllResources(String name) { 143 Vector <FileObject> v = new Vector <FileObject>(8); 144 Enumeration <? extends FileSystem> en = fileSystems(); 145 146 while (en.hasMoreElements()) { 147 FileSystem fs = en.nextElement(); 148 FileObject fo = fs.findResource(name); 149 150 if (fo != null) { 151 v.addElement(fo); 152 } 153 } 154 155 return v.elements(); 156 } 157 158 173 @Deprecated 174 public final FileObject find(String aPackage, String name, String ext) { 175 Enumeration <? extends FileSystem> en = fileSystems(); 176 177 while (en.hasMoreElements()) { 178 FileSystem fs = en.nextElement(); 179 FileObject fo = fs.find(aPackage, name, ext); 180 181 if (fo != null) { 182 return fo; 184 } 185 } 186 187 return null; 188 } 189 190 203 @Deprecated 204 public final Enumeration <? extends FileObject> findAll(String aPackage, String name, String ext) { 205 Enumeration <? extends FileSystem> en = fileSystems(); 206 Vector <FileObject> ret = new Vector <FileObject>(); 207 208 while (en.hasMoreElements()) { 209 FileSystem fs = (FileSystem) en.nextElement(); 210 FileObject fo = fs.find(aPackage, name, ext); 211 212 if (fo != null) { 213 ret.addElement(fo); 214 } 215 } 216 217 return ret.elements(); 218 } 219 220 224 public synchronized void addPropertyChangeListener(PropertyChangeListener l) { 225 } 226 227 231 public void removePropertyChangeListener(PropertyChangeListener l) { 232 } 233 234 240 @Deprecated 241 public static class Bean extends FileSystemCapability implements java.io.Serializable { 242 static final long serialVersionUID = 627905674809532736L; 243 244 245 private transient PropertyChangeSupport supp; 246 247 248 private boolean compilation = true; 249 250 251 private boolean execution = true; 252 253 254 private boolean debug = true; 255 256 257 private boolean doc = false; 258 259 264 public boolean capableOf(FileSystemCapability c) { 265 if (c == COMPILE) { 266 return compilation; 267 } 268 269 if (c == EXECUTE) { 270 return execution; 271 } 272 273 if (c == DEBUG) { 274 return debug; 275 } 276 277 if (c == DOC) { 278 return doc; 279 } 280 281 if (c == ALL) { 282 return true; 283 } 284 285 if (!(c instanceof Bean)) { 286 return false; 287 } 288 289 Bean b = (Bean) c; 291 292 return (compilation == b.compilation) && (execution == b.execution) && (debug == b.debug) && 293 (doc == b.doc); 294 } 295 296 299 @Deprecated 300 public boolean getCompile() { 301 return compilation; 302 } 303 304 307 @Deprecated 308 public void setCompile(boolean val) { 309 if (val != compilation) { 310 compilation = val; 311 312 if (supp != null) { 313 supp.firePropertyChange( 314 "compile", (!val) ? Boolean.TRUE : Boolean.FALSE, val ? Boolean.TRUE : Boolean.FALSE 316 ); 317 } 318 } 319 } 320 321 324 @Deprecated 325 public boolean getExecute() { 326 return execution; 327 } 328 329 332 @Deprecated 333 public void setExecute(boolean val) { 334 if (val != execution) { 335 execution = val; 336 337 if (supp != null) { 338 supp.firePropertyChange( 339 "execute", (!val) ? Boolean.TRUE : Boolean.FALSE, val ? Boolean.TRUE : Boolean.FALSE 341 ); 342 } 343 } 344 } 345 346 349 @Deprecated 350 public boolean getDebug() { 351 return debug; 352 } 353 354 357 @Deprecated 358 public void setDebug(boolean val) { 359 if (val != debug) { 360 debug = val; 361 362 if (supp != null) { 363 supp.firePropertyChange( 364 "debug", (!val) ? Boolean.TRUE : Boolean.FALSE, val ? Boolean.TRUE : Boolean.FALSE 366 ); 367 } 368 } 369 } 370 371 374 @Deprecated 375 public boolean getDoc() { 376 return doc; 377 } 378 379 382 @Deprecated 383 public void setDoc(boolean val) { 384 if (val != doc) { 385 doc = val; 386 387 if (supp != null) { 388 supp.firePropertyChange( 389 "doc", (!val) ? Boolean.TRUE : Boolean.FALSE, val ? Boolean.TRUE : Boolean.FALSE 391 ); 392 } 393 } 394 } 395 396 public synchronized void addPropertyChangeListener(PropertyChangeListener l) { 397 if (supp == null) { 398 supp = new PropertyChangeSupport (this); 399 } 400 401 supp.addPropertyChangeListener(l); 402 } 403 404 public void removePropertyChangeListener(PropertyChangeListener l) { 405 if (supp != null) { 406 supp.removePropertyChangeListener(l); 407 } 408 } 409 } 410 } 411 | Popular Tags |