Top Description Constructors Methods
org.jboss.modules

public final Class PathUtils

extends Object
Class Inheritance
Static Imports
java.lang.Math.max

General helpful path utility methods.
Author
David M. Lloyd

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

the path specification, or null if the name is not valid
basicModuleNameToPath
(final String
the basic module name
moduleName
)

Convert a "basic" module name to a relative path specification.

public static String

Returns:

the canonical path
canonicalize
(String
the relative or absolute possibly non-canonical path
path
)

Canonicalize the given path.

pack-priv static <T> Map<String, List<T>>
deduplicateLists(Map<String, List<T>> allPaths)

Takes a list of maps an returns an immutable representation of the same map, with all duplicate lists coalesced into a single object, and with all lists replaced by immutable array lists that has a backing array that is the correct size for the number of contents.

public static String

Returns:

the file name
fileNameOfPath
(String
the path name
path
)

Get the file name (last) segment of the given path.

public static <
the collection type
T extends Collection<? super String>
>
T

Returns:

the target set
filterPaths
(Iterable<String>
the source paths
source
,
PathFilter
the filter to apply
filter
,
T
the destination for filtered paths
target
)

Filter the paths from source into target using filter.

public static Set<String>

Returns:

the set, or null if the paths could not be determined
getPathSet
(ClassLoader
the class loader to inspect
classLoader
)

Attempt to get a set of all paths defined directly by the given class loader.

private static boolean
isAllowedPunct(final int cp)

public static boolean

Returns:

true if the child is truly a child of parent
isChild
(final String
the parent path
parent
,
final String
the child path
child
)

Determine whether one path is a child of another.

public static boolean

Returns:

true if the child is truly a direct child of parent
isDirectChild
(final String
the parent path
parent
,
final String
the child path
child
)

Determine whether one path is a direct (or immediate) child of another.

public static boolean

Returns:

true if it is relative
isRelative
(final String
the path name
path
)

Determine whether a path name is relative.

public static boolean

Returns:

true if it is a separator
isSeparator
(final char
the character to test
ch
)

Determine whether the given character is a / or a platform-specific separator.

public static String

Returns:

the relative path
relativize
(String
the path to relativize
path
)

Relativize the given path.

public static String

Returns:

the same string with OS-specific separators replaced with /
toGenericSeparators
(String
the original string
original
)

Get the given path name with OS-specific separators replaced with the generic / separator character.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

PathUtilsback to summary
private PathUtils()

Method Detail

basicModuleNameToPathback to summary
public static String basicModuleNameToPath(final String moduleName)

Convert a "basic" module name to a relative path specification.

Parameters
moduleName:String

the basic module name

Returns:String

the path specification, or null if the name is not valid

canonicalizeback to summary
public static String canonicalize(String path)

Canonicalize the given path. Removes all . and .. segments from the path.

Parameters
path:String

the relative or absolute possibly non-canonical path

Returns:String

the canonical path

deduplicateListsback to summary
pack-priv static <T> Map<String, List<T>> deduplicateLists(Map<String, List<T>> allPaths)

Takes a list of maps an returns an immutable representation of the same map, with all duplicate lists coalesced into a single object, and with all lists replaced by immutable array lists that has a backing array that is the correct size for the number of contents. This can result in a significant memory saving for some use cases

fileNameOfPathback to summary
public static String fileNameOfPath(String path)

Get the file name (last) segment of the given path.

Parameters
path:String

the path name

Returns:String

the file name

filterPathsback to summary
public static <T extends Collection<? super String>> T filterPaths(Iterable<String> source, PathFilter filter, T target)

Filter the paths from source into target using filter.

Parameters
<T>
the collection type
source:Iterable<String>

the source paths

filter:PathFilter

the filter to apply

target:T

the destination for filtered paths

Returns:T

the target set

getPathSetback to summary
public static Set<String> getPathSet(ClassLoader classLoader)

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:ClassLoader

the class loader to inspect

Returns:Set<String>

the set, or null if the paths could not be determined

isAllowedPunctback to summary
private static boolean isAllowedPunct(final int cp)
isChildback to summary
public static boolean isChild(final String parent, final String child)

Determine whether one path is a child of another.

Parameters
parent:String

the parent path

child:String

the child path

Returns:boolean

true if the child is truly a child of parent

isDirectChildback to summary
public static boolean isDirectChild(final String parent, final String child)

Determine whether one path is a direct (or immediate) child of another.

Parameters
parent:String

the parent path

child:String

the child path

Returns:boolean

true if the child is truly a direct child of parent

isRelativeback to summary
public static boolean isRelative(final String path)

Determine whether a path name is relative.

Parameters
path:String

the path name

Returns:boolean

true if it is relative

isSeparatorback to summary
public static boolean isSeparator(final char ch)

Determine whether the given character is a / or a platform-specific separator.

Parameters
ch:char

the character to test

Returns:boolean

true if it is a separator

relativizeback to summary
public static String relativize(String path)

Relativize the given path. Removes any leading / segments from the path.

Parameters
path:String

the path to relativize

Returns:String

the relative path

toGenericSeparatorsback to summary
public static String toGenericSeparators(String original)

Get the given path name with OS-specific separators replaced with the generic / separator character.

Parameters
original:String

the original string

Returns:String

the same string with OS-specific separators replaced with /