Top Description Constructors Methods
org.apache.commons.lang3

public Class ClassPathUtils

extends Object
Class Inheritance
Imports
java.util.Objects

Operations regarding the classpath.

The methods of this class do not allow null inputs.

Since
3.3

Constructor Summary

AccessConstructor and Description
public
ClassPathUtils()
Deprecated TODO Make private in 4.0.

ClassPathUtils instances should NOT be constructed in standard programming.

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

a package name.
packageToPath
(final String
the source path.
path
)

Converts a package name to a Java path ('/').

public static String

Returns:

a package name.
pathToPackage
(final String
the source path.
path
)

Converts a Java path ('/') to a package name.

public static String

Returns:

the fully qualified name of the resource with name resourceName.
toFullyQualifiedName
(final Class<?>
The context for constructing the name.
context
,
final String
the resource name to construct the fully qualified name for.
resourceName
)

Returns the fully qualified name for the resource with name resourceName relative to the given context.

public static String

Returns:

the fully qualified name of the resource with name resourceName.
toFullyQualifiedName
(final Package
The context for constructing the name.
context
,
final String
the resource name to construct the fully qualified name for.
resourceName
)

Returns the fully qualified name for the resource with name resourceName relative to the given context.

public static String

Returns:

the fully qualified path of the resource with name resourceName.
toFullyQualifiedPath
(final Class<?>
The context for constructing the path.
context
,
final String
the resource name to construct the fully qualified path for.
resourceName
)

Returns the fully qualified path for the resource with name resourceName relative to the given context.

public static String

Returns:

the fully qualified path of the resource with name resourceName.
toFullyQualifiedPath
(final Package
The context for constructing the path.
context
,
final String
the resource name to construct the fully qualified path for.
resourceName
)

Returns the fully qualified path for the resource with name resourceName relative to the given context.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ClassPathUtilsback to summary
public ClassPathUtils()

Deprecated

TODO Make private in 4.0.

ClassPathUtils instances should NOT be constructed in standard programming. Instead, the class should be used as ClassPathUtils.toFullyQualifiedName(MyClass.class, "MyClass.properties");.

This constructor is public to permit tools that require a JavaBean instance to operate.

Annotations
@Deprecated

Method Detail

packageToPathback to summary
public static String packageToPath(final String path)

Converts a package name to a Java path ('/').

Parameters
path:String

the source path.

Returns:String

a package name.

Exceptions
NullPointerException:
if path is null.
Since
3.13.0
pathToPackageback to summary
public static String pathToPackage(final String path)

Converts a Java path ('/') to a package name.

Parameters
path:String

the source path.

Returns:String

a package name.

Exceptions
NullPointerException:
if path is null.
Since
3.13.0
toFullyQualifiedNameback to summary
public static String toFullyQualifiedName(final Class<?> context, final String resourceName)

Returns the fully qualified name for the resource with name resourceName relative to the given context.

Note that this method does not check whether the resource actually exists. It only constructs the name. Null inputs are not allowed.

ClassPathUtils.toFullyQualifiedName(StringUtils.class, "StringUtils.properties") = "org.apache.commons.lang3.StringUtils.properties"
Parameters
context:Class<?>

The context for constructing the name.

resourceName:String

the resource name to construct the fully qualified name for.

Returns:String

the fully qualified name of the resource with name resourceName.

Exceptions
NullPointerException:
if either context or resourceName is null.
toFullyQualifiedNameback to summary
public static String toFullyQualifiedName(final Package context, final String resourceName)

Returns the fully qualified name for the resource with name resourceName relative to the given context.

Note that this method does not check whether the resource actually exists. It only constructs the name. Null inputs are not allowed.

ClassPathUtils.toFullyQualifiedName(StringUtils.class.getPackage(), "StringUtils.properties") = "org.apache.commons.lang3.StringUtils.properties"
Parameters
context:Package

The context for constructing the name.

resourceName:String

the resource name to construct the fully qualified name for.

Returns:String

the fully qualified name of the resource with name resourceName.

Exceptions
NullPointerException:
if either context or resourceName is null.
toFullyQualifiedPathback to summary
public static String toFullyQualifiedPath(final Class<?> context, final String resourceName)

Returns the fully qualified path for the resource with name resourceName relative to the given context.

Note that this method does not check whether the resource actually exists. It only constructs the path. Null inputs are not allowed.

ClassPathUtils.toFullyQualifiedPath(StringUtils.class, "StringUtils.properties") = "org/apache/commons/lang3/StringUtils.properties"
Parameters
context:Class<?>

The context for constructing the path.

resourceName:String

the resource name to construct the fully qualified path for.

Returns:String

the fully qualified path of the resource with name resourceName.

Exceptions
NullPointerException:
if either context or resourceName is null.
toFullyQualifiedPathback to summary
public static String toFullyQualifiedPath(final Package context, final String resourceName)

Returns the fully qualified path for the resource with name resourceName relative to the given context.

Note that this method does not check whether the resource actually exists. It only constructs the path. Null inputs are not allowed.

ClassPathUtils.toFullyQualifiedPath(StringUtils.class.getPackage(), "StringUtils.properties") = "org/apache/commons/lang3/StringUtils.properties"
Parameters
context:Package

The context for constructing the path.

resourceName:String

the resource name to construct the fully qualified path for.

Returns:String

the fully qualified path of the resource with name resourceName.

Exceptions
NullPointerException:
if either context or resourceName is null.