1 26 27 package org.objectweb.petals.classloader.locator; 28 29 import java.util.List ; 30 import java.net.URL ; 31 import java.io.IOException ; 32 33 39 public abstract class Locator { 40 41 48 public abstract boolean hasFile(String path); 49 50 57 public abstract boolean hasDirectory(String path); 58 59 66 public abstract List listContent(String path); 67 68 79 public static Locator getLocator(URL url) throws IOException { 80 81 String path = url.getPath(); 82 if (path.matches(".*\\..ar")) { 83 return new JarFileLocator(url); 85 } else if (path.endsWith("/")) { 86 return new DirLocator(url); 88 } else { 89 String err = "Unsupported URL '" + url + "' support " 90 + "only jar archive and directory"; 91 throw new IOException (err); 92 } 93 } 94 } 95 | Popular Tags |