From e6e70c16c1e7a5ffdcacc8b1830bc73d7b8497d6 Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Sun, 5 Nov 2006 23:00:20 +0000 Subject: [PATCH] checkstyle git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@471560 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/util/ClasspathUtils.java | 14 ++++++------- .../tools/ant/util/DOMElementWriter.java | 20 +++++++++--------- .../apache/tools/ant/util/DeweyDecimal.java | 2 +- .../org/apache/tools/ant/util/FileUtils.java | 2 +- .../apache/tools/ant/util/JavaEnvUtils.java | 10 ++++----- .../tools/ant/util/LeadPipeInputStream.java | 2 +- .../org/apache/tools/ant/util/ProxySetup.java | 16 +++++++------- .../apache/tools/ant/util/RetryHandler.java | 12 +++++------ .../org/apache/tools/ant/util/Retryable.java | 6 +++--- .../apache/tools/ant/util/ScriptRunner.java | 4 ++-- .../apache/tools/ant/util/StringUtils.java | 13 +++++++----- .../org/apache/tools/ant/util/UUEncoder.java | 10 ++++----- .../tools/ant/util/WeakishReference.java | 2 +- .../apache/tools/ant/util/XMLFragment.java | 2 +- .../apache/tools/ant/util/XmlConstants.java | 2 +- .../ant/util/java15/ProxyDiagnostics.java | 21 +++++++++---------- .../tools/ant/util/optional/ScriptRunner.java | 2 +- .../ant/util/optional/WeakishReference12.java | 2 +- .../ant/util/regexp/RegexpMatcherFactory.java | 3 +-- 19 files changed, 72 insertions(+), 73 deletions(-) diff --git a/src/main/org/apache/tools/ant/util/ClasspathUtils.java b/src/main/org/apache/tools/ant/util/ClasspathUtils.java index 794305f27..20785cd35 100644 --- a/src/main/org/apache/tools/ant/util/ClasspathUtils.java +++ b/src/main/org/apache/tools/ant/util/ClasspathUtils.java @@ -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. * diff --git a/src/main/org/apache/tools/ant/util/DOMElementWriter.java b/src/main/org/apache/tools/ant/util/DOMElementWriter.java index 7ce9919d1..b5125d2ec 100644 --- a/src/main/org/apache/tools/ant/util/DOMElementWriter.java +++ b/src/main/org/apache/tools/ant/util/DOMElementWriter.java @@ -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(""); break; - + case Node.CDATA_SECTION_NODE: out.write(""); break; - + case Node.ENTITY_REFERENCE_NODE: out.write('&'); out.write(child.getNodeName()); out.write(';'); break; - + case Node.PROCESSING_INSTRUCTION_NODE: out.write("Retryable interface) and executes that with possibility to + * A simple utility class to take a piece of code (that implements + * Retryable 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 Retryable 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 { diff --git a/src/main/org/apache/tools/ant/util/Retryable.java b/src/main/org/apache/tools/ant/util/Retryable.java index 08fff5dd4..8f400af93 100644 --- a/src/main/org/apache/tools/ant/util/Retryable.java +++ b/src/main/org/apache/tools/ant/util/Retryable.java @@ -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; -} \ No newline at end of file +} diff --git a/src/main/org/apache/tools/ant/util/ScriptRunner.java b/src/main/org/apache/tools/ant/util/ScriptRunner.java index 18e86dd03..1bc2adc2b 100644 --- a/src/main/org/apache/tools/ant/util/ScriptRunner.java +++ b/src/main/org/apache/tools/ant/util/ScriptRunner.java @@ -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 { -} \ No newline at end of file +} diff --git a/src/main/org/apache/tools/ant/util/StringUtils.java b/src/main/org/apache/tools/ant/util/StringUtils.java index 4829d0471..f5408ca2a 100644 --- a/src/main/org/apache/tools/ant/util/StringUtils.java +++ b/src/main/org/apache/tools/ant/util/StringUtils.java @@ -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--; diff --git a/src/main/org/apache/tools/ant/util/UUEncoder.java b/src/main/org/apache/tools/ant/util/UUEncoder.java index 29a1e536e..8b8e144e9 100644 --- a/src/main/org/apache/tools/ant/util/UUEncoder.java +++ b/src/main/org/apache/tools/ant/util/UUEncoder.java @@ -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); diff --git a/src/main/org/apache/tools/ant/util/WeakishReference.java b/src/main/org/apache/tools/ant/util/WeakishReference.java index b61c5f592..d4deeec07 100644 --- a/src/main/org/apache/tools/ant/util/WeakishReference.java +++ b/src/main/org/apache/tools/ant/util/WeakishReference.java @@ -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 { diff --git a/src/main/org/apache/tools/ant/util/XMLFragment.java b/src/main/org/apache/tools/ant/util/XMLFragment.java index 49d51a9d2..1f21a3a69 100644 --- a/src/main/org/apache/tools/ant/util/XMLFragment.java +++ b/src/main/org/apache/tools/ant/util/XMLFragment.java @@ -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 */ diff --git a/src/main/org/apache/tools/ant/util/XmlConstants.java b/src/main/org/apache/tools/ant/util/XmlConstants.java index 7a3c629f8..03d0a2484 100644 --- a/src/main/org/apache/tools/ant/util/XmlConstants.java +++ b/src/main/org/apache/tools/ant/util/XmlConstants.java @@ -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"; diff --git a/src/main/org/apache/tools/ant/util/java15/ProxyDiagnostics.java b/src/main/org/apache/tools/ant/util/java15/ProxyDiagnostics.java index c4afea650..d10990efd 100644 --- a/src/main/org/apache/tools/ant/util/java15/ProxyDiagnostics.java +++ b/src/main/org/apache/tools/ant/util/java15/ProxyDiagnostics.java @@ -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(); } diff --git a/src/main/org/apache/tools/ant/util/optional/ScriptRunner.java b/src/main/org/apache/tools/ant/util/optional/ScriptRunner.java index 0bae5bbb3..65de020d7 100644 --- a/src/main/org/apache/tools/ant/util/optional/ScriptRunner.java +++ b/src/main/org/apache/tools/ant/util/optional/ScriptRunner.java @@ -191,7 +191,7 @@ public class ScriptRunner { public void setClasspath(Path classpath) { this.classpath = classpath; } - + /** * Load the script from an external file ; optional. * diff --git a/src/main/org/apache/tools/ant/util/optional/WeakishReference12.java b/src/main/org/apache/tools/ant/util/optional/WeakishReference12.java index bd923de30..0bd0aabdf 100644 --- a/src/main/org/apache/tools/ant/util/optional/WeakishReference12.java +++ b/src/main/org/apache/tools/ant/util/optional/WeakishReference12.java @@ -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 { diff --git a/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java b/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java index dc166e4bf..8fcc96f48 100644 --- a/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java +++ b/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java @@ -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); }