/** * @return an @see java.util.Enumeration of entries in this abstract * archive, providing the list of embedded archive to not count their * entries as part of this archive */ public Enumeration entries(Enumeration embeddedArchives) { // jar file are not recursive return entries(); }
/** Open an abstract archive * @param uri the path to the archive */ public void open(URI uri) throws IOException { this.uri = uri; jarFile = getJarFile(uri); }
return recordEntryEnumeration(createEntryEnumeration(topLevelDirectoriesOnly)); } catch (IOException ex) { throw new RuntimeException(ex);
/** * @return an Archive for an embedded archive indentified with * the name parameter */ public ReadableArchive getSubArchive(String name) throws IOException { if (jarFile!=null) { // for now, I only support one level down embedded archives InputJarArchive ija = new InputJarArchive(); JarEntry je = jarFile.getJarEntry(name); if (je!=null) { JarInputStream jis = new JarInputStream(new BufferedInputStream(jarFile.getInputStream(je))); try { ija.uri = new URI("jar",name, null); } catch(URISyntaxException e) { // do nothing } ija.jarIS = jis; ija.parentArchive = this; return ija; } } return null; }
/** * @return the manifest information for this abstract archive */ public Manifest getManifest() throws IOException { if (jarFile!=null) { return jarFile.getManifest(); } if (parentArchive!=null) { // close the current input stream if (jarIS!=null) { jarIS.close(); } // reopen the embedded archive and position the input stream // at the beginning of the desired element if (jarIS==null) { jarIS = new JarInputStream(parentArchive.jarFile.getInputStream(parentArchive.jarFile.getJarEntry(uri.getSchemeSpecificPart()))); } Manifest m = jarIS.getManifest(); if (m==null) { java.io.InputStream is = getEntry(java.util.jar.JarFile.MANIFEST_NAME); if (is!=null) { m = new Manifest(); m.read(is); is.close(); } } return m; } return null; }
@Override public Enumeration<String> entries() { return entries(false); }
private ArchiveJarEntrySource(final URI archiveURI) throws IOException { sourceJarFile = getJarFile(archiveURI); jarEntries = sourceJarFile.entries(); }