final class ResourceEnumeration
extends java.lang.Object
implements java.util.Enumeration<java.net.URL>
Enumeration of resources found by scanning JARs and directories.| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
ResourceEnumeration.NestedJarConnection
Custom
URLConnection that can access JARs nested inside an arbitrary resource. |
(package private) static class |
ResourceEnumeration.NestedJarHandler
Custom
URLStreamHandler that can stream JARs nested inside an arbitrary resource. |
| Modifier and Type | Field and Description |
|---|---|
private java.net.URL |
currentURL |
private java.util.Iterator<java.lang.String> |
entryNames |
private GlobberStrategy |
globber |
private java.lang.Object |
globPattern |
private int |
index |
private boolean |
isFolder |
private java.lang.String |
nextEntryName |
private static java.util.Iterator<java.lang.String> |
NO_ENTRIES |
private boolean |
recurse |
private java.lang.String |
subPath |
private java.net.URL[] |
urls |
| Constructor and Description |
|---|
ResourceEnumeration(java.lang.String subPath,
java.lang.String glob,
boolean recurse,
java.net.URL[] urls)
Creates an
Enumeration that scans the given URLs for resources matching the globbed pattern. |
| Modifier and Type | Method and Description |
|---|---|
private java.net.URL |
findResource(java.lang.String name)
Returns a
URL pointing to the named resource underneath the current search URL. |
boolean |
hasMoreElements() |
private boolean |
matchesRequest(java.lang.String entryName)
Compares the given entry name against the normalized search path and compiled glob pattern.
|
java.net.URL |
nextElement() |
(package private) static java.lang.String |
normalizeSearchPath(java.lang.String path)
Normalizes the initial search path by removing any duplicate or initial slashes.
|
private java.util.Iterator<java.lang.String> |
scan(java.net.URL url)
Returns the appropriate
Iterator to iterate over the contents of the given URL. |
private static final java.util.Iterator<java.lang.String> NO_ENTRIES
private final java.net.URL[] urls
private final java.lang.String subPath
private final GlobberStrategy globber
private final java.lang.Object globPattern
private final boolean recurse
private int index
private java.net.URL currentURL
private boolean isFolder
private java.util.Iterator<java.lang.String> entryNames
private java.lang.String nextEntryName
ResourceEnumeration(java.lang.String subPath,
java.lang.String glob,
boolean recurse,
java.net.URL[] urls)
Enumeration that scans the given URLs for resources matching the globbed pattern.subPath - An optional path to begin the search fromglob - The globbed basename patternrecurse - When true search paths below the initial search point; otherwise don'turls - The URLs containing resourcespublic boolean hasMoreElements()
hasMoreElements in interface java.util.Enumeration<java.net.URL>public java.net.URL nextElement()
nextElement in interface java.util.Enumeration<java.net.URL>static java.lang.String normalizeSearchPath(java.lang.String path)
path - The path to normalizeprivate java.util.Iterator<java.lang.String> scan(java.net.URL url)
Iterator to iterate over the contents of the given URL.url - The containing URLprivate java.net.URL findResource(java.lang.String name)
throws java.net.MalformedURLException
URL pointing to the named resource underneath the current search URL.name - The resource namejava.net.MalformedURLExceptionprivate boolean matchesRequest(java.lang.String entryName)
entryName - The entry nametrue if the given name matches the search criteria; otherwise false