Package org.jboss.modules
Class PathUtils
- java.lang.Object
-
- org.jboss.modules.PathUtils
-
public final class PathUtils extends java.lang.ObjectGeneral helpful path utility methods.
-
-
Constructor Summary
Constructors Modifier Constructor Description privatePathUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Stringcanonicalize(java.lang.String path)Canonicalize the given path.static <T extends java.util.Collection<? super java.lang.String>>
TfilterPaths(java.lang.Iterable<java.lang.String> source, PathFilter filter, T target)Filter the paths fromsourceintotargetusingfilter.static java.util.Set<java.lang.String>getPathSet(java.lang.ClassLoader classLoader)Attempt to get a set of all paths defined directly by the given class loader.static booleanisChild(java.lang.String parent, java.lang.String child)Determine whether one path is a child of another.static booleanisDirectChild(java.lang.String parent, java.lang.String child)Determine whether one path is a direct (or immediate) child of another.static booleanisRelative(java.lang.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 java.lang.Stringrelativize(java.lang.String path)Relativize the given path.
-
-
-
Method Detail
-
filterPaths
public static <T extends java.util.Collection<? super java.lang.String>> T filterPaths(java.lang.Iterable<java.lang.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
public static java.util.Set<java.lang.String> getPathSet(java.lang.ClassLoader classLoader)
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
public static java.lang.String relativize(java.lang.String path)
Relativize the given path. Removes any leading/segments from the path.- Parameters:
path- the path to relativize- Returns:
- the relative path
-
canonicalize
public static java.lang.String canonicalize(java.lang.String path)
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
public static boolean isChild(java.lang.String parent, java.lang.String child)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
public static boolean isDirectChild(java.lang.String parent, java.lang.String child)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
-
isRelative
public static boolean isRelative(java.lang.String path)
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
-
-