FELIX-2097 Improve internal storage of available locales (this is only used for the getLocales() method and thus may be a simple string[])
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@911329 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/metatype/src/main/java/org/apache/felix/metatype/DefaultMetaTypeProvider.java b/metatype/src/main/java/org/apache/felix/metatype/DefaultMetaTypeProvider.java
index 3ce1e2d..6b8bb0d 100644
--- a/metatype/src/main/java/org/apache/felix/metatype/DefaultMetaTypeProvider.java
+++ b/metatype/src/main/java/org/apache/felix/metatype/DefaultMetaTypeProvider.java
@@ -24,7 +24,7 @@
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
-import java.util.TreeMap;
+import java.util.TreeSet;
import org.apache.felix.metatype.internal.LocalizedObjectClassDefinition;
import org.apache.felix.metatype.internal.l10n.BundleResources;
@@ -54,7 +54,7 @@
private Map objectClassDefinitions;
private Map designates;
- private Map locales;
+ private String[] locales;
public DefaultMetaTypeProvider( Bundle bundle, MetaData metadata )
@@ -125,7 +125,7 @@
}
Enumeration entries = getBundle().findEntries( path, pattern + "*.properties", false );
- locales = new TreeMap();
+ TreeSet localeSet = new TreeSet();
while ( entries.hasMoreElements() )
{
URL url = ( URL ) entries.nextElement();
@@ -136,19 +136,16 @@
{
name = name.substring( 1 );
}
- if (name.length() > 0) {
- locales.put( name, url );
+ if ( name.length() > 0 )
+ {
+ localeSet.add( name );
}
}
+
+ locales = ( String[] ) localeSet.toArray( new String[localeSet.size()] );
}
- // no locales found
- if ( locales.isEmpty() )
- {
- return null;
- }
-
- return ( String[] ) locales.keySet().toArray( new String[locales.size()] );
+ return ( locales.length == 0 ) ? null : locales;
}