org.apache.tools.ant.launch
public final class Locator extends Object
running ant off a network share can cause Ant to fail
use File.toURI().toURL().toExternalForm()
Locator implementation not encoding URI strings properly: spaces in paths
It also breaks Eclipse 3.3 Betas
Exception if installation path has spaces
Be very careful when making changes to this class, as a break will upset a lot of people.Since: Ant 1.6
Field Summary | |
---|---|
static String | ERROR_NOT_FILE_URI Error string used when an invalid uri is seen |
static String | URI_ENCODING
encoding used to represent URIs |
Method Summary | |
---|---|
static String | decodeUri(String uri)
Decodes an Uri with % characters.
|
static String | encodeURI(String path)
Encodes an Uri with % characters.
|
static URL | fileToURL(File file)
Convert a File to a URL.
|
static String | fromURI(String uri)
Constructs a file path from a file: URI.
|
static File | getClassSource(Class c)
Find the directory or jar file the class has been loaded from.
|
static URL[] | getLocationURLs(File location)
Get an array of URLs representing all of the jar files in the
given location. |
static URL[] | getLocationURLs(File location, String[] extensions)
Get an array of URLs representing all of the files of a given set of
extensions in the given location. |
static File | getResourceSource(ClassLoader c, String resource)
Find the directory or jar a given resource has been loaded from.
|
static File | getToolsJar()
Get the File necessary to load the Sun compiler tools. |
Parameters: uri String with the uri possibly containing % characters.
Returns: The decoded Uri
Throws: UnsupportedEncodingException if UTF-8 is not available
Since: Ant 1.7
Parameters: path String to encode.
Returns: The encoded string, according to URI norms
Throws: UnsupportedEncodingException if UTF-8 is not available
Since: Ant 1.7
Parameters: file the file to convert
Returns: URL the converted File
Throws: MalformedURLException on error
file:
URI.
Will be an absolute path if the given URI is absolute.
Prior to Java 1.4, swallows '%' that are not followed by two characters.
See dt-sysid which makes some mention of how characters not supported by URI Reference syntax should be escaped.Parameters: uri the URI designating a file in the local filesystem.
Returns: the local file system path for the file.
Throws: IllegalArgumentException if the URI is malformed or not a legal file: URL
Since: Ant 1.6
Parameters: c the class whose location is required.
Returns: the file or jar with the class or null if we cannot determine the location.
Since: Ant 1.6
Parameters: location the location to scan for Jars.
Returns: an array of URLs for all jars in the given location.
Throws: MalformedURLException if the URLs for the jars cannot be formed.
Parameters: location the location to scan for files. extensions an array of extension that are to match in the directory search.
Returns: an array of URLs of matching files.
Throws: MalformedURLException if the URLs for the files cannot be formed.
Parameters: c the classloader to be consulted for the source. resource the resource whose location is required.
Returns: the file with the resource source or null if we cannot determine the location.
Since: Ant 1.6
Returns: the tools jar as a File if required, null otherwise.