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 classCustomURLConnectionthat can access JARs nested inside an arbitrary resource.(package private) static final classCustomURLStreamHandlerthat can stream JARs nested inside an arbitrary resource. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionResourceEnumeration(String subPath, String glob, boolean recurse, URL[] urls) Creates anEnumerationthat scans the given URLs for resources matching the globbed pattern. -
Method Summary
Modifier and TypeMethodDescriptionprivate URLfindResource(String name) Returns aURLpointing to the named resource underneath the current search URL.booleanprivate booleanmatchesRequest(String entryName) Compares the given entry name against the normalized search path and compiled glob pattern.(package private) static StringnormalizeSearchPath(String path) Normalizes the initial search path by removing any duplicate or initial slashes.Returns the appropriateIteratorto 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, waitMethods 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 anEnumerationthat scans the given URLs for resources matching the globbed pattern.- Parameters:
subPath- An optional path to begin the search fromglob- The globbed basename patternrecurse- Whentruesearch paths below the initial search point; otherwise don'turls- The URLs containing resources
-
-
Method Details
-
hasMoreElements
public boolean hasMoreElements()- Specified by:
hasMoreElementsin interfaceEnumeration<URL>
-
nextElement
- Specified by:
nextElementin 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 appropriateIteratorto 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 aURLpointing 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:
trueif the given name matches the search criteria; otherwisefalse
-