git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@471560 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -240,8 +240,6 @@ public class ClasspathUtils { | |||
| return newInstance(className, userDefinedLoader, Object.class); | |||
| } | |||
| /** | |||
| * Creates a fresh object instance of the specified classname. | |||
| * | |||
| @@ -253,7 +251,7 @@ public class ClasspathUtils { | |||
| * @param userDefinedLoader the classloader to use. | |||
| * @param expectedType the Class that the result should be assignment | |||
| * compatible with. (No ClassCastException will be thrown in case | |||
| * the result of this method is casted to the expectedType) | |||
| * the result of this method is casted to the expectedType) | |||
| * @return The fresh object instance | |||
| * @throws BuildException when loading or instantiation failed. | |||
| * @since Ant 1.7 | |||
| @@ -263,14 +261,14 @@ public class ClasspathUtils { | |||
| ClassLoader userDefinedLoader, | |||
| Class expectedType) { | |||
| try { | |||
| Class clazz = Class.forName(className, true, userDefinedLoader); | |||
| Class clazz = Class.forName(className, true, userDefinedLoader); | |||
| Object o = clazz.newInstance(); | |||
| if (!expectedType.isInstance(o)) | |||
| { | |||
| throw new BuildException( | |||
| "Class of unexpected Type: " | |||
| "Class of unexpected Type: " | |||
| + className | |||
| + " expected :" | |||
| + " expected :" | |||
| + expectedType); | |||
| } | |||
| return o; | |||
| @@ -297,11 +295,11 @@ public class ClasspathUtils { | |||
| throw new BuildException( | |||
| "Class " | |||
| + className | |||
| + " could not be loaded because of an invalid dependency.", | |||
| + " could not be loaded because of an invalid dependency.", | |||
| e); | |||
| } | |||
| } | |||
| /** | |||
| * Obtains a delegate that helps out with classic classpath configuration. | |||
| * | |||
| @@ -47,7 +47,7 @@ public class DOMElementWriter { | |||
| private static final String NS = "ns"; | |||
| /** xml declaration is on by default */ | |||
| private boolean xmlDeclaration=true; | |||
| private boolean xmlDeclaration = true; | |||
| /** | |||
| * XML Namespaces are ignored by default. | |||
| @@ -115,7 +115,7 @@ public class DOMElementWriter { | |||
| } | |||
| /** | |||
| * Create an element writer | |||
| * Create an element writer | |||
| * XML namespaces will be ignored. | |||
| * @param xmlDeclaration flag to indicate whether the ?xml? declaration | |||
| * should be included. | |||
| @@ -126,7 +126,7 @@ public class DOMElementWriter { | |||
| } | |||
| /** | |||
| * Create an element writer | |||
| * Create an element writer | |||
| * XML namespaces will be ignored. | |||
| * @param xmlDeclaration flag to indicate whether the ?xml? declaration | |||
| * should be included. | |||
| @@ -196,9 +196,9 @@ public class DOMElementWriter { | |||
| if (hasChildren) { | |||
| for (int i = 0; i < children.getLength(); i++) { | |||
| Node child = children.item(i); | |||
| switch (child.getNodeType()) { | |||
| case Node.ELEMENT_NODE: | |||
| hasChildElements = true; | |||
| if (i == 0) { | |||
| @@ -206,29 +206,29 @@ public class DOMElementWriter { | |||
| } | |||
| write((Element) child, out, indent + 1, indentWith); | |||
| break; | |||
| case Node.TEXT_NODE: | |||
| out.write(encode(child.getNodeValue())); | |||
| break; | |||
| case Node.COMMENT_NODE: | |||
| out.write("<!--"); | |||
| out.write(encode(child.getNodeValue())); | |||
| out.write("-->"); | |||
| break; | |||
| case Node.CDATA_SECTION_NODE: | |||
| out.write("<![CDATA["); | |||
| out.write(encodedata(((Text) child).getData())); | |||
| out.write("]]>"); | |||
| break; | |||
| case Node.ENTITY_REFERENCE_NODE: | |||
| out.write('&'); | |||
| out.write(child.getNodeName()); | |||
| out.write(';'); | |||
| break; | |||
| case Node.PROCESSING_INSTRUCTION_NODE: | |||
| out.write("<?"); | |||
| out.write(child.getNodeName()); | |||
| @@ -32,7 +32,7 @@ public class DeweyDecimal { | |||
| /** Array of components that make up DeweyDecimal */ | |||
| private int[] components; | |||
| /** | |||
| * Construct a DeweyDecimal from an array of integer components. | |||
| * | |||
| @@ -1455,7 +1455,7 @@ public class FileUtils { | |||
| Object[] tokens = StringUtils.split(normalizedPath, '/').toArray(); | |||
| String[] rv = new String[tokens.length]; | |||
| System.arraycopy(tokens, 0, rv, 0, tokens.length); | |||
| return rv; | |||
| } | |||
| @@ -132,7 +132,7 @@ public final class JavaEnvUtils { | |||
| /** | |||
| * Returns the version of Java this class is running under. | |||
| * This number can be used for comparisions; it will always be | |||
| * This number can be used for comparisions; it will always be | |||
| * @return the version of Java as a number 10x the major/minor, | |||
| * e.g Java1.5 has a value of 15 | |||
| */ | |||
| @@ -292,11 +292,11 @@ public final class JavaEnvUtils { | |||
| switch(javaVersionNumber) { | |||
| case 16: | |||
| case 15: | |||
| //In Java1.5, the apache stuff moved. | |||
| //In Java1.5, the apache stuff moved. | |||
| jrePackages.addElement("com.sun.org.apache"); | |||
| //fall through. | |||
| //fall through. | |||
| case 14: | |||
| if(javaVersionNumber == 14) { | |||
| if (javaVersionNumber == 14) { | |||
| jrePackages.addElement("org.apache.crimson"); | |||
| jrePackages.addElement("org.apache.xalan"); | |||
| jrePackages.addElement("org.apache.xml"); | |||
| @@ -345,7 +345,7 @@ public final class JavaEnvUtils { | |||
| tests.addElement("com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl "); | |||
| case 14: | |||
| tests.addElement("sun.audio.AudioPlayer"); | |||
| if(javaVersionNumber == 14) { | |||
| if (javaVersionNumber == 14) { | |||
| tests.addElement("org.apache.crimson.parser.ContentModel"); | |||
| tests.addElement("org.apache.xalan.processor.ProcessorImport"); | |||
| tests.addElement("org.apache.xml.utils.URI"); | |||
| @@ -106,7 +106,7 @@ public class LeadPipeInputStream extends PipedInputStream { | |||
| int outlen = buffer.length - out; | |||
| System.arraycopy(buffer, out, newBuffer, 0, outlen); | |||
| System.arraycopy(buffer, 0, newBuffer, outlen, in); | |||
| in+= outlen; | |||
| in += outlen; | |||
| out = 0; | |||
| } | |||
| } | |||
| @@ -37,7 +37,7 @@ public class ProxySetup { | |||
| * Java1.5 property that enables use of system proxies. | |||
| * @value | |||
| */ | |||
| public static final String USE_SYSTEM_PROXIES="java.net.useSystemProxies"; | |||
| public static final String USE_SYSTEM_PROXIES = "java.net.useSystemProxies"; | |||
| public static final String HTTP_PROXY_HOST = "http.proxyHost"; | |||
| public static final String HTTP_PROXY_PORT = "http.proxyPort"; | |||
| public static final String HTTPS_PROXY_HOST = "https.proxyHost"; | |||
| @@ -83,19 +83,19 @@ public class ProxySetup { | |||
| * is set, use that instead. Else set to "true". | |||
| */ | |||
| public void enableProxies() { | |||
| if(!(getSystemProxySetting() != null)) { | |||
| String proxies =owner.getProperty(USE_SYSTEM_PROXIES); | |||
| if(proxies ==null || Project.toBoolean(proxies)) { | |||
| proxies ="true"; | |||
| if (!(getSystemProxySetting() != null)) { | |||
| String proxies = owner.getProperty(USE_SYSTEM_PROXIES); | |||
| if (proxies == null || Project.toBoolean(proxies)) { | |||
| proxies = "true"; | |||
| } | |||
| String message = "setting " + USE_SYSTEM_PROXIES + " to " + proxies; | |||
| try { | |||
| owner.log(message,Project.MSG_DEBUG); | |||
| System.setProperty(USE_SYSTEM_PROXIES,proxies); | |||
| owner.log(message, Project.MSG_DEBUG); | |||
| System.setProperty(USE_SYSTEM_PROXIES, proxies); | |||
| } catch (SecurityException e) { | |||
| //log security exceptions and continue; it aint that | |||
| //important and may be quite common running Ant embedded. | |||
| owner.log("Security Exception when "+message); | |||
| owner.log("Security Exception when " + message); | |||
| } | |||
| } | |||
| } | |||
| @@ -23,8 +23,8 @@ import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.Task; | |||
| /** | |||
| * A simple utility class to take a piece of code (that implements | |||
| * <code>Retryable</code> interface) and executes that with possibility to | |||
| * A simple utility class to take a piece of code (that implements | |||
| * <code>Retryable</code> interface) and executes that with possibility to | |||
| * retry the execution in case of IOException. | |||
| */ | |||
| public class RetryHandler { | |||
| @@ -34,7 +34,7 @@ public class RetryHandler { | |||
| /** | |||
| * Create a new RetryingHandler. | |||
| * | |||
| * | |||
| * @param retriesAllowed how many times to retry | |||
| * @param task the Ant task that is is executed from, used for logging only | |||
| */ | |||
| @@ -45,7 +45,7 @@ public class RetryHandler { | |||
| /** | |||
| * Execute the <code>Retryable</code> code with specified number of retries. | |||
| * | |||
| * | |||
| * @param exe the code to execute | |||
| * @param desc some descriptive text for this piece of code, used for logging | |||
| * @throws IOException if the number of retries has exceeded the allowed limit | |||
| @@ -59,8 +59,8 @@ public class RetryHandler { | |||
| } catch (IOException e) { | |||
| retries++; | |||
| if (retries > this.retriesAllowed && this.retriesAllowed > -1) { | |||
| task.log("try #" + retries + ": IO error (" | |||
| + desc + "), number of maximum retries reached (" | |||
| task.log("try #" + retries + ": IO error (" | |||
| + desc + "), number of maximum retries reached (" | |||
| + this.retriesAllowed + "), giving up", Project.MSG_WARN); | |||
| throw e; | |||
| } else { | |||
| @@ -21,13 +21,13 @@ import java.io.IOException; | |||
| /** | |||
| * Simple interface for executing a piece of code. Used for writing anonymous inner | |||
| * Simple interface for executing a piece of code. Used for writing anonymous inner | |||
| * classes in FTP task for retry-on-IOException behaviour. | |||
| * | |||
| * | |||
| * @see RetryHandler | |||
| */ | |||
| public interface Retryable { | |||
| public static final int RETRY_FOREVER = -1; | |||
| void execute() throws IOException; | |||
| } | |||
| } | |||
| @@ -19,9 +19,9 @@ package org.apache.tools.ant.util; | |||
| /** | |||
| * This class is here for backwards compatiblity. | |||
| * @deprecated Implementation moved to another location. Use | |||
| * @deprecated Implementation moved to another location. Use | |||
| * that org.apache.tools.ant.types.optional.ScriptRunner instead. | |||
| */ | |||
| public class ScriptRunner | |||
| extends org.apache.tools.ant.util.optional.ScriptRunner { | |||
| } | |||
| } | |||
| @@ -115,14 +115,17 @@ public final class StringUtils { | |||
| if (suffix.length() > buffer.length()) { | |||
| return false; | |||
| } | |||
| // this loop is done on purpose to avoid memory allocation performance problems on various JDKs | |||
| // StringBuffer.lastIndexOf() was introduced in jdk 1.4 and implementation is ok though does allocation/copying | |||
| // StringBuffer.toString().endsWith() does massive memory allocation/copying on JDK 1.5 | |||
| // this loop is done on purpose to avoid memory allocation performance | |||
| // problems on various JDKs | |||
| // StringBuffer.lastIndexOf() was introduced in jdk 1.4 and | |||
| // implementation is ok though does allocation/copying | |||
| // StringBuffer.toString().endsWith() does massive memory | |||
| // allocation/copying on JDK 1.5 | |||
| // See http://issues.apache.org/bugzilla/show_bug.cgi?id=37169 | |||
| int endIndex = suffix.length() - 1; | |||
| int bufferIndex = buffer.length() - 1; | |||
| while ( endIndex >= 0 ) { | |||
| if ( buffer.charAt(bufferIndex) != suffix.charAt(endIndex) ) { | |||
| while (endIndex >= 0) { | |||
| if (buffer.charAt(bufferIndex) != suffix.charAt(endIndex)) { | |||
| return false; | |||
| } | |||
| bufferIndex--; | |||
| @@ -107,7 +107,7 @@ public class UUEncoder { | |||
| byte[] data, int offset, int length, OutputStream out) | |||
| throws IOException { | |||
| // write out the number of characters encoded in this line. | |||
| out.write((byte)((length & 0x3F) + ' ')); | |||
| out.write((byte) ((length & 0x3F) + ' ')); | |||
| byte a; | |||
| byte b; | |||
| byte c; | |||
| @@ -125,10 +125,10 @@ public class UUEncoder { | |||
| } | |||
| } | |||
| byte d1 = (byte)(((a >>> 2) & 0x3F) + ' '); | |||
| byte d2 = (byte)(((( a << 4) & 0x30) | ((b >>> 4) & 0x0F)) + ' '); | |||
| byte d3 = (byte)((((b << 2) & 0x3C) | ((c >>> 6) & 0x3)) + ' '); | |||
| byte d4 = (byte)((c & 0x3F) + ' '); | |||
| byte d1 = (byte) (((a >>> 2) & 0x3F) + ' '); | |||
| byte d2 = (byte) ((((a << 4) & 0x30) | ((b >>> 4) & 0x0F)) + ' '); | |||
| byte d3 = (byte) ((((b << 2) & 0x3C) | ((c >>> 6) & 0x3)) + ' '); | |||
| byte d4 = (byte) ((c & 0x3F) + ' '); | |||
| out.write(d1); | |||
| out.write(d2); | |||
| @@ -71,7 +71,7 @@ public class WeakishReference { | |||
| /** | |||
| * This was a hard reference for Java 1.1. Since Ant1.7, | |||
| * @deprecated since 1.7. | |||
| * @deprecated since 1.7. | |||
| * Hopefully nobody is using this. | |||
| */ | |||
| public static class HardReference extends WeakishReference { | |||
| @@ -87,7 +87,7 @@ public class XMLFragment extends ProjectComponent implements DynamicElementNS { | |||
| } | |||
| /** | |||
| * Add text to a node. | |||
| * Add text to a node. | |||
| * @param n node | |||
| * @param s value | |||
| */ | |||
| @@ -41,7 +41,7 @@ public class XmlConstants { | |||
| "http://java.sun.com/xml/jaxp/properties/schemaSource"; | |||
| public static final String URI_XSD = | |||
| "http://www.w3.org/2001/XMLSchema"; | |||
| public static final String FEATURE_EXTERNAL_ENTITIES = | |||
| public static final String FEATURE_EXTERNAL_ENTITIES = | |||
| "http://xml.org/sax/features/external-general-entities"; | |||
| public static final String FEATURE_DISALLOW_DTD = | |||
| "http://apache.org/xml/features/disallow-doctype-decl"; | |||
| @@ -14,7 +14,7 @@ | |||
| * See the License for the specific language governing permissions and | |||
| * limitations under the License. | |||
| * | |||
| */ | |||
| */ | |||
| package org.apache.tools.ant.util.java15; | |||
| @@ -55,14 +55,14 @@ public class ProxyDiagnostics { | |||
| public ProxyDiagnostics(String destination) { | |||
| this.destination = destination; | |||
| try { | |||
| this.destURI=new URI(destination); | |||
| this.destURI = new URI(destination); | |||
| } catch (URISyntaxException e) { | |||
| throw new BuildException(e); | |||
| } | |||
| } | |||
| /** | |||
| * create a proxy diagnostics tool bound to | |||
| * create a proxy diagnostics tool bound to | |||
| * {@link #DEFAULT_DESTINATION} | |||
| */ | |||
| public ProxyDiagnostics() { | |||
| @@ -70,24 +70,24 @@ public class ProxyDiagnostics { | |||
| } | |||
| public String toString() { | |||
| ProxySelector selector=ProxySelector.getDefault(); | |||
| ProxySelector selector = ProxySelector.getDefault(); | |||
| List list = selector.select(destURI); | |||
| StringBuffer result=new StringBuffer(); | |||
| Iterator proxies=list.listIterator(); | |||
| StringBuffer result = new StringBuffer(); | |||
| Iterator proxies = list.listIterator(); | |||
| while (proxies.hasNext()) { | |||
| Proxy proxy = (Proxy) proxies.next(); | |||
| SocketAddress address = proxy.address(); | |||
| if(address==null) { | |||
| if (address == null) { | |||
| result.append("Direct connection\n"); | |||
| } else { | |||
| result.append(proxy.toString()); | |||
| if(address instanceof InetSocketAddress) { | |||
| InetSocketAddress ina=(InetSocketAddress) address; | |||
| if (address instanceof InetSocketAddress) { | |||
| InetSocketAddress ina = (InetSocketAddress) address; | |||
| result.append(' '); | |||
| result.append(ina.getHostName()); | |||
| result.append(':'); | |||
| result.append(ina.getPort()); | |||
| if(ina.isUnresolved()) { | |||
| if (ina.isUnresolved()) { | |||
| result.append(" [unresolved]"); | |||
| } else { | |||
| InetAddress addr = ina.getAddress(); | |||
| @@ -98,7 +98,6 @@ public class ProxyDiagnostics { | |||
| } | |||
| result.append('\n'); | |||
| } | |||
| } | |||
| return result.toString(); | |||
| } | |||
| @@ -191,7 +191,7 @@ public class ScriptRunner { | |||
| public void setClasspath(Path classpath) { | |||
| this.classpath = classpath; | |||
| } | |||
| /** | |||
| * Load the script from an external file ; optional. | |||
| * | |||
| @@ -30,7 +30,7 @@ import java.lang.ref.WeakReference; | |||
| * Note that in ant1.7 is parent was changed to extend HardReference. | |||
| * This is because the latter has access to the (package scoped) | |||
| * WeakishReference(Object) constructor, and both that and this are thin | |||
| * facades on the underlying no-longer-abstract base class. | |||
| * facades on the underlying no-longer-abstract base class. | |||
| */ | |||
| public class WeakishReference12 extends WeakishReference.HardReference { | |||
| @@ -114,8 +114,7 @@ public class RegexpMatcherFactory { | |||
| * @exception BuildException if an error occurs | |||
| */ | |||
| protected RegexpMatcher createInstance(String className) | |||
| throws BuildException | |||
| { | |||
| throws BuildException { | |||
| return (RegexpMatcher) ClasspathUtils.newInstance(className, | |||
| RegexpMatcherFactory.class.getClassLoader(), RegexpMatcher.class); | |||
| } | |||