Package org.eclipse.sisu.space
Class ResourceEnumeration
java.lang.Object
org.eclipse.sisu.space.ResourceEnumeration
- All Implemented Interfaces:
Enumeration<URL>
Enumeration
of resources found by scanning JARs and directories.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
CustomURLConnection
that can access JARs nested inside an arbitrary resource.(package private) static final class
CustomURLStreamHandler
that can stream JARs nested inside an arbitrary resource. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionResourceEnumeration
(String subPath, String glob, boolean recurse, URL[] urls) Creates anEnumeration
that scans the given URLs for resources matching the globbed pattern. -
Method Summary
Modifier and TypeMethodDescriptionprivate URL
findResource
(String name) Returns aURL
pointing to the named resource underneath the current search URL.boolean
private boolean
matchesRequest
(String entryName) Compares the given entry name against the normalized search path and compiled glob pattern.(package private) static String
normalizeSearchPath
(String path) Normalizes the initial search path by removing any duplicate or initial slashes.Returns the appropriateIterator
to iterate over the contents of the given URL.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Enumeration
asIterator
-
Field Details
-
NO_ENTRIES
-
urls
-
subPath
-
globber
-
globPattern
-
recurse
private final boolean recurse -
index
private int index -
currentURL
-
isFolder
private boolean isFolder -
entryNames
-
nextEntryName
-
-
Constructor Details
-
ResourceEnumeration
Creates anEnumeration
that scans the given URLs for resources matching the globbed pattern.- Parameters:
subPath
- An optional path to begin the search fromglob
- The globbed basename patternrecurse
- Whentrue
search paths below the initial search point; otherwise don'turls
- The URLs containing resources
-
-
Method Details
-
hasMoreElements
public boolean hasMoreElements()- Specified by:
hasMoreElements
in interfaceEnumeration<URL>
-
nextElement
- Specified by:
nextElement
in interfaceEnumeration<URL>
-
normalizeSearchPath
Normalizes the initial search path by removing any duplicate or initial slashes.- Parameters:
path
- The path to normalize- Returns:
- Normalized search path
-
scan
Returns the appropriateIterator
to iterate over the contents of the given URL.- Parameters:
url
- The containing URL- Returns:
- Iterator that iterates over resources contained inside the given URL
-
findResource
Returns aURL
pointing to the named resource underneath the current search URL.- Parameters:
name
- The resource name- Returns:
- URL for the resource
- Throws:
MalformedURLException
-
matchesRequest
Compares the given entry name against the normalized search path and compiled glob pattern.- Parameters:
entryName
- The entry name- Returns:
true
if the given name matches the search criteria; otherwisefalse
-