1 19 20 package org.apache.tools.ant.module.spi; 21 22 import java.io.File ; 23 import java.io.FileNotFoundException ; 24 import java.net.URL ; 25 import java.util.Map ; 26 import org.openide.filesystems.FileObject; 27 import org.openide.filesystems.FileUtil; 28 import org.openide.filesystems.URLMapper; 29 30 34 final class AutomaticExtraClasspath implements AutomaticExtraClasspathProvider { 35 private File file; 36 37 38 private AutomaticExtraClasspath(File file) { 39 this.file = file; 40 } 41 42 public static AutomaticExtraClasspathProvider url(Map <?,?> map) throws Exception { 43 Object obj = map.get("url"); if (obj instanceof URL ) { 45 FileObject fo = URLMapper.findFileObject((URL )obj); 46 File f = fo != null ? FileUtil.toFile(fo) : null; 47 if (f != null) { 48 AutomaticExtraClasspath aec = new AutomaticExtraClasspath(f); 49 return aec; 50 } 51 throw new FileNotFoundException (obj.toString()); 52 } else { 53 throw new IllegalArgumentException ("url arg is not URL: " + obj); } 55 } 56 57 public File [] getClasspathItems() { 58 return new File [] { file }; 59 } 60 } 61 | Popular Tags |