Methods Summary |
---|
private void | gatherResourcesWithFileMode(java.lang.String path, java.net.URI resourceURI, java.util.Set resources)
final File file = new File(resourceURI);
final String[] list = file.list(new FilenameFilter() {
public boolean accept(File file, String name) {
return name.charAt(0) != '.";
}
});
for(String filename : list) {
resources.add(path + filename);
}
|
private void | gatherResourcesWithJarMode(java.lang.String path, java.net.URI resourceURI, java.util.Set resources)
final String resourceURIAsString = resourceURI.toASCIIString();
final int pathDelim = resourceURIAsString.indexOf('!");
final String zipFile = resourceURIAsString.substring("jar:file:/".length(), (pathDelim != -1) ? pathDelim : resourceURIAsString.length());
ZipFile file = null;
try {
file = new ZipFile(zipFile);
String pathToCompare = path;
if (pathToCompare.charAt(0) == '/") {
pathToCompare = pathToCompare.substring(1, pathToCompare.length());
}
if (!pathToCompare.endsWith("/")) {
pathToCompare = pathToCompare + "/";
}
for(final Enumeration<? extends ZipEntry> e = file.entries(); e.hasMoreElements(); ) {
final ZipEntry entry = e.nextElement();
if (entry.getName().startsWith(pathToCompare) && !entry.getName().equals(pathToCompare)) {
resources.add("/" + entry.getName());
}
}
} catch(IOException e) {
} finally {
if (file != null) {
try {
file.close();
} catch (IOException ex) {
}
}
}
|
public java.lang.Object | getAttribute(java.lang.String name)
return attributes.get(name);
|
public java.net.URL | getResource(java.lang.String resource)
if (resource.charAt(0) == '/") {
resource = resource.substring(1, resource.length());
}
return classloader.getResource(resource);
|
public java.io.InputStream | getResourceAsStream(java.lang.String resource)
return classloader.getResourceAsStream(resource);
|
public java.util.Set | getResourcePaths(java.lang.String path)
try {
return populateResourcePaths(path);
} catch (Exception ex) {
}
return Collections.emptySet();
|
private java.util.Enumeration | getResources(java.lang.String resource)
if (resource.charAt(0) == '/") {
resource = resource.substring(1, resource.length());
}
return classloader.getResources(resource);
|
private java.util.Set | populateResourcePaths(java.lang.String path)
final Set<String> resources = new HashSet<String>();
for(final Enumeration<URL> initResources = getResources(path); initResources.hasMoreElements(); ) {
final URI resourceURI = initResources.nextElement().toURI();
if (resourceURI.getScheme().equals("file")) {
gatherResourcesWithFileMode(path, resourceURI, resources);
} else if (resourceURI.getScheme().equals("jar")) {
gatherResourcesWithJarMode(path, resourceURI, resources);
}
}
return resources;
|
public void | setAttribute(java.lang.String name, java.lang.Object value)
attributes.put(name, value);
|