- reduced LOC
- name hiding
- some JavaDoc spelling fixes
- use of StringUtils.LINE_SEP
- List not ArrayList for methods (use interface not concrete class suggestion from PMD)


Kev
Index: Extension.java
===================================================================
RCS file: 
/home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/Extension.java,v
retrieving revision 1.14
diff -u -r1.14 Extension.java
--- Extension.java      12 Nov 2004 11:07:12 -0000      1.14
+++ Extension.java      24 Feb 2005 15:48:13 -0000
@@ -23,6 +23,8 @@
 import java.util.jar.Attributes;
 import java.util.jar.Manifest;
 
+import org.apache.tools.ant.util.StringUtils;
+
 /**
  * <p>Utility class that represents either an available "Optional Package"
  * (formerly known as "Standard Extension") as described in the manifest
@@ -489,54 +491,53 @@
      * @return string representation of object.
      */
     public String toString() {
-        final String lineSeparator = System.getProperty("line.separator");
         final String brace = ": ";
 
         final StringBuffer sb = new StringBuffer(EXTENSION_NAME.toString());
         sb.append(brace);
         sb.append(extensionName);
-        sb.append(lineSeparator);
+        sb.append(StringUtils.LINE_SEP);
 
         if (null != specificationVersion) {
             sb.append(SPECIFICATION_VERSION);
             sb.append(brace);
             sb.append(specificationVersion);
-            sb.append(lineSeparator);
+            sb.append(StringUtils.LINE_SEP);
         }
 
         if (null != specificationVendor) {
             sb.append(SPECIFICATION_VENDOR);
             sb.append(brace);
             sb.append(specificationVendor);
-            sb.append(lineSeparator);
+            sb.append(StringUtils.LINE_SEP);
         }
 
         if (null != implementationVersion) {
             sb.append(IMPLEMENTATION_VERSION);
             sb.append(brace);
             sb.append(implementationVersion);
-            sb.append(lineSeparator);
+            sb.append(StringUtils.LINE_SEP);
         }
 
         if (null != implementationVendorID) {
             sb.append(IMPLEMENTATION_VENDOR_ID);
             sb.append(brace);
             sb.append(implementationVendorID);
-            sb.append(lineSeparator);
+            sb.append(StringUtils.LINE_SEP);
         }
 
         if (null != implementationVendor) {
             sb.append(IMPLEMENTATION_VENDOR);
             sb.append(brace);
             sb.append(implementationVendor);
-            sb.append(lineSeparator);
+            sb.append(StringUtils.LINE_SEP);
         }
 
         if (null != implementationURL) {
             sb.append(IMPLEMENTATION_URL);
             sb.append(brace);
             sb.append(implementationURL);
-            sb.append(lineSeparator);
+            sb.append(StringUtils.LINE_SEP);
         }
 
         return sb.toString();
@@ -685,8 +686,7 @@
     private static String getTrimmedString(final String value) {
         if (null == value) {
             return null;
-        } else {
-            return value.trim();
-        }
+        } 
+        return value.trim();
     }
-}
+}
\ No newline at end of file
Index: ExtensionSet.java
===================================================================
RCS file: 
/home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionSet.java,v
retrieving revision 1.8
diff -u -r1.8 ExtensionSet.java
--- ExtensionSet.java   9 Mar 2004 16:48:24 -0000       1.8
+++ ExtensionSet.java   24 Feb 2005 15:48:13 -0000
@@ -73,14 +73,14 @@
     /**
      * Extract a set of Extension objects from the ExtensionSet.
      *
-     * @param project the project instance.
+     * @param proj the project instance.
      * @return an array containing the Extensions from this set
      * @throws BuildException if an error occurs
      */
-    public Extension[] toExtensions(final Project project)
+    public Extension[] toExtensions(final Project proj)
         throws BuildException {
         final ArrayList extensionsList = 
ExtensionUtil.toExtensions(extensions);
-        ExtensionUtil.extractExtensions(project, extensionsList, 
extensionsFilesets);
+        ExtensionUtil.extractExtensions(proj, extensionsList, 
extensionsFilesets);
         return (Extension[]) extensionsList.toArray(new 
Extension[extensionsList.size()]);
     }
 
Index: ExtensionUtil.java
===================================================================
RCS file: 
/home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionUtil.java,v
retrieving revision 1.11
diff -u -r1.11 ExtensionUtil.java
--- ExtensionUtil.java  9 Mar 2004 16:48:24 -0000       1.11
+++ ExtensionUtil.java  24 Feb 2005 15:48:14 -0000
@@ -20,8 +20,10 @@
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 import java.util.jar.JarFile;
 import java.util.jar.Manifest;
+
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.DirectoryScanner;
 import org.apache.tools.ant.Project;
@@ -37,6 +39,7 @@
      * Class is not meant to be instantiated.
      */
     private ExtensionUtil() {
+        //all methods static
     }
 
     /**
@@ -45,7 +48,7 @@
      * @param adapters the list of ExtensionAdapterss to add to convert
      * @throws BuildException if an error occurs
      */
-    static ArrayList toExtensions(final ArrayList adapters)
+    static ArrayList toExtensions(final List adapters)
         throws BuildException {
         final ArrayList results = new ArrayList();
 
@@ -63,35 +66,35 @@
     /**
      * Generate a list of extensions from a specified fileset.
      *
-     * @param librarys the list to add extensions to
+     * @param libraries the list to add extensions to
      * @param fileset the filesets containing librarys
      * @throws BuildException if an error occurs
      */
     static void extractExtensions(final Project project,
-                                   final ArrayList librarys,
-                                   final ArrayList fileset)
+                                   final List libraries,
+                                   final List fileset)
         throws BuildException {
         if (!fileset.isEmpty()) {
             final Extension[] extensions = getExtensions(project,
                                                           fileset);
             for (int i = 0; i < extensions.length; i++) {
-                librarys.add(extensions[ i ]);
+                libraries.add(extensions[ i ]);
             }
         }
     }
 
     /**
-     * Retrieve extensions from the specified librarys.
+     * Retrieve extensions from the specified libraries.
      *
-     * @param librarys the filesets for librarys
-     * @return the extensions contained in librarys
-     * @throws BuildException if failing to scan librarys
+     * @param libraries the filesets for libraries
+     * @return the extensions contained in libraries
+     * @throws BuildException if failing to scan libraries
      */
     private static Extension[] getExtensions(final Project project,
-                                              final ArrayList librarys)
+                                              final List libraries)
         throws BuildException {
         final ArrayList extensions = new ArrayList();
-        final Iterator iterator = librarys.iterator();
+        final Iterator iterator = libraries.iterator();
         while (iterator.hasNext()) {
             final FileSet fileSet = (FileSet) iterator.next();
 
@@ -123,7 +126,7 @@
      * @throws BuildException if there is an error
      */
     private static void loadExtensions(final File file,
-                                        final ArrayList extensionList,
+                                        final List extensionList,
                                         final boolean includeImpl,
                                         final boolean includeURL)
         throws BuildException {
@@ -151,7 +154,7 @@
      * @param includeImpl false to exclude implementation details
      * @param includeURL false to exclude implementation URL
      */
-    private static void addExtension(final ArrayList extensionList,
+    private static void addExtension(final List extensionList,
                                       final Extension originalExtension,
                                       final boolean includeImpl,
                                       final boolean includeURL) {
@@ -189,12 +192,12 @@
     }
 
     /**
-     * retrieve manifest for specified file.
+     * Retrieve manifest for specified file.
      *
      * @param file the file
      * @return the manifest
-     * @throws BuildException if errror occurs (file not exist,
-     *         file not a jar, manifest not exist in file)
+     * @throws BuildException if errror occurs (file doesn't exist,
+     *         file not a jar, manifest doesn't exist in file)
      */
     static Manifest getManifest(final File file)
         throws BuildException {
@@ -209,4 +212,4 @@
             throw new BuildException(ioe.getMessage(), ioe);
         }
     }
-}
+}
\ No newline at end of file
Index: JarLibManifestTask.java
===================================================================
RCS file: 
/home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibManifestTask.java,v
retrieving revision 1.10
diff -u -r1.10 JarLibManifestTask.java
--- JarLibManifestTask.java     15 Nov 2004 14:52:27 -0000      1.10
+++ JarLibManifestTask.java     24 Feb 2005 15:48:15 -0000
@@ -104,9 +104,8 @@
             final String message =
                 "Can not have multiple extensions defined in one library.";
             throw new BuildException(message);
-        } else {
-            extension = extensionAdapter.toExtension();
         }
+        extension = extensionAdapter.toExtension();
     }
 
     /**
@@ -254,8 +253,7 @@
                                     final String listPrefix,
                                     final ArrayList extensions)
         throws BuildException {
-        final int size = extensions.size();
-        for (int i = 0; i < size; i++) {
+        for (int i = 0, size = extensions.size(); i < size; i++) {
             final Extension ext = (Extension) extensions.get(i);
             final String prefix = listPrefix + i + "-";
             Extension.addExtension(ext, prefix, attributes);
@@ -297,9 +295,7 @@
     private ArrayList toExtensions(final ArrayList extensionSets)
         throws BuildException {
         final ArrayList results = new ArrayList();
-
-        final int size = extensionSets.size();
-        for (int i = 0; i < size; i++) {
+        for (int i = 0, size = extensionSets.size(); i < size; i++) {
             final ExtensionSet set = (ExtensionSet) extensionSets.get(i);
             final Extension[] extensions = set.toExtensions(getProject());
             for (int j = 0; j < extensions.length; j++) {
@@ -309,4 +305,4 @@
 
         return results;
     }
-}
+}
\ No newline at end of file
Index: JarLibResolveTask.java
===================================================================
RCS file: 
/home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/JarLibResolveTask.java,v
retrieving revision 1.11
diff -u -r1.11 JarLibResolveTask.java
--- JarLibResolveTask.java      9 Mar 2004 16:48:24 -0000       1.11
+++ JarLibResolveTask.java      24 Feb 2005 15:48:17 -0000
@@ -98,10 +98,10 @@
      * Adds location resolver to look for a library in a location
      * relative to project directory.
      *
-     * @param location the resolver location to search.
+     * @param loc the resolver location to search.
      */
-    public void addConfiguredLocation(final LocationResolver location) {
-        resolvers.add(location);
+    public void addConfiguredLocation(final LocationResolver loc) {
+        resolvers.add(loc);
     }
 
     /**
@@ -155,10 +155,9 @@
             final String message = "Property Already set to: " + candidate;
             if (failOnError) {
                 throw new BuildException(message);
-            } else {
-                getProject().log(message, Project.MSG_ERR);
-                return;
-            }
+            } 
+            getProject().log(message, Project.MSG_ERR);
+            return;
         }
 
         final int size = resolvers.size();
@@ -201,9 +200,8 @@
             "Unable to resolve extension to a file";
         if (failOnError) {
             throw new BuildException(message);
-        } else {
-            getProject().log(message, Project.MSG_ERR);
         }
+        getProject().log(message, Project.MSG_ERR);
     }
 
     /**
@@ -283,4 +281,4 @@
             throw new BuildException(message);
         }
     }
-}
+}
\ No newline at end of file
Index: Specification.java
===================================================================
RCS file: 
/home/cvspublic/ant/src/main/org/apache/tools/ant/taskdefs/optional/extension/Specification.java,v
retrieving revision 1.12
diff -u -r1.12 Specification.java
--- Specification.java  22 Nov 2004 09:23:33 -0000      1.12
+++ Specification.java  24 Feb 2005 15:48:19 -0000
@@ -24,6 +24,8 @@
 import java.util.jar.Attributes;
 import java.util.jar.Manifest;
 
+import org.apache.tools.ant.util.StringUtils;
+
 /**
  * <p>Utility class that represents either an available "Optional Package"
  * (formerly known as "Standard Extension") as described in the manifest
@@ -37,6 +39,9 @@
  * @version $Revision: 1.12 $ $Date: 2004/11/22 09:23:33 $
  */
 public final class Specification {
+    
+    private static final String MISSING = "Missing ";
+    
     /**
      * Manifest Attribute Name object for SPECIFICATION_TITLE.
      */
@@ -320,11 +325,10 @@
     public String[] getSections() {
         if (null == sections) {
             return null;
-        } else {
-            final String[] newSections = new String[ sections.length ];
-            System.arraycopy(sections, 0, newSections, 0, sections.length);
-            return newSections;
-        }
+        } 
+        final String[] newSections = new String[ sections.length ];
+        System.arraycopy(sections, 0, newSections, 0, sections.length);
+        return newSections;
     }
 
     /**
@@ -394,48 +398,47 @@
      * @return string representation of object.
      */
     public String toString() {
-        final String lineSeparator = System.getProperty("line.separator");
         final String brace = ": ";
 
         final StringBuffer sb
             = new StringBuffer(SPECIFICATION_TITLE.toString());
         sb.append(brace);
         sb.append(specificationTitle);
-        sb.append(lineSeparator);
+        sb.append(StringUtils.LINE_SEP);
 
         if (null != specificationVersion) {
             sb.append(SPECIFICATION_VERSION);
             sb.append(brace);
             sb.append(specificationVersion);
-            sb.append(lineSeparator);
+            sb.append(StringUtils.LINE_SEP);
         }
 
         if (null != specificationVendor) {
             sb.append(SPECIFICATION_VENDOR);
             sb.append(brace);
             sb.append(specificationVendor);
-            sb.append(lineSeparator);
+            sb.append(StringUtils.LINE_SEP);
         }
 
         if (null != implementationTitle) {
             sb.append(IMPLEMENTATION_TITLE);
             sb.append(brace);
             sb.append(implementationTitle);
-            sb.append(lineSeparator);
+            sb.append(StringUtils.LINE_SEP);
         }
 
         if (null != implementationVersion) {
             sb.append(IMPLEMENTATION_VERSION);
             sb.append(brace);
             sb.append(implementationVersion);
-            sb.append(lineSeparator);
+            sb.append(StringUtils.LINE_SEP);
         }
 
         if (null != implementationVendor) {
             sb.append(IMPLEMENTATION_VENDOR);
             sb.append(brace);
             sb.append(implementationVendor);
-            sb.append(lineSeparator);
+            sb.append(StringUtils.LINE_SEP);
         }
 
         return sb.toString();
@@ -521,20 +524,19 @@
                                               final ArrayList sectionsToAdd) {
         if (0 == sectionsToAdd.size()) {
             return specification;
-        } else {
-            sectionsToAdd.addAll(Arrays.asList(specification.getSections()));
-
-            final String[] sections =
-                (String[]) sectionsToAdd.toArray(new 
String[sectionsToAdd.size()]);
-
-            return new Specification(specification.getSpecificationTitle(),
-                                      
specification.getSpecificationVersion().toString(),
-                                      specification.getSpecificationVendor(),
-                                      specification.getImplementationTitle(),
-                                      specification.getImplementationVersion(),
-                                      specification.getImplementationVendor(),
-                                      sections);
         }
+        sectionsToAdd.addAll(Arrays.asList(specification.getSections()));
+        
+        final String[] sections =
+            (String[]) sectionsToAdd.toArray(new String[sectionsToAdd.size()]);
+        
+        return new Specification(specification.getSpecificationTitle(),
+                specification.getSpecificationVersion().toString(),
+                specification.getSpecificationVendor(),
+                specification.getImplementationTitle(),
+                specification.getImplementationVersion(),
+                specification.getImplementationVendor(),
+                sections);
     }
 
     /**
@@ -546,9 +548,8 @@
     private static String getTrimmedString(final String value) {
         if (null == value) {
             return null;
-        } else {
-            return value.trim();
-        }
+        } 
+        return value.trim();
     }
 
     /**
@@ -572,35 +573,35 @@
         final String specVendor
             = getTrimmedString(attributes.getValue(SPECIFICATION_VENDOR));
         if (null == specVendor) {
-            throw new ParseException("Missing " + SPECIFICATION_VENDOR, 0);
+            throw new ParseException(MISSING + SPECIFICATION_VENDOR, 0);
         }
 
         final String specVersion
             = getTrimmedString(attributes.getValue(SPECIFICATION_VERSION));
         if (null == specVersion) {
-            throw new ParseException("Missing " + SPECIFICATION_VERSION, 0);
+            throw new ParseException(MISSING + SPECIFICATION_VERSION, 0);
         }
 
         final String impTitle
             = getTrimmedString(attributes.getValue(IMPLEMENTATION_TITLE));
         if (null == impTitle) {
-            throw new ParseException("Missing " + IMPLEMENTATION_TITLE, 0);
+            throw new ParseException(MISSING + IMPLEMENTATION_TITLE, 0);
         }
 
         final String impVersion
             = getTrimmedString(attributes.getValue(IMPLEMENTATION_VERSION));
         if (null == impVersion) {
-            throw new ParseException("Missing " + IMPLEMENTATION_VERSION, 0);
+            throw new ParseException(MISSING + IMPLEMENTATION_VERSION, 0);
         }
 
         final String impVendor
             = getTrimmedString(attributes.getValue(IMPLEMENTATION_VENDOR));
         if (null == impVendor) {
-            throw new ParseException("Missing " + IMPLEMENTATION_VENDOR, 0);
+            throw new ParseException(MISSING + IMPLEMENTATION_VENDOR, 0);
         }
 
         return new Specification(name, specVersion, specVendor,
                                   impTitle, impVersion, impVendor,
                                   new String[]{section});
     }
-}
+}
\ No newline at end of file

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to