Save This Page
Home » apache-ant-1.8.1 » org.apache.tools » ant » launch » [javadoc | source]
org.apache.tools.ant.launch
public final class: Locator [javadoc | source]
java.lang.Object
   org.apache.tools.ant.launch.Locator
The Locator is a utility class which is used to find certain items in the environment. It is used at boot time in the launcher, and cannot make use of any of Ant's other classes. This is a surprisingly brittle piece of code, and has had lots of bugs filed against it. 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.
Field Summary
public static final  String URI_ENCODING    encoding used to represent URIs 
public static final  String ERROR_NOT_FILE_URI    Error string used when an invalid uri is seen 
Method from org.apache.tools.ant.launch.Locator Summary:
decodeUri,   encodeURI,   fileToURL,   fromJarURI,   fromURI,   getClassSource,   getLocationURLs,   getLocationURLs,   getResourceSource,   getToolsJar
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.tools.ant.launch.Locator Detail:
 public static String decodeUri(String uri) throws UnsupportedEncodingException 
    Decodes an Uri with % characters. The URI is escaped
 public static String encodeURI(String path) throws UnsupportedEncodingException 
    Encodes an Uri with % characters. The URI is escaped
 public static URL fileToURL(File file) throws MalformedURLException 
    Convert a File to a URL. File.toURL() does not encode characters like #. File.toURI() has been introduced in java 1.4, so Ant cannot use it (except by reflection) FileUtils.toURI() cannot be used by Locator.java Implemented this way. File.toURL() adds file: and changes '\' to '/' for dos OSes encodeURI converts characters like ' ' and '#' to %DD
 public static String fromJarURI(String uri) 
    Crack a JAR URI. This method is public for testing; we may delete it without any warning -it is not part of Ant's stable API.
 public static String fromURI(String uri) 
    Constructs a file path from a 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.
 public static File getClassSource(Class c) 
    Find the directory or jar file the class has been loaded from.
 public static URL[] getLocationURLs(File location) throws MalformedURLException 
    Get an array of URLs representing all of the jar files in the given location. If the location is a file, it is returned as the only element of the array. If the location is a directory, it is scanned for jar files.
 public static URL[] getLocationURLs(File location,
    String[] extensions) throws MalformedURLException 
    Get an array of URLs representing all of the files of a given set of extensions in the given location. If the location is a file, it is returned as the only element of the array. If the location is a directory, it is scanned for matching files.
 public static File getResourceSource(ClassLoader c,
    String resource) 
    Find the directory or jar a given resource has been loaded from.
 public static File getToolsJar() 
    Get the File necessary to load the Sun compiler tools. If the classes are available to this class, then no additional URL is required and null is returned. This may be because the classes are explicitly in the class path or provided by the JVM directly.