commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Woonsan Ko (JIRA)" <>
Subject [jira] [Commented] (LANG-417) ClassUtils: method for turning FQN into resource path
Date Tue, 22 Oct 2013 17:50:43 GMT


Woonsan Ko commented on LANG-417:

I'd like to suggest the following:

public class ResourceUtils {
    public static String toAbsoluteResourceName(Package context, name);
    public static String toAbsoluteResourceName(Class context, name);

According to the original description above, he just wanted to replace a resource name by
an absolute resource name. e.g, [ com.example.Hello.class, '' ] ->
In this sense, URL doesn't seem to be proper. URL is likely to have something like 'file:///...',
which is different from the original request. I assume he wanted to use something like ClassLoader#getResource()
in the end.
Also, the suggested api, toResourcePath(String fqName), doesn't seem to be necessary in this

By the way, I think we'd better use 'AbsoluteResourceName' instead of 'ResourcePath' because
the former one is similar to the javadoc explanation in java.lang.Class#getResource(name)
(quote: "Before delegation, an *absolute resource name* is constructed from the given resource
name using this algorithm"), and 'path' may sound confusing because the return value doesn't
represent a full (file) path at all.

Just my two cents,


> ClassUtils: method for turning FQN into resource path
> -----------------------------------------------------
>                 Key: LANG-417
>                 URL:
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.*
>            Reporter: Paul Benedict
>             Fix For: Patch Needed
> I commonly need a FQ path to a resource within the same location as a class file. I recommend
the addition of this method:
> public String getPackageResourcePath(Class clazz, String resourceName)
>     StringBuffer buf = new StringBuffer();
>     buf.append(ClassUtils.getPackageName(getClass()).replace('.', '/'));
>     buf.append("/");
>     buf.append(resourceName);
>     return  buf.toString();
> }

This message was sent by Atlassian JIRA

View raw message