Package org.hotswap.agent.util.scanner
Class ClassPathScanner
- java.lang.Object
-
- org.hotswap.agent.util.scanner.ClassPathScanner
-
-
Field Summary
Fields Modifier and Type Field Description static StringFILE_URL_PREFIXstatic StringJAR_URL_PREFIXstatic StringJAR_URL_SEPARATORstatic StringZIP_URL_PREFIX
-
Constructor Summary
Constructors Constructor Description ClassPathScanner()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected JarFilegetJarFile(String jarFileUrl)Resolve the given jar file URL into a JarFile object.voidscan(ClassLoader classLoader, String path, ScannerVisitor visitor)Scan all directories matching path (there might be multiple locations on classpath, JAR directory, ...)protected voidscanDirectory(File pluginDir, ScannerVisitor visitor)Recursively scan the directory.static URItoURI(String location)Create a URI instance for the given location String, replacing spaces with "%20" quotes first.
-
-
-
Field Detail
-
JAR_URL_SEPARATOR
public static final String JAR_URL_SEPARATOR
- See Also:
- Constant Field Values
-
JAR_URL_PREFIX
public static final String JAR_URL_PREFIX
- See Also:
- Constant Field Values
-
ZIP_URL_PREFIX
public static final String ZIP_URL_PREFIX
- See Also:
- Constant Field Values
-
FILE_URL_PREFIX
public static final String FILE_URL_PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
scan
public void scan(ClassLoader classLoader, String path, ScannerVisitor visitor) throws IOException
Description copied from interface:ScannerScan all directories matching path (there might be multiple locations on classpath, JAR directory, ...) and call visitor for each found file.- Specified by:
scanin interfaceScanner- Parameters:
classLoader- classloader to resolve pathpath- a '/'-separated path name that identifies the resource directory. Semantics same asClassLoader.getResources(java.lang.String).visitor- visit each file on the path- Throws:
IOException- any IO exception while scanning
-
scanDirectory
protected void scanDirectory(File pluginDir, ScannerVisitor visitor) throws IOException
Recursively scan the directory.- Parameters:
pluginDir- directory.visitor- callback- Throws:
IOException- exception from a visitor
-
getJarFile
protected JarFile getJarFile(String jarFileUrl) throws IOException
Resolve the given jar file URL into a JarFile object.- Throws:
IOException
-
toURI
public static URI toURI(String location) throws URISyntaxException
Create a URI instance for the given location String, replacing spaces with "%20" quotes first.- Parameters:
location- the location String to convert into a URI instance- Returns:
- the URI instance
- Throws:
URISyntaxException- if the location wasn't a valid URI
-
-