maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gb...@apache.org
Subject svn commit: r1762213 - in /maven/shared/trunk/maven-shared-jar/src: main/java/org/apache/maven/shared/jar/ main/java/org/apache/maven/shared/jar/classes/ main/java/org/apache/maven/shared/jar/identification/ main/java/org/apache/maven/shared/jar/identi...
Date Sun, 25 Sep 2016 14:54:41 GMT
Author: gboue
Date: Sun Sep 25 14:54:41 2016
New Revision: 1762213

URL: http://svn.apache.org/viewvc?rev=1762213&view=rev
Log:
Improved code: fixed usage of raw types (except Commons Collections) and converted use of
Iterator to for-each loop

Modified:
    maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/JarAnalyzer.java
    maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/JarData.java
    maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/ImportVisitor.java
    maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/JarClasses.java
    maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/JarClassesAnalysis.java
    maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentification.java
    maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentificationAnalysis.java
    maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/EmbeddedMavenModelExposer.java
    maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/JarClassesExposer.java
    maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/ManifestExposer.java
    maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/RepositorySearchExposer.java
    maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/StaticMainOutputExposer.java
    maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/TextFileExposer.java
    maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/TimestampExposer.java
    maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/hash/JarBytecodeHashAnalyzer.java
    maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/repository/EmptyRepositoryHashSearch.java
    maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/repository/RepositoryHashSearch.java
    maven/shared/trunk/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/AbstractJarAnalyzerTestCase.java
    maven/shared/trunk/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/classes/ImportVisitorTest.java

Modified: maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/JarAnalyzer.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/JarAnalyzer.java?rev=1762213&r1=1762212&r2=1762213&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/JarAnalyzer.java
(original)
+++ maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/JarAnalyzer.java
Sun Sep 25 14:54:41 2016
@@ -25,7 +25,6 @@ import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.Iterator;
 import java.util.List;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
@@ -113,16 +112,13 @@ public class JarAnalyzer
         }
 
         // Obtain entries list.
-        List entries = Collections.list( jarFile.entries() );
+        List<JarEntry> entries = Collections.list( jarFile.entries() );
 
         // Sorting of list is done by name to ensure a bytecode hash is always consistent.
-        Collections.sort( entries, new Comparator()
+        Collections.sort( entries, new Comparator<JarEntry>()
         {
-            public int compare( Object o1, Object o2 )
+            public int compare( JarEntry entry1, JarEntry entry2 )
             {
-                JarEntry entry1 = (JarEntry) o1;
-                JarEntry entry2 = (JarEntry) o2;
-
                 return entry1.getName().compareTo( entry2.getName() );
             }
         } );
@@ -175,15 +171,12 @@ public class JarAnalyzer
      * @param pattern the pattern to filter against
      * @return the list of files found, in {@link java.util.jar.JarEntry} elements
      */
-    public List filterEntries( Pattern pattern )
+    public List<JarEntry> filterEntries( Pattern pattern )
     {
-        List ret = new ArrayList();
+        List<JarEntry> ret = new ArrayList<JarEntry>();
 
-        Iterator it = getEntries().iterator();
-        while ( it.hasNext() )
+        for ( JarEntry entry : getEntries() )
         {
-            JarEntry entry = (JarEntry) it.next();
-
             Matcher mat = pattern.matcher( entry.getName() );
             if ( mat.find() )
             {
@@ -198,7 +191,7 @@ public class JarAnalyzer
      *
      * @return the list of files found, in {@link java.util.jar.JarEntry} elements
      */
-    public List getClassEntries()
+    public List<JarEntry> getClassEntries()
     {
         return filterEntries( CLASS_FILTER );
     }
@@ -208,7 +201,7 @@ public class JarAnalyzer
      *
      * @return the list of files found, in {@link java.util.jar.JarEntry} elements
      */
-    public List getMavenPomEntries()
+    public List<JarEntry> getMavenPomEntries()
     {
         return filterEntries( MAVEN_POM_FILTER );
     }
@@ -218,7 +211,7 @@ public class JarAnalyzer
      *
      * @return the list of files found, in {@link java.util.jar.JarEntry} elements
      */
-    public List getVersionEntries()
+    public List<JarEntry> getVersionEntries()
     {
         return filterEntries( VERSION_FILTER );
     }
@@ -228,7 +221,7 @@ public class JarAnalyzer
      *
      * @return the list of files found, in {@link java.util.jar.JarEntry} elements
      */
-    public List getEntries()
+    public List<JarEntry> getEntries()
     {
         return jarData.getEntries();
     }

Modified: maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/JarData.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/JarData.java?rev=1762213&r1=1762212&r2=1762213&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/JarData.java
(original)
+++ maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/JarData.java
Sun Sep 25 14:54:41 2016
@@ -27,6 +27,7 @@ import java.io.File;
 import java.util.Collections;
 import java.util.List;
 import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
 import java.util.jar.Manifest;
 
 /**
@@ -67,7 +68,7 @@ public final class JarData
     /**
      * The JAR entries.
      */
-    private final List entries;
+    private final List<JarEntry> entries;
 
     /**
      * Information about the JAR's identifying features.
@@ -81,7 +82,7 @@ public final class JarData
      * @param manifest the JAR manifest
      * @param entries  the JAR entries
      */
-    public JarData( File file, Manifest manifest, List entries )
+    public JarData( File file, Manifest manifest, List<JarEntry> entries )
     {
         this.file = file;
 
@@ -101,7 +102,7 @@ public final class JarData
         this.sealed = sealed;
     }
 
-    public List getEntries()
+    public List<JarEntry> getEntries()
     {
         return entries;
     }

Modified: maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/ImportVisitor.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/ImportVisitor.java?rev=1762213&r1=1762212&r2=1762213&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/ImportVisitor.java
(original)
+++ maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/ImportVisitor.java
Sun Sep 25 14:54:41 2016
@@ -39,7 +39,7 @@ public class ImportVisitor
     /**
      * The list of imports discovered.
      */
-    private List imports;
+    private List<String> imports;
 
     /**
      * The Java class that is being analyzed.
@@ -68,7 +68,7 @@ public class ImportVisitor
 
         // Create a list that is guaranteed to be unique while retaining it's list qualities
(LinkedHashSet does not
         // expose the list interface even if natural ordering is retained)  
-        this.imports = SetUniqueList.decorate( new ArrayList() );
+        this.imports = SetUniqueList.decorate( new ArrayList<String>() );
     }
 
     /**
@@ -76,7 +76,7 @@ public class ImportVisitor
      *
      * @return Returns the imports.
      */
-    public List getImports()
+    public List<String> getImports()
     {
         return imports;
     }

Modified: maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/JarClasses.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/JarClasses.java?rev=1762213&r1=1762212&r2=1762213&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/JarClasses.java
(original)
+++ maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/JarClasses.java
Sun Sep 25 14:54:41 2016
@@ -35,22 +35,22 @@ public class JarClasses
     /**
      * The list of imports in the classes in the JAR.
      */
-    private List imports;
+    private List<String> imports;
 
     /**
      * A list of packages represented by classes in the JAR.
      */
-    private List packages;
+    private List<String> packages;
 
     /**
      * A list of the classes that in the JAR.
      */
-    private List classNames;
+    private List<String> classNames;
 
     /**
      * A list of methods within the classes in the JAR.
      */
-    private List methods;
+    private List<String> methods;
 
     /**
      * Whether the JAR contains any code with debug information. If there is a mix of debug
and release code, this will
@@ -71,10 +71,10 @@ public class JarClasses
     {
         // Unique list decorators are used to ensure natural ordering is retained, the list
interface is availble, and
         // that duplicates are not entered.
-        imports = SetUniqueList.decorate( new ArrayList() );
-        packages = SetUniqueList.decorate( new ArrayList() );
-        classNames = SetUniqueList.decorate( new ArrayList() );
-        methods = SetUniqueList.decorate( new ArrayList() );
+        imports = SetUniqueList.decorate( new ArrayList<String>() );
+        packages = SetUniqueList.decorate( new ArrayList<String>() );
+        classNames = SetUniqueList.decorate( new ArrayList<String>() );
+        methods = SetUniqueList.decorate( new ArrayList<String>() );
     }
 
     /**
@@ -112,22 +112,22 @@ public class JarClasses
      *
      * @param imports the imports to add. Each item should be a String to avoid down the
line ClassCastExceptions.
      */
-    public void addImports( List imports )
+    public void addImports( List<String> imports )
     {
         this.imports.addAll( imports );
     }
 
-    public List getImports()
+    public List<String> getImports()
     {
         return Collections.unmodifiableList( imports );
     }
 
-    public List getClassNames()
+    public List<String> getClassNames()
     {
         return Collections.unmodifiableList( classNames );
     }
 
-    public List getPackages()
+    public List<String> getPackages()
     {
         return Collections.unmodifiableList( packages );
     }
@@ -152,7 +152,7 @@ public class JarClasses
         this.jdkRevision = jdkRevision;
     }
 
-    public List getMethods()
+    public List<String> getMethods()
     {
         return Collections.unmodifiableList( methods );
     }

Modified: maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/JarClassesAnalysis.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/JarClassesAnalysis.java?rev=1762213&r1=1762212&r2=1762213&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/JarClassesAnalysis.java
(original)
+++ maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/classes/JarClassesAnalysis.java
Sun Sep 25 14:54:41 2016
@@ -29,7 +29,6 @@ import org.apache.maven.shared.jar.JarAn
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 
 import java.io.IOException;
-import java.util.Iterator;
 import java.util.List;
 import java.util.jar.JarEntry;
 
@@ -77,16 +76,14 @@ public class JarClassesAnalysis
             String jarfilename = jarAnalyzer.getFile().getAbsolutePath();
             classes = new JarClasses();
 
-            List classList = jarAnalyzer.getClassEntries();
+            List<JarEntry> classList = jarAnalyzer.getClassEntries();
 
             classes.setDebugPresent( false );
 
             double maxVersion = 0.0;
 
-            Iterator it = classList.iterator();
-            while ( it.hasNext() )
+            for ( JarEntry entry : classList )
             {
-                JarEntry entry = (JarEntry) it.next();
                 String classname = entry.getName();
 
                 try

Modified: maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentification.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentification.java?rev=1762213&r1=1762212&r2=1762213&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentification.java
(original)
+++ maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentification.java
Sun Sep 25 14:54:41 2016
@@ -57,27 +57,27 @@ public class JarIdentification
     /**
      * The list of possible group IDs discovered.
      */
-    private List potentialGroupIds = new ArrayList();
+    private List<String> potentialGroupIds = new ArrayList<String>();
 
     /**
      * The list of possible artifact IDs discovered.
      */
-    private List potentialArtifactIds = new ArrayList();
+    private List<String> potentialArtifactIds = new ArrayList<String>();
 
     /**
      * The list of possible versions discovered.
      */
-    private List potentialVersions = new ArrayList();
+    private List<String> potentialVersions = new ArrayList<String>();
 
     /**
      * The list of possible artifact names discovered.
      */
-    private List potentialNames = new ArrayList();
+    private List<String> potentialNames = new ArrayList<String>();
 
     /**
      * The list of possible vendors discovered.
      */
-    private List potentialVendors = new ArrayList();
+    private List<String> potentialVendors = new ArrayList<String>();
 
     /**
      * Add a validated group ID.
@@ -204,7 +204,7 @@ public class JarIdentification
         addUnique( potentialNames, name );
     }
 
-    private static void addUnique( List list, String value )
+    private static void addUnique( List<String> list, String value )
     {
         if ( value != null )
         {
@@ -265,27 +265,27 @@ public class JarIdentification
         this.version = version;
     }
 
-    public List getPotentialVersions()
+    public List<String> getPotentialVersions()
     {
         return potentialVersions;
     }
 
-    public List getPotentialNames()
+    public List<String> getPotentialNames()
     {
         return potentialNames;
     }
 
-    public List getPotentialGroupIds()
+    public List<String> getPotentialGroupIds()
     {
         return potentialGroupIds;
     }
 
-    public List getPotentialArtifactIds()
+    public List<String> getPotentialArtifactIds()
     {
         return potentialArtifactIds;
     }
 
-    public List getPotentialVendors()
+    public List<String> getPotentialVendors()
     {
         return potentialVendors;
     }

Modified: maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentificationAnalysis.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentificationAnalysis.java?rev=1762213&r1=1762212&r2=1762213&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentificationAnalysis.java
(original)
+++ maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/JarIdentificationAnalysis.java
Sun Sep 25 14:54:41 2016
@@ -23,7 +23,6 @@ import org.apache.maven.shared.jar.JarAn
 import org.apache.maven.shared.utils.StringUtils;
 
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -47,7 +46,7 @@ public class JarIdentificationAnalysis
      *
      * @plexus.requirement role="org.apache.maven.shared.jar.identification.JarIdentificationExposer"
      */
-    private List exposers;
+    private List<JarIdentificationExposer> exposers;
 
     /**
      * Analyze a JAR and find any associated Maven metadata. Note that if the provided JAR
analyzer has previously
@@ -67,9 +66,8 @@ public class JarIdentificationAnalysis
 
         taxon = new JarIdentification();
 
-        for ( Iterator i = exposers.iterator(); i.hasNext(); )
+        for ( JarIdentificationExposer exposer : exposers )
         {
-            JarIdentificationExposer exposer = (JarIdentificationExposer) i.next();
             exposer.expose( taxon, jarAnalyzer );
         }
 
@@ -108,56 +106,45 @@ public class JarIdentificationAnalysis
         }
     }
 
-    private String pickSmallest( List list )
+    private String pickSmallest( List<String> list )
     {
         String smallest = null;
 
-        if ( !list.isEmpty() )
+        int size = Integer.MAX_VALUE;
+        for ( String val : list )
         {
-            int size = Integer.MAX_VALUE;
-            Iterator it = list.iterator();
-            while ( it.hasNext() )
+            if ( StringUtils.isNotEmpty( val ) )
             {
-                String val = (String) it.next();
-
-                if ( StringUtils.isNotEmpty( val ) )
+                if ( val.length() < size )
                 {
-                    if ( val.length() < size )
-                    {
-                        smallest = val;
-                        size = val.length();
-                    }
+                    smallest = val;
+                    size = val.length();
                 }
             }
         }
-
+        
         return smallest;
     }
 
-    private String pickLargest( List list )
+    private String pickLargest( List<String> list )
     {
         String largest = null;
-        if ( !list.isEmpty() )
+        int size = Integer.MIN_VALUE;
+        for ( String val : list )
         {
-            int size = Integer.MIN_VALUE;
-            Iterator it = list.iterator();
-            while ( it.hasNext() )
+            if ( StringUtils.isNotEmpty( val ) )
             {
-                String val = (String) it.next();
-                if ( StringUtils.isNotEmpty( val ) )
+                if ( val.length() > size )
                 {
-                    if ( val.length() > size )
-                    {
-                        largest = val;
-                        size = val.length();
-                    }
+                    largest = val;
+                    size = val.length();
                 }
             }
         }
         return largest;
     }
 
-    public void setExposers( List exposers )
+    public void setExposers( List<JarIdentificationExposer> exposers )
     {
         this.exposers = Collections.unmodifiableList( exposers );
     }

Modified: maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/EmbeddedMavenModelExposer.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/EmbeddedMavenModelExposer.java?rev=1762213&r1=1762212&r2=1762213&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/EmbeddedMavenModelExposer.java
(original)
+++ maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/EmbeddedMavenModelExposer.java
Sun Sep 25 14:54:41 2016
@@ -47,7 +47,7 @@ public class EmbeddedMavenModelExposer
 {
     public void expose( JarIdentification identification, JarAnalyzer jarAnalyzer )
     {
-        List entries = jarAnalyzer.getMavenPomEntries();
+        List<JarEntry> entries = jarAnalyzer.getMavenPomEntries();
         if ( entries.isEmpty() )
         {
             return;

Modified: maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/JarClassesExposer.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/JarClassesExposer.java?rev=1762213&r1=1762212&r2=1762213&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/JarClassesExposer.java
(original)
+++ maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/JarClassesExposer.java
Sun Sep 25 14:54:41 2016
@@ -25,9 +25,6 @@ import org.apache.maven.shared.jar.class
 import org.apache.maven.shared.jar.identification.JarIdentification;
 import org.apache.maven.shared.jar.identification.JarIdentificationExposer;
 
-import java.util.Iterator;
-
-
 /**
  * Exposer that examines a JAR file to derive Maven metadata from the classes in a JAR. It
will currently identify
  * potential group IDs from the class packages.
@@ -49,10 +46,8 @@ public class JarClassesExposer
     {
         JarClasses jarclasses = analyzer.analyze( jarAnalyzer );
 
-        Iterator it = jarclasses.getPackages().iterator();
-        while ( it.hasNext() )
+        for ( String packagename : jarclasses.getPackages() )
         {
-            String packagename = (String) it.next();
             identification.addGroupId( packagename );
         }
     }

Modified: maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/ManifestExposer.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/ManifestExposer.java?rev=1762213&r1=1762212&r2=1762213&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/ManifestExposer.java
(original)
+++ maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/ManifestExposer.java
Sun Sep 25 14:54:41 2016
@@ -23,8 +23,6 @@ import org.apache.maven.shared.jar.JarAn
 import org.apache.maven.shared.jar.identification.JarIdentification;
 import org.apache.maven.shared.jar.identification.JarIdentificationExposer;
 
-import java.util.Iterator;
-import java.util.Map;
 import java.util.jar.Attributes;
 import java.util.jar.Manifest;
 
@@ -43,13 +41,8 @@ public class ManifestExposer
         {
             addManifestAttributeValues( manifest.getMainAttributes(), identification );
 
-            Map entries = manifest.getEntries();
-            Iterator itentries = entries.entrySet().iterator();
-            while ( itentries.hasNext() )
+            for ( Attributes attribs : manifest.getEntries().values() )
             {
-                Map.Entry entry = (Map.Entry) itentries.next();
-                Attributes attribs = (Attributes) entry.getValue();
-
                 addManifestAttributeValues( attribs, identification );
             }
         }

Modified: maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/RepositorySearchExposer.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/RepositorySearchExposer.java?rev=1762213&r1=1762212&r2=1762213&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/RepositorySearchExposer.java
(original)
+++ maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/RepositorySearchExposer.java
Sun Sep 25 14:54:41 2016
@@ -28,7 +28,6 @@ import org.apache.maven.shared.jar.ident
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -71,7 +70,7 @@ public class RepositorySearchExposer
 
     public void expose( JarIdentification identification, JarAnalyzer jarAnalyzer )
     {
-        List repohits = new ArrayList();
+        List<Artifact> repohits = new ArrayList<Artifact>();
 
         String hash = fileHashAnalyzer.computeHash( jarAnalyzer );
         if ( hash != null )
@@ -85,17 +84,12 @@ public class RepositorySearchExposer
             repohits.addAll( repositoryHashSearch.searchBytecodeHash( bytecodehash ) );
         }
 
-        if ( !repohits.isEmpty() )
+        // Found hits in the repository.
+        for ( Artifact artifact : repohits )
         {
-            // Found hits in the repository.
-            Iterator it = repohits.iterator();
-            while ( it.hasNext() )
-            {
-                Artifact artifact = (Artifact) it.next();
-                identification.addAndSetGroupId( artifact.getGroupId() );
-                identification.addAndSetArtifactId( artifact.getArtifactId() );
-                identification.addAndSetVersion( artifact.getVersion() );
-            }
+            identification.addAndSetGroupId( artifact.getGroupId() );
+            identification.addAndSetArtifactId( artifact.getArtifactId() );
+            identification.addAndSetVersion( artifact.getVersion() );
         }
     }
 

Modified: maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/StaticMainOutputExposer.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/StaticMainOutputExposer.java?rev=1762213&r1=1762212&r2=1762213&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/StaticMainOutputExposer.java
(original)
+++ maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/StaticMainOutputExposer.java
Sun Sep 25 14:54:41 2016
@@ -24,7 +24,6 @@ import org.apache.maven.shared.jar.ident
 import org.apache.maven.shared.jar.identification.JarIdentificationExposer;
 
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -40,21 +39,16 @@ public class StaticMainOutputExposer
 {
     public void expose( JarIdentification identification, JarAnalyzer jarAnalyzer )
     {
-        List staticMains = findStaticMainVersions();
-        if ( !staticMains.isEmpty() )
+        List<String> staticMains = findStaticMainVersions();
+        for ( String ver : staticMains )
         {
-            Iterator itvers = staticMains.iterator();
-            while ( itvers.hasNext() )
-            {
-                String ver = (String) itvers.next();
-                identification.addVersion( ver );
-            }
+            identification.addVersion( ver );
         }
     }
 
-    private List findStaticMainVersions()
+    private List<String> findStaticMainVersions()
     {
         // TODO: Execute the static main methods of classes with 'Version' in their name.
-        return Collections.EMPTY_LIST;
+        return Collections.emptyList();
     }
 }

Modified: maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/TextFileExposer.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/TextFileExposer.java?rev=1762213&r1=1762212&r2=1762213&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/TextFileExposer.java
(original)
+++ maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/TextFileExposer.java
Sun Sep 25 14:54:41 2016
@@ -31,7 +31,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import java.util.jar.JarEntry;
 
@@ -48,28 +47,20 @@ public class TextFileExposer
 {
     public void expose( JarIdentification identification, JarAnalyzer jarAnalyzer )
     {
-        List textFiles = findTextFileVersions( jarAnalyzer );
-        if ( !textFiles.isEmpty() )
+        List<String> textFiles = findTextFileVersions( jarAnalyzer );
+        for ( String ver : textFiles )
         {
-            Iterator ithits = textFiles.iterator();
-            while ( ithits.hasNext() )
-            {
-                String ver = (String) ithits.next();
-                identification.addVersion( ver );
-            }
+            identification.addVersion( ver );
         }
     }
 
-    private List findTextFileVersions( JarAnalyzer jarAnalyzer )
+    private List<String> findTextFileVersions( JarAnalyzer jarAnalyzer )
     {
-        List textVersions = new ArrayList();
-        List hits = jarAnalyzer.getVersionEntries();
+        List<String> textVersions = new ArrayList<String>();
+        List<JarEntry> hits = jarAnalyzer.getVersionEntries();
 
-        Iterator it = hits.iterator();
-        while ( it.hasNext() )
+        for ( JarEntry entry : hits )
         {
-            JarEntry entry = (JarEntry) it.next();
-
             // skip this entry if it's a class file.
             if ( !entry.getName().endsWith( ".class" ) ) //$NON-NLS-1$
             {

Modified: maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/TimestampExposer.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/TimestampExposer.java?rev=1762213&r1=1762212&r2=1762213&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/TimestampExposer.java
(original)
+++ maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/exposers/TimestampExposer.java
Sun Sep 25 14:54:41 2016
@@ -28,7 +28,6 @@ import org.apache.maven.shared.utils.Str
 
 import java.text.SimpleDateFormat;
 import java.util.Date;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.jar.JarEntry;
@@ -43,28 +42,24 @@ public class TimestampExposer
 {
     public void expose( JarIdentification identification, JarAnalyzer jarAnalyzer )
     {
-        List entries = jarAnalyzer.getEntries();
+        List<JarEntry> entries = jarAnalyzer.getEntries();
         SimpleDateFormat tsformat = new SimpleDateFormat( "yyyyMMdd", Locale.US ); //$NON-NLS-1$
         Bag timestamps = new HashBag();
-        Iterator it = entries.iterator();
-        while ( it.hasNext() )
+        for ( JarEntry entry : entries )
         {
-            JarEntry entry = (JarEntry) it.next();
             long time = entry.getTime();
             String timestamp = tsformat.format( new Date( time ) );
             timestamps.add( timestamp );
         }
 
-        it = timestamps.iterator();
         String ts = "";
         int tsmax = 0;
-        while ( it.hasNext() )
+        for ( Object timestamp : timestamps )
         {
-            String timestamp = (String) it.next();
             int count = timestamps.getCount( timestamp );
             if ( count > tsmax )
             {
-                ts = timestamp;
+                ts = (String) timestamp;
                 tsmax = count;
             }
         }

Modified: maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/hash/JarBytecodeHashAnalyzer.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/hash/JarBytecodeHashAnalyzer.java?rev=1762213&r1=1762212&r2=1762213&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/hash/JarBytecodeHashAnalyzer.java
(original)
+++ maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/hash/JarBytecodeHashAnalyzer.java
Sun Sep 25 14:54:41 2016
@@ -28,7 +28,7 @@ import org.apache.maven.shared.utils.io.
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.Iterator;
+import java.util.List;
 import java.util.jar.JarEntry;
 
 /**
@@ -58,14 +58,13 @@ public class JarBytecodeHashAnalyzer
         String result = jarData.getBytecodeHash();
         if ( result == null )
         {
-            Iterator it = jarAnalyzer.getClassEntries().iterator();
+            List<JarEntry> entries = jarAnalyzer.getClassEntries();
 
             try
             {
                 digester.reset();
-                while ( it.hasNext() )
+                for ( JarEntry entry : entries )
                 {
-                    JarEntry entry = (JarEntry) it.next();
                     computeEntryBytecodeHash( jarAnalyzer.getEntryInputStream( entry ) );
                 }
                 result = digester.calc();

Modified: maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/repository/EmptyRepositoryHashSearch.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/repository/EmptyRepositoryHashSearch.java?rev=1762213&r1=1762212&r2=1762213&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/repository/EmptyRepositoryHashSearch.java
(original)
+++ maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/repository/EmptyRepositoryHashSearch.java
Sun Sep 25 14:54:41 2016
@@ -22,6 +22,8 @@ package org.apache.maven.shared.jar.iden
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.maven.artifact.Artifact;
+
 /**
  * Empty repository hash search.  Always returns an empty list.
  * <p/>
@@ -34,13 +36,13 @@ import java.util.List;
 public class EmptyRepositoryHashSearch
     implements RepositoryHashSearch
 {
-    public List searchBytecodeHash( String hash )
+    public List<Artifact> searchBytecodeHash( String hash )
     {
-        return Collections.EMPTY_LIST;
+        return Collections.emptyList();
     }
 
-    public List searchFileHash( String hash )
+    public List<Artifact> searchFileHash( String hash )
     {
-        return Collections.EMPTY_LIST;
+        return Collections.emptyList();
     }
 }

Modified: maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/repository/RepositoryHashSearch.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/repository/RepositoryHashSearch.java?rev=1762213&r1=1762212&r2=1762213&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/repository/RepositoryHashSearch.java
(original)
+++ maven/shared/trunk/maven-shared-jar/src/main/java/org/apache/maven/shared/jar/identification/repository/RepositoryHashSearch.java
Sun Sep 25 14:54:41 2016
@@ -21,6 +21,8 @@ package org.apache.maven.shared.jar.iden
 
 import java.util.List;
 
+import org.apache.maven.artifact.Artifact;
+
 /**
  * Interface for Repository Hash Searches.
  */
@@ -32,7 +34,7 @@ public interface RepositoryHashSearch
      * @param hash the hash code to use
      * @return a list of {@link org.apache.maven.artifact.Artifact} instances that matched
      */
-    List searchFileHash( String hash );
+    List<Artifact> searchFileHash( String hash );
 
     /**
      * Search the repository for artifacts matching the given hash code when consider the
bytecode of the classes in the
@@ -41,5 +43,5 @@ public interface RepositoryHashSearch
      * @param hash the hash code to use
      * @return a list of {@link org.apache.maven.artifact.Artifact} instances that matched
      */
-    List searchBytecodeHash( String hash );
+    List<Artifact> searchBytecodeHash( String hash );
 }

Modified: maven/shared/trunk/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/AbstractJarAnalyzerTestCase.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/AbstractJarAnalyzerTestCase.java?rev=1762213&r1=1762212&r2=1762213&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/AbstractJarAnalyzerTestCase.java
(original)
+++ maven/shared/trunk/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/AbstractJarAnalyzerTestCase.java
Sun Sep 25 14:54:41 2016
@@ -28,7 +28,6 @@ import java.net.MalformedURLException;
 import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -47,14 +46,12 @@ public abstract class AbstractJarAnalyze
         return new File( URLDecoder.decode( path, "UTF-8" ) );
     }
 
-    public void assertNotContainsRegex( String msg, String regex, Collection coll )
+    public void assertNotContainsRegex( String msg, String regex, Collection<String>
coll )
     {
-        List failures = new ArrayList();
+        List<String> failures = new ArrayList<String>();
         Pattern pat = Pattern.compile( regex );
-        Iterator it = coll.iterator();
-        while ( it.hasNext() )
+        for ( String value : coll )
         {
-            String value = (String) it.next();
             Matcher mat = pat.matcher( value );
             if ( mat.find() )
             {
@@ -66,10 +63,9 @@ public abstract class AbstractJarAnalyze
         {
             StringBuffer sb = new StringBuffer();
             sb.append( msg ).append( " collection has illegal regex \"" ).append( regex ).append(
"\"" );
-            it = failures.iterator();
-            while ( it.hasNext() )
+            for ( String failure : failures )
             {
-                sb.append( "\n   - \"" ).append( it.next() ).append( "\"" );
+                sb.append( "\n   - \"" ).append( failure ).append( "\"" );
             }
             throw new AssertionFailedError( sb.toString() );
         }

Modified: maven/shared/trunk/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/classes/ImportVisitorTest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/classes/ImportVisitorTest.java?rev=1762213&r1=1762212&r2=1762213&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/classes/ImportVisitorTest.java
(original)
+++ maven/shared/trunk/maven-shared-jar/src/test/java/org/apache/maven/shared/jar/classes/ImportVisitorTest.java
Sun Sep 25 14:54:41 2016
@@ -48,7 +48,7 @@ public class ImportVisitorTest
         DescendingVisitor descVisitor = new DescendingVisitor( javaClass, importVisitor );
         javaClass.accept( descVisitor );
 
-        List imports = importVisitor.getImports();
+        List<String> imports = importVisitor.getImports();
         assertNotNull( "Import List", imports );
 
         assertNotContainsRegex( "Import List", "[\\[\\)\\(\\;]", imports );
@@ -69,7 +69,7 @@ public class ImportVisitorTest
         DescendingVisitor descVisitor = new DescendingVisitor( javaClass, importVisitor );
         javaClass.accept( descVisitor );
 
-        List imports = importVisitor.getImports();
+        List<String> imports = importVisitor.getImports();
         assertNotNull( "Import List", imports );
 
         assertNotContainsRegex( "Import List", "[\\[\\)\\(\\;]", imports );




Mime
View raw message