Package org.jboss.modules
Class PathUtils
java.lang.Object
org.jboss.modules.PathUtils
General helpful path utility methods.
- Author:
- David M. Lloyd
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringbasicModuleNameToPath(String moduleName) Convert a "basic" module name to a relative path specification.static Stringcanonicalize(String path) Canonicalize the given path.static StringfileNameOfPath(String path) Get the file name (last) segment of the given path.static <T extends Collection<? super String>>
TfilterPaths(Iterable<String> source, PathFilter filter, T target) Filter the paths fromsourceintotargetusingfilter.getPathSet(ClassLoader classLoader) Attempt to get a set of all paths defined directly by the given class loader.static booleanDetermine whether one path is a child of another.static booleanisDirectChild(String parent, String child) Determine whether one path is a direct (or immediate) child of another.static booleanisRelative(String path) Determine whether a path name is relative.static booleanisSeparator(char ch) Determine whether the given character is a/or a platform-specific separator.static Stringrelativize(String path) Relativize the given path.static StringtoGenericSeparators(String original) Get the given path name with OS-specific separators replaced with the generic/separator character.
-
Method Details
-
filterPaths
public static <T extends Collection<? super String>> T filterPaths(Iterable<String> source, PathFilter filter, T target) Filter the paths fromsourceintotargetusingfilter.- Type Parameters:
T- the collection type- Parameters:
source- the source pathsfilter- the filter to applytarget- the destination for filtered paths- Returns:
- the
targetset
-
getPathSet
Attempt to get a set of all paths defined directly by the given class loader. If the path set cannot be ascertained,nullis returned.- Parameters:
classLoader- the class loader to inspect- Returns:
- the set, or
nullif the paths could not be determined
-
relativize
Relativize the given path. Removes any leading/segments from the path.- Parameters:
path- the path to relativize- Returns:
- the relative path
-
fileNameOfPath
Get the file name (last) segment of the given path.- Parameters:
path- the path name- Returns:
- the file name
-
canonicalize
Canonicalize the given path. Removes all.and..segments from the path.- Parameters:
path- the relative or absolute possibly non-canonical path- Returns:
- the canonical path
-
isChild
Determine whether one path is a child of another.- Parameters:
parent- the parent pathchild- the child path- Returns:
trueif the child is truly a child of parent
-
isDirectChild
Determine whether one path is a direct (or immediate) child of another.- Parameters:
parent- the parent pathchild- the child path- Returns:
trueif the child is truly a direct child of parent
-
toGenericSeparators
Get the given path name with OS-specific separators replaced with the generic/separator character.- Parameters:
original- the original string- Returns:
- the same string with OS-specific separators replaced with
/
-
isRelative
Determine whether a path name is relative.- Parameters:
path- the path name- Returns:
trueif it is relative
-
isSeparator
public static boolean isSeparator(char ch) Determine whether the given character is a/or a platform-specific separator.- Parameters:
ch- the character to test- Returns:
trueif it is a separator
-
basicModuleNameToPath
Convert a "basic" module name to a relative path specification.- Parameters:
moduleName- the basic module name- Returns:
- the path specification, or
nullif the name is not valid
-