Package org.eclipse.sisu.space
Class ResourceEnumeration
- java.lang.Object
-
- org.eclipse.sisu.space.ResourceEnumeration
-
- All Implemented Interfaces:
java.util.Enumeration<java.net.URL>
final class ResourceEnumeration extends java.lang.Object implements java.util.Enumeration<java.net.URL>Enumerationof resources found by scanning JARs and directories.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classResourceEnumeration.NestedJarConnectionCustomURLConnectionthat can access JARs nested inside an arbitrary resource.(package private) static classResourceEnumeration.NestedJarHandlerCustomURLStreamHandlerthat can stream JARs nested inside an arbitrary resource.
-
Field Summary
Fields Modifier and Type Field Description private java.net.URLcurrentURLprivate java.util.Iterator<java.lang.String>entryNamesprivate GlobberStrategyglobberprivate java.lang.ObjectglobPatternprivate intindexprivate booleanisFolderprivate java.lang.StringnextEntryNameprivate static java.util.Iterator<java.lang.String>NO_ENTRIESprivate booleanrecurseprivate java.lang.StringsubPathprivate java.net.URL[]urls
-
Constructor Summary
Constructors Constructor Description ResourceEnumeration(java.lang.String subPath, java.lang.String glob, boolean recurse, java.net.URL[] urls)Creates anEnumerationthat scans the given URLs for resources matching the globbed pattern.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.net.URLfindResource(java.lang.String name)Returns aURLpointing to the named resource underneath the current search URL.booleanhasMoreElements()private booleanmatchesRequest(java.lang.String entryName)Compares the given entry name against the normalized search path and compiled glob pattern.java.net.URLnextElement()(package private) static java.lang.StringnormalizeSearchPath(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 appropriateIteratorto iterate over the contents of the given URL.
-
-
-
Field Detail
-
NO_ENTRIES
private static final java.util.Iterator<java.lang.String> NO_ENTRIES
-
urls
private final java.net.URL[] urls
-
subPath
private final java.lang.String subPath
-
globber
private final GlobberStrategy globber
-
globPattern
private final java.lang.Object globPattern
-
recurse
private final boolean recurse
-
index
private int index
-
currentURL
private java.net.URL currentURL
-
isFolder
private boolean isFolder
-
entryNames
private java.util.Iterator<java.lang.String> entryNames
-
nextEntryName
private java.lang.String nextEntryName
-
-
Constructor Detail
-
ResourceEnumeration
ResourceEnumeration(java.lang.String subPath, java.lang.String glob, boolean recurse, java.net.URL[] urls)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 Detail
-
hasMoreElements
public boolean hasMoreElements()
- Specified by:
hasMoreElementsin interfacejava.util.Enumeration<java.net.URL>
-
nextElement
public java.net.URL nextElement()
- Specified by:
nextElementin interfacejava.util.Enumeration<java.net.URL>
-
normalizeSearchPath
static java.lang.String normalizeSearchPath(java.lang.String path)
Normalizes the initial search path by removing any duplicate or initial slashes.- Parameters:
path- The path to normalize- Returns:
- Normalized search path
-
scan
private java.util.Iterator<java.lang.String> scan(java.net.URL url)
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
private java.net.URL findResource(java.lang.String name) throws java.net.MalformedURLExceptionReturns aURLpointing to the named resource underneath the current search URL.- Parameters:
name- The resource name- Returns:
- URL for the resource
- Throws:
java.net.MalformedURLException
-
matchesRequest
private boolean matchesRequest(java.lang.String entryName)
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
-
-