????
| Current Path : /opt/ant/manual/api/org/apache/tools/ant/launch/ |
| Current File : //opt/ant/manual/api/org/apache/tools/ant/launch/Locator.html |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_03) on Tue May 22 06:24:51 CEST 2012 -->
<title>Locator (Apache Ant API)</title>
<meta name="date" content="2012-05-22">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Locator (Apache Ant API)";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/tools/ant/launch/LaunchException.html" title="class in org.apache.tools.ant.launch"><span class="strong">Prev Class</span></a></li>
<li>Next Class</li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/tools/ant/launch/Locator.html" target="_top">Frames</a></li>
<li><a href="Locator.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Nested | </li>
<li><a href="#field_summary">Field</a> | </li>
<li>Constr | </li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li><a href="#field_detail">Field</a> | </li>
<li>Constr | </li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.tools.ant.launch</div>
<h2 title="Class Locator" class="title">Class Locator</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>org.apache.tools.ant.launch.Locator</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public final class <span class="strong">Locator</span>
extends java.lang.Object</pre>
<div class="block">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.
<a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=42275">running ant off a network share can cause Ant to fail</a>
<a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=8031">use File.toURI().toURL().toExternalForm()</a>
<a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=42222">Locator implementation not encoding URI strings properly: spaces in paths</a>
It also breaks Eclipse 3.3 Betas
<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=183283">Exception if installation path has spaces</a>
Be very careful when making changes to this class, as a break will upset a lot of people.</div>
<dl><dt><span class="strong">Since:</span></dt>
<dd>Ant 1.6</dd></dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- =========== FIELD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="field_summary">
<!-- -->
</a>
<h3>Field Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Field Summary table, listing fields, and an explanation">
<caption><span>Fields</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Field and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/tools/ant/launch/Locator.html#ERROR_NOT_FILE_URI">ERROR_NOT_FILE_URI</a></strong></code>
<div class="block">Error string used when an invalid uri is seen</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/tools/ant/launch/Locator.html#URI_ENCODING">URI_ENCODING</a></strong></code>
<div class="block">encoding used to represent URIs</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/tools/ant/launch/Locator.html#decodeUri(java.lang.String)">decodeUri</a></strong>(java.lang.String uri)</code>
<div class="block">Decodes an Uri with % characters.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/tools/ant/launch/Locator.html#encodeURI(java.lang.String)">encodeURI</a></strong>(java.lang.String path)</code>
<div class="block">Encodes an Uri with % characters.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.net.URL</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/tools/ant/launch/Locator.html#fileToURL(java.io.File)">fileToURL</a></strong>(java.io.File file)</code>
<div class="block">Convert a File to a URL.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/tools/ant/launch/Locator.html#fromJarURI(java.lang.String)">fromJarURI</a></strong>(java.lang.String uri)</code>
<div class="block">Crack a JAR URI.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.lang.String</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/tools/ant/launch/Locator.html#fromURI(java.lang.String)">fromURI</a></strong>(java.lang.String uri)</code>
<div class="block">Constructs a file path from a <code>file:</code> URI.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.io.File</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/tools/ant/launch/Locator.html#getClassSource(java.lang.Class)">getClassSource</a></strong>(java.lang.Class c)</code>
<div class="block">Find the directory or jar file the class has been loaded from.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.net.URL[]</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/tools/ant/launch/Locator.html#getLocationURLs(java.io.File)">getLocationURLs</a></strong>(java.io.File location)</code>
<div class="block">Get an array of URLs representing all of the jar files in the
given location.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.net.URL[]</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/tools/ant/launch/Locator.html#getLocationURLs(java.io.File, java.lang.String[])">getLocationURLs</a></strong>(java.io.File location,
java.lang.String[] extensions)</code>
<div class="block">Get an array of URLs representing all of the files of a given set of
extensions in the given location.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static java.io.File</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/tools/ant/launch/Locator.html#getResourceSource(java.lang.ClassLoader, java.lang.String)">getResourceSource</a></strong>(java.lang.ClassLoader c,
java.lang.String resource)</code>
<div class="block">Find the directory or jar a given resource has been loaded from.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static java.io.File</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/tools/ant/launch/Locator.html#getToolsJar()">getToolsJar</a></strong>()</code>
<div class="block">Get the File necessary to load the Sun compiler tools.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class java.lang.Object</h3>
<code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ FIELD DETAIL =========== -->
<ul class="blockList">
<li class="blockList"><a name="field_detail">
<!-- -->
</a>
<h3>Field Detail</h3>
<a name="URI_ENCODING">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>URI_ENCODING</h4>
<pre>public static final java.lang.String URI_ENCODING</pre>
<div class="block">encoding used to represent URIs</div>
<dl><dt><span class="strong">See Also:</span></dt><dd><a href="../../../../../constant-values.html#org.apache.tools.ant.launch.Locator.URI_ENCODING">Constant Field Values</a></dd></dl>
</li>
</ul>
<a name="ERROR_NOT_FILE_URI">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>ERROR_NOT_FILE_URI</h4>
<pre>public static final java.lang.String ERROR_NOT_FILE_URI</pre>
<div class="block">Error string used when an invalid uri is seen</div>
<dl><dt><span class="strong">See Also:</span></dt><dd><a href="../../../../../constant-values.html#org.apache.tools.ant.launch.Locator.ERROR_NOT_FILE_URI">Constant Field Values</a></dd></dl>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="getClassSource(java.lang.Class)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getClassSource</h4>
<pre>public static java.io.File getClassSource(java.lang.Class c)</pre>
<div class="block">Find the directory or jar file the class has been loaded from.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>c</code> - the class whose location is required.</dd>
<dt><span class="strong">Returns:</span></dt><dd>the file or jar with the class or null if we cannot
determine the location.</dd><dt><span class="strong">Since:</span></dt>
<dd>Ant 1.6</dd></dl>
</li>
</ul>
<a name="getResourceSource(java.lang.ClassLoader, java.lang.String)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getResourceSource</h4>
<pre>public static java.io.File getResourceSource(java.lang.ClassLoader c,
java.lang.String resource)</pre>
<div class="block">Find the directory or jar a given resource has been loaded from.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>c</code> - the classloader to be consulted for the source.</dd><dd><code>resource</code> - the resource whose location is required.</dd>
<dt><span class="strong">Returns:</span></dt><dd>the file with the resource source or null if
we cannot determine the location.</dd><dt><span class="strong">Since:</span></dt>
<dd>Ant 1.6</dd></dl>
</li>
</ul>
<a name="fromURI(java.lang.String)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>fromURI</h4>
<pre>public static java.lang.String fromURI(java.lang.String uri)</pre>
<div class="block">Constructs a file path from a <code>file:</code> URI.
<p>Will be an absolute path if the given URI is absolute.</p>
<p>Prior to Java 1.4,<!-- XXX is JDK version actually relevant? -->
swallows '%' that are not followed by two characters.</p>
See <a href="http://www.w3.org/TR/xml11/#dt-sysid">dt-sysid</a>
which makes some mention of how
characters not supported by URI Reference syntax should be escaped.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>uri</code> - the URI designating a file in the local filesystem.</dd>
<dt><span class="strong">Returns:</span></dt><dd>the local file system path for the file.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if the URI is malformed or not a legal file: URL</dd><dt><span class="strong">Since:</span></dt>
<dd>Ant 1.6</dd></dl>
</li>
</ul>
<a name="fromJarURI(java.lang.String)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>fromJarURI</h4>
<pre>public static java.lang.String fromJarURI(java.lang.String uri)</pre>
<div class="block">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.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>uri</code> - uri to expand; contains jar: somewhere in it</dd>
<dt><span class="strong">Returns:</span></dt><dd>the decoded URI</dd><dt><span class="strong">Since:</span></dt>
<dd>Ant1.7.1</dd></dl>
</li>
</ul>
<a name="decodeUri(java.lang.String)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>decodeUri</h4>
<pre>public static java.lang.String decodeUri(java.lang.String uri)
throws java.io.UnsupportedEncodingException</pre>
<div class="block">Decodes an Uri with % characters.
The URI is escaped</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>uri</code> - String with the uri possibly containing % characters.</dd>
<dt><span class="strong">Returns:</span></dt><dd>The decoded Uri</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.io.UnsupportedEncodingException</code> - if UTF-8 is not available</dd><dt><span class="strong">Since:</span></dt>
<dd>Ant 1.7</dd></dl>
</li>
</ul>
<a name="encodeURI(java.lang.String)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>encodeURI</h4>
<pre>public static java.lang.String encodeURI(java.lang.String path)
throws java.io.UnsupportedEncodingException</pre>
<div class="block">Encodes an Uri with % characters.
The URI is escaped</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>path</code> - String to encode.</dd>
<dt><span class="strong">Returns:</span></dt><dd>The encoded string, according to URI norms</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.io.UnsupportedEncodingException</code> - if UTF-8 is not available</dd><dt><span class="strong">Since:</span></dt>
<dd>Ant 1.7</dd></dl>
</li>
</ul>
<a name="fileToURL(java.io.File)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>fileToURL</h4>
<pre>public static java.net.URL fileToURL(java.io.File file)
throws java.net.MalformedURLException</pre>
<div class="block">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) <!-- XXX no longer true -->
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</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>file</code> - the file to convert</dd>
<dt><span class="strong">Returns:</span></dt><dd>URL the converted File</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.net.MalformedURLException</code> - on error</dd></dl>
</li>
</ul>
<a name="getToolsJar()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getToolsJar</h4>
<pre>public static java.io.File getToolsJar()</pre>
<div class="block">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.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>the tools jar as a File if required, null otherwise.</dd></dl>
</li>
</ul>
<a name="getLocationURLs(java.io.File)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getLocationURLs</h4>
<pre>public static java.net.URL[] getLocationURLs(java.io.File location)
throws java.net.MalformedURLException</pre>
<div class="block">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.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>location</code> - the location to scan for Jars.</dd>
<dt><span class="strong">Returns:</span></dt><dd>an array of URLs for all jars in the given location.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.net.MalformedURLException</code> - if the URLs for the jars cannot be
formed.</dd></dl>
</li>
</ul>
<a name="getLocationURLs(java.io.File, java.lang.String[])">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>getLocationURLs</h4>
<pre>public static java.net.URL[] getLocationURLs(java.io.File location,
java.lang.String[] extensions)
throws java.net.MalformedURLException</pre>
<div class="block">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.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>location</code> - the location to scan for files.</dd><dd><code>extensions</code> - an array of extension that are to match in the
directory search.</dd>
<dt><span class="strong">Returns:</span></dt><dd>an array of URLs of matching files.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code>java.net.MalformedURLException</code> - if the URLs for the files cannot be
formed.</dd></dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/tools/ant/launch/LaunchException.html" title="class in org.apache.tools.ant.launch"><span class="strong">Prev Class</span></a></li>
<li>Next Class</li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/tools/ant/launch/Locator.html" target="_top">Frames</a></li>
<li><a href="Locator.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Nested | </li>
<li><a href="#field_summary">Field</a> | </li>
<li>Constr | </li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li><a href="#field_detail">Field</a> | </li>
<li>Constr | </li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>