Author: jdcasey
Date: Tue Apr 21 22:53:31 2009
New Revision: 767323

URL: http://svn.apache.org/viewvc?rev=767323&view=rev
Log:
update to 1.5 syntax

Modified:
    
maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/AbstractStringBasedModelInterpolator.java
    
maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/ModelInterpolationException.java
    
maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/ModelInterpolator.java
    
maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/PathTranslatingPostProcessor.java
    
maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/StringSearchModelInterpolator.java

Modified: 
maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/AbstractStringBasedModelInterpolator.java
URL: 
http://svn.apache.org/viewvc/maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/AbstractStringBasedModelInterpolator.java?rev=767323&r1=767322&r2=767323&view=diff
==============================================================================
--- 
maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/AbstractStringBasedModelInterpolator.java
 (original)
+++ 
maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/AbstractStringBasedModelInterpolator.java
 Tue Apr 21 22:53:31 2009
@@ -19,18 +19,6 @@
  * under the License.
  */
 
-import java.io.File;
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
 import org.apache.maven.model.Model;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
@@ -54,6 +42,17 @@
 import 
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
 /**
  * Use a regular expression search to find and resolve expressions within the 
POM.
  *
@@ -65,13 +64,13 @@
     extends AbstractLogEnabled
     implements ModelInterpolator, Initializable
 {
-    private static final List PROJECT_PREFIXES = Arrays.asList( new String[]{ 
"pom.", "project." } );
+    private static final List<String> PROJECT_PREFIXES = Arrays.asList( new 
String[]{ "pom.", "project." } );
 
-    private static final List TRANSLATED_PATH_EXPRESSIONS;
+    private static final List<String> TRANSLATED_PATH_EXPRESSIONS;
 
     static
     {
-        List translatedPrefixes = new ArrayList();
+        List<String> translatedPrefixes = new ArrayList<String>();
 
         // MNG-1927, MNG-2124, MNG-3355:
         // If the build section is present and the project directory is 
non-null, we should make
@@ -109,7 +108,7 @@
     {
     }
 
-    public Model interpolate( Model model, Map context )
+    public Model interpolate( Model model, Map<String, ?> context )
         throws ModelInterpolationException
     {
         return interpolate( model, context, true );
@@ -127,7 +126,7 @@
      *
      * @deprecated Use {...@link ModelInterpolator#interpolate(Model, File, 
ProjectBuilderConfiguration, boolean)} instead.
      */
-    public Model interpolate( Model model, Map context, boolean strict )
+    public Model interpolate( Model model, Map<String, ?> context, boolean 
strict )
         throws ModelInterpolationException
     {
         Properties props = new Properties();
@@ -204,8 +203,8 @@
     {
         try
         {
-            List valueSources = createValueSources( model, projectDir, config 
);
-            List postProcessors = createPostProcessors( model, projectDir, 
config );
+            List<ValueSource> valueSources = createValueSources( model, 
projectDir, config );
+            List<InterpolationPostProcessor> postProcessors = 
createPostProcessors( model, projectDir, config );
             
             return interpolateInternal( src, valueSources, postProcessors, 
debug );
         }
@@ -215,7 +214,7 @@
         }
     }
     
-    protected List createValueSources( final Model model, final File 
projectDir, final ProjectBuilderConfiguration config )
+    protected List<ValueSource> createValueSources( final Model model, final 
File projectDir, final ProjectBuilderConfiguration config )
     {
         String timestampFormat = DEFAULT_BUILD_TIMESTAMP_FORMAT;
 
@@ -251,7 +250,7 @@
         },
         PROJECT_PREFIXES, false );
         
-        List valueSources = new ArrayList( 9 );
+        List<ValueSource> valueSources = new ArrayList<ValueSource>( 9 );
         
         // NOTE: Order counts here!
         valueSources.add( basedirValueSource );
@@ -273,12 +272,19 @@
         return valueSources;
     }
     
-    protected List createPostProcessors( final Model model, final File 
projectDir, final ProjectBuilderConfiguration config )
+    protected List<InterpolationPostProcessor> createPostProcessors( final 
Model model, final File projectDir,
+                                                                     final 
ProjectBuilderConfiguration config )
     {
-        return Collections.singletonList( new PathTranslatingPostProcessor( 
PROJECT_PREFIXES, TRANSLATED_PATH_EXPRESSIONS, projectDir, pathTranslator ) );
+        return Collections.singletonList( (InterpolationPostProcessor) new 
PathTranslatingPostProcessor(
+                                                                               
                          PROJECT_PREFIXES,
+                                                                               
                          TRANSLATED_PATH_EXPRESSIONS,
+                                                                               
                          projectDir,
+                                                                               
                          pathTranslator ) );
     }
     
-    protected String interpolateInternal( String src, List valueSources, List 
postProcessors, boolean debug )
+    @SuppressWarnings("unchecked")
+    protected String interpolateInternal( String src, List<ValueSource> 
valueSources,
+                                          List<InterpolationPostProcessor> 
postProcessors, boolean debug )
         throws ModelInterpolationException
     {
         if ( src.indexOf( "${" ) < 0 )
@@ -292,16 +298,13 @@
         synchronized( this )
         {
             
-            for ( Iterator it = valueSources.iterator(); it.hasNext(); )
+            for ( ValueSource vs : valueSources )
             {
-                ValueSource vs = (ValueSource) it.next();
                 interpolator.addValueSource( vs );
             }
             
-            for ( Iterator it = postProcessors.iterator(); it.hasNext(); )
+            for ( InterpolationPostProcessor postProcessor : postProcessors )
             {
-                InterpolationPostProcessor postProcessor = 
(InterpolationPostProcessor) it.next();
-                
                 interpolator.addPostProcessor( postProcessor );
             }
 
@@ -318,16 +321,14 @@
 
                 if ( debug )
                 {
-                    List feedback = interpolator.getFeedback();
+                    List<Object> feedback = (List<Object>) 
interpolator.getFeedback();
                     if ( feedback != null && !feedback.isEmpty() )
                     {
                         logger.debug( "Maven encountered the following 
problems during initial POM interpolation:" );
 
                         Object last = null;
-                        for ( Iterator it = feedback.iterator(); it.hasNext(); 
)
+                        for ( Object next : feedback )
                         {
-                            Object next = it.next();
-
                             if ( next instanceof Throwable )
                             {
                                 if ( last == null )
@@ -361,15 +362,13 @@
             }
             finally
             {
-                for ( Iterator iterator = valueSources.iterator(); 
iterator.hasNext(); )
+                for ( ValueSource vs : valueSources )
                 {
-                    ValueSource vs = (ValueSource) iterator.next();
                     interpolator.removeValuesSource( vs );
                 }
                 
-                for ( Iterator iterator = postProcessors.iterator(); 
iterator.hasNext(); )
+                for ( InterpolationPostProcessor postProcessor : 
postProcessors )
                 {
-                    InterpolationPostProcessor postProcessor = 
(InterpolationPostProcessor) iterator.next();
                     interpolator.removePostProcessor( postProcessor );
                 }
             }

Modified: 
maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/ModelInterpolationException.java
URL: 
http://svn.apache.org/viewvc/maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/ModelInterpolationException.java?rev=767323&r1=767322&r2=767323&view=diff
==============================================================================
--- 
maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/ModelInterpolationException.java
 (original)
+++ 
maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/ModelInterpolationException.java
 Tue Apr 21 22:53:31 2009
@@ -24,6 +24,7 @@
  *         <p/>
  *         Created on Feb 2, 2005
  */
+...@suppresswarnings("serial")
 public class ModelInterpolationException
     extends Exception
 {

Modified: 
maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/ModelInterpolator.java
URL: 
http://svn.apache.org/viewvc/maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/ModelInterpolator.java?rev=767323&r1=767322&r2=767323&view=diff
==============================================================================
--- 
maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/ModelInterpolator.java
 (original)
+++ 
maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/ModelInterpolator.java
 Tue Apr 21 22:53:31 2009
@@ -41,13 +41,13 @@
     /**
      * @deprecated Use {...@link ModelInterpolator#interpolate(Model, File, 
ProjectBuilderConfiguration, boolean)} instead.
      */
-    Model interpolate( Model project, Map context )
+    Model interpolate( Model project, Map<String, ?> context )
         throws ModelInterpolationException;
 
     /**
      * @deprecated Use {...@link ModelInterpolator#interpolate(Model, File, 
ProjectBuilderConfiguration, boolean)} instead.
      */
-    Model interpolate( Model model, Map context, boolean strict )
+    Model interpolate( Model model, Map<String, ?> context, boolean strict )
         throws ModelInterpolationException;
 
     Model interpolate( Model model,

Modified: 
maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/PathTranslatingPostProcessor.java
URL: 
http://svn.apache.org/viewvc/maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/PathTranslatingPostProcessor.java?rev=767323&r1=767322&r2=767323&view=diff
==============================================================================
--- 
maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/PathTranslatingPostProcessor.java
 (original)
+++ 
maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/PathTranslatingPostProcessor.java
 Tue Apr 21 22:53:31 2009
@@ -20,9 +20,7 @@
  */
 
 import org.apache.maven.project.path.PathTranslator;
-import org.codehaus.plexus.interpolation.AbstractFunctionValueSourceWrapper;
 import org.codehaus.plexus.interpolation.InterpolationPostProcessor;
-import org.codehaus.plexus.interpolation.ValueSource;
 import org.codehaus.plexus.interpolation.util.ValueSourceUtils;
 
 import java.io.File;
@@ -36,12 +34,12 @@
     implements InterpolationPostProcessor
 {
 
-    private final List unprefixedPathKeys;
+    private final List<String> unprefixedPathKeys;
     private final File projectDir;
     private final PathTranslator pathTranslator;
-    private final List expressionPrefixes;
+    private final List<String> expressionPrefixes;
 
-    public PathTranslatingPostProcessor( List expressionPrefixes, List 
unprefixedPathKeys, File projectDir, PathTranslator pathTranslator )
+    public PathTranslatingPostProcessor( List<String> expressionPrefixes, 
List<String> unprefixedPathKeys, File projectDir, PathTranslator pathTranslator 
)
     {
         this.expressionPrefixes = expressionPrefixes;
         this.unprefixedPathKeys = unprefixedPathKeys;

Modified: 
maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/StringSearchModelInterpolator.java
URL: 
http://svn.apache.org/viewvc/maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/StringSearchModelInterpolator.java?rev=767323&r1=767322&r2=767323&view=diff
==============================================================================
--- 
maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/StringSearchModelInterpolator.java
 (original)
+++ 
maven/components/branches/maven-2.1.x/maven-project/src/main/java/org/apache/maven/project/interpolation/StringSearchModelInterpolator.java
 Tue Apr 21 22:53:31 2009
@@ -1,5 +1,14 @@
 package org.apache.maven.project.interpolation;
 
+import org.apache.maven.model.Model;
+import org.apache.maven.project.ProjectBuilderConfiguration;
+import org.apache.maven.project.path.PathTranslator;
+import org.codehaus.plexus.interpolation.InterpolationPostProcessor;
+import org.codehaus.plexus.interpolation.Interpolator;
+import org.codehaus.plexus.interpolation.StringSearchInterpolator;
+import org.codehaus.plexus.interpolation.ValueSource;
+import org.codehaus.plexus.logging.Logger;
+
 import java.io.File;
 import java.lang.reflect.Array;
 import java.lang.reflect.Field;
@@ -7,25 +16,17 @@
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.WeakHashMap;
 
-import org.apache.maven.model.Model;
-import org.apache.maven.project.ProjectBuilderConfiguration;
-import org.apache.maven.project.path.PathTranslator;
-import org.codehaus.plexus.interpolation.Interpolator;
-import org.codehaus.plexus.interpolation.StringSearchInterpolator;
-import org.codehaus.plexus.logging.Logger;
-
 public class StringSearchModelInterpolator
     extends AbstractStringBasedModelInterpolator
 {
 
-    private static final Map fieldsByClass = new WeakHashMap();
-    private static final Map fieldIsPrimitiveByClass = new WeakHashMap();
+    private static final Map<Class<?>, Field[]> fieldsByClass = new 
WeakHashMap<Class<?>, Field[]>();
+    private static final Map<Class<?>, Boolean> fieldIsPrimitiveByClass = new 
WeakHashMap<Class<?>, Boolean>();
 
     public StringSearchModelInterpolator()
     {
@@ -50,8 +51,8 @@
     {
         try
         {
-            List valueSources = createValueSources( model, projectDir, config 
);
-            List postProcessors = createPostProcessors( model, projectDir, 
config );
+            List<ValueSource> valueSources = createValueSources( model, 
projectDir, config );
+            List<InterpolationPostProcessor> postProcessors = 
createPostProcessors( model, projectDir, config );
             
             InterpolateObjectAction action =
                 new InterpolateObjectAction( obj, valueSources, 
postProcessors, debugEnabled,
@@ -79,32 +80,32 @@
         return interpolator;
     }
     
-    private static final class InterpolateObjectAction implements 
PrivilegedAction
+    private static final class InterpolateObjectAction implements 
PrivilegedAction<ModelInterpolationException>
     {
 
         private final boolean debugEnabled;
-        private final LinkedList interpolationTargets;
+        private final LinkedList<Object> interpolationTargets;
         private final StringSearchModelInterpolator modelInterpolator;
         private final Logger logger;
-        private final List valueSources;
-        private final List postProcessors;
+        private final List<ValueSource> valueSources;
+        private final List<InterpolationPostProcessor> postProcessors;
         
-        public InterpolateObjectAction( Object target, List valueSources, List 
postProcessors,
-                                        boolean debugEnabled,
+        public InterpolateObjectAction( Object target, List<ValueSource> 
valueSources,
+                                        List<InterpolationPostProcessor> 
postProcessors, boolean debugEnabled,
                                         StringSearchModelInterpolator 
modelInterpolator, Logger logger )
         {
             this.valueSources = valueSources;
             this.postProcessors = postProcessors;
             this.debugEnabled = debugEnabled;
             
-            this.interpolationTargets = new LinkedList();
+            this.interpolationTargets = new LinkedList<Object>();
             interpolationTargets.add( target );
             
             this.modelInterpolator = modelInterpolator;
             this.logger = logger;
         }
 
-        public Object run()
+        public ModelInterpolationException run()
         {
             while( !interpolationTargets.isEmpty() )
             {
@@ -123,7 +124,8 @@
             return null;
         }
 
-        private void traverseObjectWithParents( Class cls, Object target )
+        @SuppressWarnings("unchecked")
+        private void traverseObjectWithParents( Class<?> cls, Object target )
             throws ModelInterpolationException
         {
             if ( cls == null )
@@ -147,7 +149,7 @@
                 
                 for ( int i = 0; i < fields.length; i++ )
                 {
-                    Class type = fields[i].getType();
+                    Class<?> type = fields[i].getType();
                     if ( isQualifiedForInterpolation( fields[i], type ) )
                     {
                         boolean isAccessible = fields[i].isAccessible();
@@ -171,10 +173,10 @@
                                 }
                                 else if ( Collection.class.isAssignableFrom( 
type ) )
                                 {
-                                    Collection c = (Collection) fields[i].get( 
target );
+                                    Collection<Object> c = 
(Collection<Object>) fields[i].get( target );
                                     if ( c != null && !c.isEmpty() )
                                     {
-                                        List originalValues = new ArrayList( c 
);
+                                        List<Object> originalValues = new 
ArrayList<Object>( c );
                                         try
                                         {
                                             c.clear();
@@ -188,9 +190,8 @@
                                             continue;
                                         }
                                         
-                                        for ( Iterator it = 
originalValues.iterator(); it.hasNext(); )
+                                        for ( Object value : originalValues )
                                         {
-                                            Object value = it.next();
                                             if ( value != null )
                                             {
                                                 if( String.class == 
value.getClass() )
@@ -229,13 +230,11 @@
                                 }
                                 else if ( Map.class.isAssignableFrom( type ) )
                                 {
-                                    Map m = (Map) fields[i].get( target );
+                                    Map<Object, Object> m = (Map<Object, 
Object>) fields[i].get( target );
                                     if ( m != null && !m.isEmpty() )
                                     {
-                                        for ( Iterator it = 
m.entrySet().iterator(); it.hasNext(); )
+                                        for ( Map.Entry<Object, Object> entry 
: m.entrySet() )
                                         {
-                                            Map.Entry entry = (Map.Entry) 
it.next();
-                                            
                                             Object value = entry.getValue();
                                             
                                             if ( value != null )
@@ -311,12 +310,12 @@
             }
         }
 
-        private boolean isQualifiedForInterpolation( Class cls )
+        private boolean isQualifiedForInterpolation( Class<?> cls )
         {
             return !cls.getPackage().getName().startsWith( "java" );
         }
 
-        private boolean isQualifiedForInterpolation( Field field, Class 
fieldType )
+        private boolean isQualifiedForInterpolation( Field field, Class<?> 
fieldType )
         {
             if ( !fieldIsPrimitiveByClass.containsKey( fieldType ) )
             {


Reply via email to