Package org.jboss.modules
Class PathUtils
java.lang.Object
org.jboss.modules.PathUtils
General helpful path utility methods.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
canonicalize
(String path) Canonicalize the given path.static <T extends Collection<? super String>>
TfilterPaths
(Iterable<String> source, PathFilter filter, T target) Filter the paths fromsource
intotarget
usingfilter
.getPathSet
(ClassLoader classLoader) Attempt to get a set of all paths defined directly by the given class loader.static boolean
Determine whether one path is a child of another.static boolean
isDirectChild
(String parent, String child) Determine whether one path is a direct (or immediate) child of another.static boolean
isRelative
(String path) Determine whether a path name is relative.static boolean
isSeparator
(char ch) Determine whether the given character is a/
or a platform-specific separator.static String
relativize
(String path) Relativize the given path.
-
Constructor Details
-
PathUtils
private PathUtils()
-
-
Method Details
-
filterPaths
public static <T extends Collection<? super String>> T filterPaths(Iterable<String> source, PathFilter filter, T target) Filter the paths fromsource
intotarget
usingfilter
.- Type Parameters:
T
- the collection type- Parameters:
source
- the source pathsfilter
- the filter to applytarget
- the destination for filtered paths- Returns:
- the
target
set
-
getPathSet
Attempt to get a set of all paths defined directly by the given class loader. If the path set cannot be ascertained,null
is returned.- Parameters:
classLoader
- the class loader to inspect- Returns:
- the set, or
null
if 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
-
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:
true
if 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:
true
if the child is truly a direct child of parent
-
isRelative
Determine whether a path name is relative.- Parameters:
path
- the path name- Returns:
true
if 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:
true
if it is a separator
-