ClassPathUtils¶
- public class org.apache.commons.lang3.ClassPathUtils[source]¶
Operations regarding the classpath.
The methods of this class do not allow
nullinputs.- Since:
3.3
Constructors¶
Deprecated. |
- @Deprecated public ClassPathUtils()[source]¶
Deprecated: TODO Make private in 4.0.
ClassPathUtilsinstances should NOT be constructed in standard programming. Instead, the class should be used asClassPathUtils.toFullyQualifiedName(MyClass.class, "MyClass.properties");.This constructor is public to permit tools that require a JavaBean instance to operate.
Methods¶
Converts a package name to a Java path (‘/’). |
|
Converts a Java path (‘/’) to a package name. |
|
Returns the fully qualified name for the resource with name |
|
Returns the fully qualified name for the resource with name |
|
Returns the fully qualified path for the resource with name |
|
Returns the fully qualified path for the resource with name |
- public static String packageToPath(String path)[source]¶
Converts a package name to a Java path (‘/’).
- Parameters:
path – The source path.
- Returns:
A package name.
- Throws:
java.lang.NullPointerException – Thrown if
pathis null.- Since:
3.13.0
- public static String pathToPackage(String path)[source]¶
Converts a Java path (‘/’) to a package name.
- Parameters:
path – The source path.
- Returns:
A package name.
- Throws:
java.lang.NullPointerException – Thrown if
pathis null.- Since:
3.13.0
- public static String toFullyQualifiedName(Class<?> context, String resourceName)[source]¶
Returns the fully qualified name for the resource with name
resourceNamerelative 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 – The context for constructing the name.
resourceName – The resource name to construct the fully qualified name for.
- Returns:
The fully qualified name of the resource with name
resourceName.- Throws:
java.lang.NullPointerException – Thrown if either
contextorresourceNameis null.
- public static String toFullyQualifiedName(Package context, String resourceName)[source]¶
Returns the fully qualified name for the resource with name
resourceNamerelative 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 – The context for constructing the name.
resourceName – The resource name to construct the fully qualified name for.
- Returns:
The fully qualified name of the resource with name
resourceName.- Throws:
java.lang.NullPointerException – Thrown if either
contextorresourceNameis null.
- public static String toFullyQualifiedPath(Class<?> context, String resourceName)[source]¶
Returns the fully qualified path for the resource with name
resourceNamerelative 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 – The context for constructing the path.
resourceName – The resource name to construct the fully qualified path for.
- Returns:
The fully qualified path of the resource with name
resourceName.- Throws:
java.lang.NullPointerException – Thrown if either
contextorresourceNameis null.
- public static String toFullyQualifiedPath(Package context, String resourceName)[source]¶
Returns the fully qualified path for the resource with name
resourceNamerelative 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 – The context for constructing the path.
resourceName – The resource name to construct the fully qualified path for.
- Returns:
The fully qualified path of the resource with name
resourceName.- Throws:
java.lang.NullPointerException – Thrown if either
contextorresourceNameis null.