Class JarUtils
java.lang.Object
nonapi.io.github.classgraph.utils.JarUtils
Jarfile utilities.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PatternCheck if a path has a URL scheme at the beginning. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringclassfilePathToClassName(String classfilePath) Convert a classfile path to the corresponding class name.static StringclassNameToClassfilePath(String className) Convert a class name to the corresponding classfile path.static StringderivedAutomaticModuleName(String jarPath) Derive automatic module name from jar name, using this algorithm.static StringReturns the leafname of a path, after first stripping off everything after the first '!'static StringpathElementsToPathStr(Iterable<?> pathElts) Get a set of path elements as a string, from an array of objects (e.g. of String, File or URL type, whose toString() method will be called to get the path component), and return the path as a single string delineated with the standard path separator character.static StringpathElementsToPathStr(Object... pathElts) Get a set of path elements as a string, from an array of objects (e.g. of String, File or URL type, whose toString() method will be called to get the path component), and return the path as a single string delineated with the standard path separator character.static String[]smartPathSplit(String pathStr, char separatorChar, ScanSpec scanSpec) Split a path on the given separator char.static String[]smartPathSplit(String pathStr, ScanSpec scanSpec) Split a path on File.pathSeparator (':' on Linux, ';' on Windows), but also allow for the use of URLs with protocol specifiers, e.g.
-
Field Details
-
URL_SCHEME_PATTERN
Check if a path has a URL scheme at the beginning. Require at least 2 chars in a URL scheme, so that Windows drive designations don't get treated as URL schemes.
-
-
Method Details
-
smartPathSplit
Split a path on File.pathSeparator (':' on Linux, ';' on Windows), but also allow for the use of URLs with protocol specifiers, e.g. "http://domain/jar1.jar:http://domain/jar2.jar".- Parameters:
pathStr- The path to split.scanSpec- the scan spec- Returns:
- The path element substrings.
-
smartPathSplit
Split a path on the given separator char. If the separator char is ':', also allow for the use of URLs with protocol specifiers, e.g. "http://domain/jar1.jar:http://domain/jar2.jar".- Parameters:
pathStr- The path to split.separatorChar- The separator char to use.scanSpec- the scan spec- Returns:
- The path element substrings.
-
pathElementsToPathStr
Get a set of path elements as a string, from an array of objects (e.g. of String, File or URL type, whose toString() method will be called to get the path component), and return the path as a single string delineated with the standard path separator character.- Parameters:
pathElts- The path elements.- Returns:
- The delimited path formed out of the path elements.
-
pathElementsToPathStr
Get a set of path elements as a string, from an array of objects (e.g. of String, File or URL type, whose toString() method will be called to get the path component), and return the path as a single string delineated with the standard path separator character.- Parameters:
pathElts- The path elements.- Returns:
- The delimited path formed out of the path elements, after calling each of their toString() methods.
-
leafName
-
classfilePathToClassName
-
classNameToClassfilePath
-
derivedAutomaticModuleName
Derive automatic module name from jar name, using this algorithm.- Parameters:
jarPath- The jar path.- Returns:
- The automatic module name.
-