1 26 package org.objectweb.jonas_lib.loader.locator; 27 28 import java.io.IOException ; 29 import java.net.URL ; 30 import java.util.Enumeration ; 31 import java.util.List ; 32 import java.util.Vector ; 33 import java.util.jar.JarFile ; 34 import java.util.zip.ZipEntry ; 35 36 42 public class JarFileLocator extends Locator { 43 44 47 private JarFile file = null; 48 49 56 public JarFileLocator(URL jar) throws IOException { 57 String filename = jar.getFile(); 58 file = new JarFile (filename); 59 } 60 61 68 public boolean hasFile(String path) { 69 70 ZipEntry entry = file.getEntry(path); 71 return (entry != null); 72 } 73 74 81 public boolean hasDirectory(String path) { 82 83 boolean found = false; 84 for (Enumeration e = file.entries(); e.hasMoreElements() && !found;) { 85 ZipEntry entry = (ZipEntry ) e.nextElement(); 86 if (entry.getName().startsWith(path)) { 87 return true; 88 } 89 } 90 91 return false; 92 } 93 94 101 public List listContent(String path) { 102 103 List libs = new Vector (); 104 for (Enumeration e = file.entries(); e.hasMoreElements();) { 105 ZipEntry entry = (ZipEntry ) e.nextElement(); 106 if (entry.getName().startsWith(path)) { 107 libs.add(entry.getName()); 108 } 109 } 110 111 return libs; 112 } 113 114 } | Popular Tags |