diff --git a/spring-core/src/main/java/org/springframework/util/ResourceUtils.java b/spring-core/src/main/java/org/springframework/util/ResourceUtils.java index 8acebff9ab4..cf33d422367 100644 --- a/spring-core/src/main/java/org/springframework/util/ResourceUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ResourceUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2014 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,15 +30,15 @@ import java.net.URLConnection; * *

Consider using Spring's Resource abstraction in the core package * for handling all kinds of file resources in a uniform manner. - * {@link org.springframework.core.io.ResourceLoader}'s {@code getResource} + * {@link org.springframework.core.io.ResourceLoader}'s {@code getResource()} * method can resolve any location to a {@link org.springframework.core.io.Resource} - * object, which in turn allows to obtain a {@code java.io.File} in the + * object, which in turn allows one to obtain a {@code java.io.File} in the * file system through its {@code getFile()} method. * *

The main reason for these utility methods for resource location handling * is to support {@link Log4jConfigurer}, which must be able to resolve * resource locations before the logging system has been initialized. - * Spring' Resource abstraction in the core package, on the other hand, + * Spring's {@code Resource} abstraction in the core package, on the other hand, * already expects the logging system to be available. * * @author Juergen Hoeller @@ -66,15 +66,15 @@ public abstract class ResourceUtils { /** URL protocol for an entry from a zip file: "zip" */ public static final String URL_PROTOCOL_ZIP = "zip"; + /** URL protocol for an entry from a WebSphere jar file: "wsjar" */ + public static final String URL_PROTOCOL_WSJAR = "wsjar"; + /** URL protocol for an entry from a JBoss jar file: "vfszip" */ public static final String URL_PROTOCOL_VFSZIP = "vfszip"; /** URL protocol for a JBoss VFS resource: "vfs" */ public static final String URL_PROTOCOL_VFS = "vfs"; - /** URL protocol for an entry from a WebSphere jar file: "wsjar" */ - public static final String URL_PROTOCOL_WSJAR = "wsjar"; - /** URL protocol for an entry from an OC4J jar file: "code-source" */ public static final String URL_PROTOCOL_CODE_SOURCE = "code-source"; @@ -146,7 +146,7 @@ public abstract class ResourceUtils { /** * Resolve the given resource location to a {@code java.io.File}, * i.e. to a file in the file system. - *

Does not check whether the fil actually exists; simply returns + *

Does not check whether the file actually exists; simply returns * the File that the given location would correspond to. * @param resourceLocation the resource location to resolve: either a * "classpath:" pseudo URL, a "file:" URL, or a plain file path @@ -255,23 +255,22 @@ public abstract class ResourceUtils { */ public static boolean isFileURL(URL url) { String protocol = url.getProtocol(); - return (URL_PROTOCOL_FILE.equals(protocol) || protocol.startsWith(URL_PROTOCOL_VFS)); + return (URL_PROTOCOL_FILE.equals(protocol) || URL_PROTOCOL_VFS.equals(protocol)); } /** * Determine whether the given URL points to a resource in a jar file, * that is, has protocol "jar", "zip", "wsjar" or "code-source". - *

"zip" and "wsjar" are used by BEA WebLogic Server and IBM WebSphere, respectively, - * but can be treated like jar files. The same applies to "code-source" URLs on Oracle + *

"zip" and "wsjar" are used by WebLogic Server and WebSphere, respectively, + * but can be treated like jar files. The same applies to "code-source" URLs on * OC4J, provided that the path contains a jar separator. * @param url the URL to check * @return whether the URL has been identified as a JAR URL */ public static boolean isJarURL(URL url) { String protocol = url.getProtocol(); - return (URL_PROTOCOL_JAR.equals(protocol) || - URL_PROTOCOL_ZIP.equals(protocol) || - URL_PROTOCOL_WSJAR.equals(protocol) || + return (URL_PROTOCOL_JAR.equals(protocol) || URL_PROTOCOL_ZIP.equals(protocol) || + URL_PROTOCOL_WSJAR.equals(protocol) || URL_PROTOCOL_VFSZIP.equals(protocol) || (URL_PROTOCOL_CODE_SOURCE.equals(protocol) && url.getPath().contains(JAR_URL_SEPARATOR))); } @@ -306,7 +305,7 @@ public abstract class ResourceUtils { /** * Create a URI instance for the given URL, - * replacing spaces with "%20" quotes first. + * replacing spaces with "%20" URI encoding first. *

Furthermore, this method works on JDK 1.4 as well, * in contrast to the {@code URL.toURI()} method. * @param url the URL to convert into a URI instance @@ -320,7 +319,7 @@ public abstract class ResourceUtils { /** * Create a URI instance for the given location String, - * replacing spaces with "%20" quotes first. + * replacing spaces with "%20" URI encoding first. * @param location the location String to convert into a URI instance * @return the URI instance * @throws URISyntaxException if the location wasn't a valid URI