/** * @return all resources name */ public Iterator<String> getEntries() { Map<String, URL> listResources = new HashMap<String, URL>(); // Get all files and subdirectories addFiles(directory, listResources); return listResources.keySet().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>(); File f = new File(directory, encode(resourceName)); if (f.exists()) { try { listResources.add(fileToURL2(f)); } catch (URLUtilsException e) { throw new ArchiveException("Invalid url", e); } } return listResources.iterator(); }
/** * @return the Metadata associated to this archive. */ @Override public IArchiveMetadata getMetadata() { if (!metadataAnalyzed) { try { initMetadata(); } catch (ArchiveException e) { logger.error("Cannot initialize metadata of file '" + directory + "'.", e); } metadataAnalyzed = true; } return super.getMetadata(); }
return new DirectoryArchiveImpl(file);
/** * @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>(); File f = new File(directory, encode(resourceName)); if (f.exists()) { try { listResources.add(fileToURL2(f)); } catch (URLUtilsException e) { throw new ArchiveException("Invalid url", e); } } return listResources.iterator(); }
/** * @return the Metadata associated to this archive. */ @Override public IArchiveMetadata getMetadata() { if (!metadataAnalyzed) { try { initMetadata(); } catch (ArchiveException e) { logger.error("Cannot initialize metadata of file '" + directory + "'.", e); } metadataAnalyzed = true; } return super.getMetadata(); }
return new DirectoryArchiveImpl(file);
/** * @return Returns an Iterator of Resource's URL. * @throws ArchiveException if method fails. */ public Iterator<URL> getResources() throws ArchiveException { Map<String, URL> listResources = new HashMap<String, URL>(); // Get all files and subdirectories addFiles(directory, listResources); return listResources.values().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; // lookup the directory on filesystem File f = new File(directory, encode(resourceName)); try { if (f.exists()) { resourceURL = fileToURL2(f); } } catch (URLUtilsException e) { throw new ArchiveException("Invalid url", e); } return resourceURL; }
/** * @return string representation */ @Override public String toString() { return getName(); }
/** * @return all resources name */ public Iterator<String> getEntries() { Map<String, URL> listResources = new HashMap<String, URL>(); // Get all files and subdirectories addFiles(directory, listResources); return listResources.keySet().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; // lookup the directory on filesystem File f = new File(directory, encode(resourceName)); try { if (f.exists()) { resourceURL = fileToURL2(f); } } catch (URLUtilsException e) { throw new ArchiveException("Invalid url", e); } return resourceURL; }
/** * @return Returns an Iterator of Resource's URL. * @throws ArchiveException if method fails. */ public Iterator<URL> getResources() throws ArchiveException { Map<String, URL> listResources = new HashMap<String, URL>(); // Get all files and subdirectories addFiles(directory, listResources); return listResources.values().iterator(); }
/** * Methods that loop on directories to find the children (files). * @param file the given directory/file. * @param listResources the list on which to add new files. */ private void addFiles(final File file, final Map<String, URL> listResources) { if (!file.exists() || !file.isDirectory()) { return; } // directory File[] files = file.listFiles(); if (files != null) { for (File f : files) { // loop addFiles("", f, listResources); } } }
/** * Methods that loop on directories to find the children (files). * @param file the given directory/file. * @param listResources the list on which to add new files. */ private void addFiles(final File file, final Map<String, URL> listResources) { if (!file.exists() || !file.isDirectory()) { return; } // directory File[] files = file.listFiles(); if (files != null) { for (File f : files) { // loop addFiles("", f, listResources); } } }
/** * Methods that loop on directories to find the children (files). * @param name the resource name * @param file the given directory/file. * @param listResources the list on which to add new files. */ private void addFiles(final String name, final File file, final Map<String, URL> listResources) { if (file.isDirectory()) { // directory File[] files = file.listFiles(); if (files != null) { for (File f : files) { // loop addFiles(name + file.getName() + "/", f, listResources); } } } else { // single file try { listResources.put(name + file.getName(), fileToURL2(file)); } catch (URLUtilsException e) { throw new IllegalStateException("Invalid url", e); } } }
/** * Methods that loop on directories to find the children (files). * @param name the resource name * @param file the given directory/file. * @param listResources the list on which to add new files. */ private void addFiles(final String name, final File file, final Map<String, URL> listResources) { if (file.isDirectory()) { // directory File[] files = file.listFiles(); if (files != null) { for (File f : files) { // loop addFiles(name + file.getName() + "/", f, listResources); } } } else { // single file try { listResources.put(name + file.getName(), fileToURL2(file)); } catch (URLUtilsException e) { throw new IllegalStateException("Invalid url", e); } } }