|
45 | 45 | */
|
46 | 46 | public class ClassPathResource extends AbstractFileResolvingResource {
|
47 | 47 |
|
| 48 | + /** |
| 49 | + * Internal representation of the original path supplied by the user, |
| 50 | + * used for creating relative paths and resolving URLs and InputStreams. |
| 51 | + */ |
48 | 52 | private final String path;
|
49 | 53 |
|
50 | 54 | private final String absolutePath;
|
@@ -119,44 +123,13 @@ else if (absolutePath.startsWith("/")) {
|
119 | 123 |
|
120 | 124 |
|
121 | 125 | /**
|
122 |
| - * Return the path for this resource. |
123 |
| - * <p>If this resource was created using |
124 |
| - * {@link ClassPathResource#ClassPathResource(String) ClassPathResource(String)} |
125 |
| - * or {@link ClassPathResource#ClassPathResource(String, ClassLoader) |
126 |
| - * ClassPathResource(String, ClassLoader)}, the returned path is a |
127 |
| - * {@linkplain StringUtils#cleanPath(String) cleaned} version of the |
128 |
| - * <em>absolute path</em> supplied to the constructor, <strong>without</strong> |
129 |
| - * a leading slash. |
130 |
| - * <p>If this resource was created using |
131 |
| - * {@link ClassPathResource#ClassPathResource(String, Class) |
132 |
| - * ClassPathResource(String, Class)} with an absolute path, the returned path |
133 |
| - * is a {@linkplain StringUtils#cleanPath(String) cleaned} version of the |
134 |
| - * <em>absolute path</em> supplied to the constructor, <strong>with</strong> |
135 |
| - * a leading slash. |
136 |
| - * <p>If this resource was created using |
137 |
| - * {@link ClassPathResource#ClassPathResource(String, Class) |
138 |
| - * ClassPathResource(String, Class)} with a relative path, the returned path |
139 |
| - * is a {@linkplain StringUtils#cleanPath(String) cleaned} version of the |
140 |
| - * <em>relative path</em> supplied to the constructor. |
141 |
| - * <p>The path returned by this method cannot be reliably used with |
142 |
| - * {@link ClassLoader#getResource(String)}. |
143 |
| - * <p>If you consistently need the <em>absolute path</em>, use |
144 |
| - * {@link #getAbsolutePath()} instead. |
145 |
| - * @see #getAbsolutePath() |
| 126 | + * Return the <em>absolute path</em> for this resource, as a |
| 127 | + * {@linkplain StringUtils#cleanPath(String) cleaned} resource path within |
| 128 | + * the class path. |
| 129 | + * <p>The path returned by this method does not have a leading slash and is |
| 130 | + * suitable for use with {@link ClassLoader#getResource(String)}. |
146 | 131 | */
|
147 | 132 | public final String getPath() {
|
148 |
| - return this.path; |
149 |
| - } |
150 |
| - |
151 |
| - /** |
152 |
| - * Return the <em>absolute path</em> for this resource, as a resource path |
153 |
| - * within the class path without a leading slash. |
154 |
| - * <p>The path returned by this method is suitable for use with |
155 |
| - * {@link ClassLoader#getResource(String)}. |
156 |
| - * @since 6.0 |
157 |
| - * @see #getPath() |
158 |
| - */ |
159 |
| - public final String getAbsolutePath() { |
160 | 133 | return this.absolutePath;
|
161 | 134 | }
|
162 | 135 |
|
|
0 commit comments