JDK5 Typesafe Collection Updates

git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@581104 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Joakim Erdfelt 2007-10-01 22:33:16 +00:00
parent df668819ac
commit 2ddcb71f37
5 changed files with 27 additions and 32 deletions

View File

@ -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() ) );
}

View File

@ -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 );
}

View File

@ -113,6 +113,7 @@ public class MavenProxyPropertyLoader
}
}
@SuppressWarnings("unchecked")
private Properties getSubset( Properties props, String prefix )
{
Enumeration keys = props.keys();

View File

@ -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;
}

View File

@ -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 );
}
}