/** * @return all resources name * @throws ArchiveException if error occurs */ public Iterator<String> getEntries() throws ArchiveException { List<String> listResourcesName = new ArrayList<String>(); init(); try { Enumeration<? extends ZipEntry> en = jarFile.entries(); while (en.hasMoreElements()) { ZipEntry zipEntry = en.nextElement(); String name = zipEntry.getName(); listResourcesName.add(name); } } finally { close(); } return listResourcesName.iterator(); }
/** * @return string representation */ @Override public String toString() { return getName(); }
/** * @param resourceName The resource name to be looked up. * @return Returns an Iterator of matching resources. * @throws ArchiveException if method fails. */ public Iterator<URL> getResources(final String resourceName) throws ArchiveException { List<URL> listResources = new ArrayList<URL>(); URL url = getResource(resourceName); if (url != null) { listResources.add(url); } return listResources.iterator(); }
/** * Init metadata by reading the Manifest file. * @throws ArchiveException if metadata are not initialized */ protected void initMetadata() throws ArchiveException { // Open Jar File init(); // Get manifest Manifest manifest = null; try { manifest = jarFile.getManifest(); } catch (IOException e) { throw new ArchiveException("Cannot analyze the manifest", e); } finally { // close jar close(); } // Read manifest if (manifest != null) { readManifest(manifest); } }
/** * @return the Metadata associated to this archive. */ @Override public IArchiveMetadata getMetadata() { if (!metadataAnalyzed) { try { initMetadata(); } catch (ArchiveException e) { logger.error("Cannot analyze metadata for archive " + jarFile, e); } metadataAnalyzed = true; } return super.getMetadata(); }
return new JarArchiveImpl(file); } else { return new FileArchiveImpl(file);
/** * Init metadata by reading the Manifest file. * @throws ArchiveException if metadata are not initialized */ protected void initMetadata() throws ArchiveException { // Open Jar File init(); // Get manifest Manifest manifest = null; try { manifest = jarFile.getManifest(); } catch (IOException e) { throw new ArchiveException("Cannot analyze the manifest", e); } finally { // close jar close(); } // Read manifest if (manifest != null) { readManifest(manifest); } }
/** * @return the Metadata associated to this archive. */ @Override public IArchiveMetadata getMetadata() { if (!metadataAnalyzed) { try { initMetadata(); } catch (ArchiveException e) { logger.error("Cannot analyze metadata for archive " + jarFile, e); } metadataAnalyzed = true; } return super.getMetadata(); }
return new JarArchiveImpl(file); } else { return new FileArchiveImpl(file);
/** * @return all resources name * @throws ArchiveException if error occurs */ public Iterator<String> getEntries() throws ArchiveException { List<String> listResourcesName = new ArrayList<String>(); init(); try { Enumeration<? extends ZipEntry> en = jarFile.entries(); while (en.hasMoreElements()) { ZipEntry zipEntry = en.nextElement(); String name = zipEntry.getName(); listResourcesName.add(name); } } finally { close(); } return listResourcesName.iterator(); }
/** * @return string representation */ @Override public String toString() { return getName(); }
/** * @param resourceName The resource name to be looked up. * @return Returns an Iterator of matching resources. * @throws ArchiveException if method fails. */ public Iterator<URL> getResources(final String resourceName) throws ArchiveException { List<URL> listResources = new ArrayList<URL>(); URL url = getResource(resourceName); if (url != null) { listResources.add(url); } return listResources.iterator(); }
/** * @param resourceName The resource name to be looked up. * @return Returns the resource URL if the resource has been found. null * otherwise. * @throws ArchiveException if method fails. */ public URL getResource(final String resourceName) throws ArchiveException { URL resourceUrl = null; // Open jar file. init(); try { JarEntry jarEntry = jarFile.getJarEntry(resourceName); if (jarEntry != null) { try { resourceUrl = new URL("jar:" + url + "!/" + resourceName); } catch (MalformedURLException e) { throw new ArchiveException("Invalid url", e); } } } finally { close(); } return resourceUrl; }
/** * @param resourceName The resource name to be looked up. * @return Returns the resource URL if the resource has been found. null * otherwise. * @throws ArchiveException if method fails. */ public URL getResource(final String resourceName) throws ArchiveException { URL resourceUrl = null; // Open jar file. init(); try { JarEntry jarEntry = jarFile.getJarEntry(resourceName); if (jarEntry != null) { try { resourceUrl = new URL("jar:" + url + "!/" + resourceName); } catch (MalformedURLException e) { throw new ArchiveException("Invalid url", e); } } } finally { close(); } return resourceUrl; }
/** * @return Returns an Iterator of Resource's URL. * @throws ArchiveException if method fails. */ public Iterator<URL> getResources() throws ArchiveException { List<URL> listResources = new ArrayList<URL>(); init(); try { Enumeration<? extends ZipEntry> en = jarFile.entries(); while (en.hasMoreElements()) { ZipEntry zipEntry = en.nextElement(); String name = zipEntry.getName(); try { listResources.add(new URL("jar:" + url + "!/" + name)); } catch (MalformedURLException e) { throw new ArchiveException("Invalid url", e); } } } finally { close(); } return listResources.iterator(); }
/** * @return Returns an Iterator of Resource's URL. * @throws ArchiveException if method fails. */ public Iterator<URL> getResources() throws ArchiveException { List<URL> listResources = new ArrayList<URL>(); init(); try { Enumeration<? extends ZipEntry> en = jarFile.entries(); while (en.hasMoreElements()) { ZipEntry zipEntry = en.nextElement(); String name = zipEntry.getName(); try { listResources.add(new URL("jar:" + url + "!/" + name)); } catch (MalformedURLException e) { throw new ArchiveException("Invalid url", e); } } } finally { close(); } return listResources.iterator(); }