Class ResourceUtils
java.lang.Object
org.zeroturnaround.javarebel.support.ResourceUtils
Utility methods for resolving resource locations to files in the
file system.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringURL protocol for an entry from a JBoss jar file: "vfszip" -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringextractJarEntryPath(URL jarUrl) Extract the JAR entry from the given URLstatic URLextractJarFileURL(URL jarUrl) Extract the URL for the actual jar file from the given URL (which may point to a resource in a jar file or to a jar file itself).static Filestatic FileResolve the given resource URL to ajava.io.File, i.e.static FileResolve the given resource URL to ajava.io.File, i.e.static FileResolve the given resource URL to ajava.io.File, i.e.static File[]static booleanDetermine whether the given URL points to a resource in the file system.static booleanDetermine whether the given URL points to a resource in a jar file, that is, has protocol "jar", "zip", "wsjar" or "code-source".static booleanisNestedJarEntry(String entry) Determine if the jar entry is in a nested jarstatic booleanDetermines if the parameter is a URL with a protocol or notstatic booleanisVirtualJarURL(URL url) static URICreate a URI instance for the given location String, replacing spaces with "%20" quotes first.static URICreate a URI instance for the given URL, replacing spaces with "%20" quotes first.
-
Field Details
-
URL_PROTOCOL_VFSZIP
URL protocol for an entry from a JBoss jar file: "vfszip"- See Also:
-
-
Constructor Details
-
ResourceUtils
public ResourceUtils()
-
-
Method Details
-
isUrl
Determines if the parameter is a URL with a protocol or not- Parameters:
s- a String to check if it's URL- Returns:
- a true if the s was url
-
getFile
Resolve the given resource URL to ajava.io.File, i.e. to a file in the file system.- Parameters:
resourceUrl- the resource URL to resolvesc- a backup RebelServletContext to make some checks- Returns:
- a corresponding File object or null
-
getFile
Resolve the given resource URL to ajava.io.File, i.e. to a file in the file system.- Parameters:
resourceUrl- the resource URL to resolve- Returns:
- a corresponding File object
-
getFile
-
getFiles
-
getFile
Resolve the given resource URL to ajava.io.File, i.e. to a file in the file system.- Parameters:
resourceUrl- the resource URL to resolvedescription- a description of the original resource that the URL was created for (for example, a class path location)- Returns:
- a corresponding File object
-
isFileURL
Determine whether the given URL points to a resource in the file system.- Parameters:
url- the URL to check. May be null.- Returns:
- true if url references a file
-
isJarURL
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 OC4J, provided that the path contains a jar separator.
- Parameters:
url- the URL to check. May be null.- Returns:
- whether the URL has been identified as a JAR URL
-
isVirtualJarURL
-
isNestedJarEntry
Determine if the jar entry is in a nested jar- Parameters:
entry- Then name of the entry in the jar file- Returns:
- if the entry is in a nested jar
-
extractJarFileURL
Extract the URL for the actual jar file from the given URL (which may point to a resource in a jar file or to a jar file itself).- Parameters:
jarUrl- the original URL- Returns:
- the URL for the actual jar file
-
extractJarEntryPath
Extract the JAR entry from the given URL- Parameters:
jarUrl- the original URL- Returns:
- the JAR entry
-
toURI
Create a URI instance for the given URL, replacing spaces with "%20" quotes first.Furthermore, this method works on JDK 1.4 as well, in contrast to the
URL.toURI()method.- Parameters:
url- the URL to convert into a URI instance- Returns:
- the URI instance
- Throws:
URISyntaxException- if the URL wasn't a valid URI- See Also:
-
toURI
Create a URI instance for the given location String, replacing spaces with "%20" quotes first.- Parameters:
location- the location String to convert into a URI instance- Returns:
- the URI instance
- Throws:
URISyntaxException- if the location wasn't a valid URI
-