@groovy.transform.CompileStatic @groovy.util.logging.Slf4j class ClassPathScanner extends java.lang.Object
Utility to scan the class path for folder with resources from all modules (.jar files) and class path directories. Supports only the format: 'folder/*.ext'.
Type | Name and description |
---|---|
private java.lang.ClassLoader |
classLoader The classloader to use |
private static org.simplemes.eframe.misc.ClassPathScannerFactory |
factory The factory to build a class path scanner. |
private java.util.regex.Pattern |
searchPattern The Matching pattern for the given search spec. |
private java.lang.String |
searchSpec The path format to search for. |
Constructor and description |
---|
ClassPathScanner
(java.lang.String searchSpec) Builds a scanner for the given search spec. |
ClassPathScanner
() |
Type Params | Return Type | Name and description |
---|---|---|
|
java.net.URL |
buildJarFileUrl(java.io.File file, java.lang.String path) Builds a jar file URL for the given jar file and path. |
|
java.lang.String |
getJarFilePath(java.net.URL url) Gets the file name for the given JAR file URL. |
|
java.lang.String |
getRootPath() Returns the root path for the desired resources. |
|
java.lang.String |
match(java.net.URL url) Returns the portion of the given URL matches the desired search spec. |
|
java.lang.String |
match(java.lang.String url) Returns the portion of the given URL matches the desired search spec. |
|
java.util.List |
scan() Scans the classpath for matching resources. |
|
java.util.List |
scanFileFolder(java.io.File folder) Scan a file folder, including sub-folders. |
|
java.util.List |
scanJarFolder(java.io.File file) Scan a JAR file folder, including sub-folders. |
|
java.util.List |
scanResource(java.net.URL url) Scans a single resource for sub-elements that match the pattern. |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
The classloader to use
The factory to build a class path scanner. This allows tests to provide specific results from the scan() method.
The Matching pattern for the given search spec.
The path format to search for. Supports only the format: 'folder/*.ext'.
Builds a scanner for the given search spec.
searchSpec
- The path format to search for. Supports only the format: 'folder/*.ext'.Builds a jar file URL for the given jar file and path. @return
file
- The .jar file.path
- TheGets the file name for the given JAR file URL.
url
- The URL of the jar file to get.Returns the root path for the desired resources.
Returns the portion of the given URL matches the desired search spec.
url
- The URL to check.Returns the portion of the given URL matches the desired search spec.
url
- The string form of URL to check.Scans the classpath for matching resources.
Scan a file folder, including sub-folders.
folder
- The folder to check.Scan a JAR file folder, including sub-folders.
url
- The URL of the jar file to check.Scans a single resource for sub-elements that match the pattern.
url
- The resource to check.Groovy Documentation