aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-base
diff options
context:
space:
mode:
authorJoakim Erdfelt <joakime@apache.org>2007-10-01 22:33:16 +0000
committerJoakim Erdfelt <joakime@apache.org>2007-10-01 22:33:16 +0000
commit2ddcb71f3710a67851d3aa9c7378b339be0420d5 (patch)
treea3f9afe172655e92c74539263b7200f1a33f45ed /archiva-base
parentdf668819ac3ed66c5b02153d3614210ae15af0d1 (diff)
downloadarchiva-2ddcb71f3710a67851d3aa9c7378b339be0420d5.tar.gz
archiva-2ddcb71f3710a67851d3aa9c7378b339be0420d5.zip
JDK5 Typesafe Collection Updates
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@581104 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-base')
-rw-r--r--archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java26
-rw-r--r--archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/FileTypes.java12
-rw-r--r--archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoader.java1
-rw-r--r--archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/FiletypeToMapClosure.java4
-rw-r--r--archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/NetworkProxyComparator.java16
5 files changed, 27 insertions, 32 deletions
diff --git a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java
index 04355df68..f4c99d5d1 100644
--- a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java
+++ b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java
@@ -83,7 +83,7 @@ public class DefaultArchivaConfiguration
/**
* Listeners we've registered.
*/
- private List listeners = new LinkedList();
+ private List<RegistryListener> listeners = new LinkedList<RegistryListener>();
public String getFilteredUserConfigFilename()
{
@@ -119,9 +119,9 @@ public class DefaultArchivaConfiguration
if ( !config.getRepositories().isEmpty() )
{
- for ( Iterator i = config.getRepositories().iterator(); i.hasNext(); )
+ for ( Iterator<V1RepositoryConfiguration> i = config.getRepositories().iterator(); i.hasNext(); )
{
- V1RepositoryConfiguration r = (V1RepositoryConfiguration) i.next();
+ V1RepositoryConfiguration r = i.next();
r.setScanned( r.isIndexed() );
if ( r.getUrl().startsWith( "file://" ) )
@@ -145,7 +145,7 @@ public class DefaultArchivaConfiguration
}
}
}
-
+
return config;
}
@@ -181,11 +181,11 @@ public class DefaultArchivaConfiguration
}
else if ( baseSection != null )
{
- Collection keys = baseSection.getKeys();
+ Collection<String> keys = baseSection.getKeys();
boolean foundList = false;
- for ( Iterator i = keys.iterator(); i.hasNext() && !foundList; )
+ for ( Iterator<String> i = keys.iterator(); i.hasNext() && !foundList; )
{
- String key = (String) i.next();
+ String key = i.next();
// a little aggressive with the repositoryScanning and databaseScanning - should be no need to split
// that configuration
@@ -208,9 +208,9 @@ public class DefaultArchivaConfiguration
}
// escape all cron expressions to handle ','
- for ( Iterator i = configuration.getManagedRepositories().iterator(); i.hasNext(); )
+ for ( Iterator<ManagedRepositoryConfiguration> i = configuration.getManagedRepositories().iterator(); i.hasNext(); )
{
- ManagedRepositoryConfiguration c = (ManagedRepositoryConfiguration) i.next();
+ ManagedRepositoryConfiguration c = i.next();
c.setRefreshCronExpression( escapeCronExpression( c.getRefreshCronExpression() ) );
}
@@ -244,9 +244,9 @@ public class DefaultArchivaConfiguration
{
( (Initializable) registry ).initialize();
- for ( Iterator i = listeners.iterator(); i.hasNext(); )
+ for ( Iterator<RegistryListener> i = listeners.iterator(); i.hasNext(); )
{
- RegistryListener l = (RegistryListener) i.next();
+ RegistryListener l = i.next();
addRegistryChangeListener( l );
}
@@ -319,9 +319,9 @@ public class DefaultArchivaConfiguration
private Configuration processExpressions( Configuration config )
{
// TODO: for commons-configuration 1.3 only
- for ( Iterator i = config.getManagedRepositories().iterator(); i.hasNext(); )
+ for ( Iterator<ManagedRepositoryConfiguration> i = config.getManagedRepositories().iterator(); i.hasNext(); )
{
- ManagedRepositoryConfiguration c = (ManagedRepositoryConfiguration) i.next();
+ ManagedRepositoryConfiguration c = i.next();
c.setLocation( removeExpressions( c.getLocation() ) );
c.setRefreshCronExpression( unescapeCronExpression( c.getRefreshCronExpression() ) );
}
diff --git a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/FileTypes.java b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/FileTypes.java
index a1684681b..51bdd11d2 100644
--- a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/FileTypes.java
+++ b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/FileTypes.java
@@ -64,7 +64,7 @@ public class FileTypes
/**
* Map of default values for the file types.
*/
- private Map defaultTypeMap = new HashMap();
+ private Map<String, List<String>> defaultTypeMap = new HashMap<String, List<String>>();
/**
* <p>
@@ -83,7 +83,7 @@ public class FileTypes
* @param id the id to lookup.
* @return the list of patterns.
*/
- public List getFileTypePatterns( String id )
+ public List<String> getFileTypePatterns( String id )
{
Configuration config = archivaConfiguration.getConfiguration();
Predicate selectedFiletype = new FiletypeSelectionPredicate( id );
@@ -95,7 +95,7 @@ public class FileTypes
return filetype.getPatterns();
}
- List defaultPatterns = (List) defaultTypeMap.get( id );
+ List<String> defaultPatterns = defaultTypeMap.get( id );
if ( CollectionUtils.isEmpty( defaultPatterns ) )
{
@@ -116,7 +116,7 @@ public class FileTypes
.getResource( "/org/apache/maven/archiva/configuration/default-archiva.xml" );
XMLReader reader = new XMLReader( "configuration", defaultArchivaXml );
- List resp = reader.getElementList( "//configuration/repositoryScanning/fileTypes/fileType" );
+ List<Element> resp = reader.getElementList( "//configuration/repositoryScanning/fileTypes/fileType" );
CollectionUtils.forAllDo( resp, new AddFileTypeToDefaultMap() );
}
@@ -152,11 +152,11 @@ public class FileTypes
return;
}
- List patternElemList = patternsElem.elements( "pattern" );
+ List<Element> patternElemList = patternsElem.elements( "pattern" );
ElementTextListClosure elemTextList = new ElementTextListClosure();
CollectionUtils.forAllDo( patternElemList, elemTextList );
- List patterns = elemTextList.getList();
+ List<String> patterns = elemTextList.getList();
defaultTypeMap.put( id, patterns );
}
diff --git a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoader.java b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoader.java
index 4429c1000..33fdb51b3 100644
--- a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoader.java
+++ b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoader.java
@@ -113,6 +113,7 @@ public class MavenProxyPropertyLoader
}
}
+ @SuppressWarnings("unchecked")
private Properties getSubset( Properties props, String prefix )
{
Enumeration keys = props.keys();
diff --git a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/FiletypeToMapClosure.java b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/FiletypeToMapClosure.java
index 7a6422463..96f15ab2a 100644
--- a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/FiletypeToMapClosure.java
+++ b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/FiletypeToMapClosure.java
@@ -34,7 +34,7 @@ import java.util.Map;
public class FiletypeToMapClosure
implements Closure
{
- private Map map = new HashMap();
+ private Map<String, FileType> map = new HashMap<String, FileType>();
public void execute( Object input )
{
@@ -45,7 +45,7 @@ public class FiletypeToMapClosure
}
}
- public Map getMap()
+ public Map<String, FileType> getMap()
{
return map;
}
diff --git a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/NetworkProxyComparator.java b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/NetworkProxyComparator.java
index d19b022dd..aebc924ba 100644
--- a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/NetworkProxyComparator.java
+++ b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/NetworkProxyComparator.java
@@ -30,10 +30,9 @@ import java.util.Comparator;
* @version $Id$
*/
public class NetworkProxyComparator
- implements Comparator
+ implements Comparator<NetworkProxyConfiguration>
{
-
- public int compare( Object o1, Object o2 )
+ public int compare( NetworkProxyConfiguration o1, NetworkProxyConfiguration o2 )
{
if ( o1 == null && o2 == null )
{
@@ -50,13 +49,8 @@ public class NetworkProxyComparator
return -1;
}
- if ( ( o1 instanceof NetworkProxyConfiguration ) && ( o2 instanceof NetworkProxyConfiguration ) )
- {
- String id1 = ( (NetworkProxyConfiguration) o1 ).getId();
- String id2 = ( (NetworkProxyConfiguration) o2 ).getId();
- return id1.compareToIgnoreCase( id2 );
- }
-
- return 0;
+ String id1 = o1.getId();
+ String id2 = o2.getId();
+ return id1.compareToIgnoreCase( id2 );
}
}