Update of /var/cvs/src/org/mmbase/util
In directory james.mmbase.org:/tmp/cvs-serv27211
Modified Files:
LocalizedEntryListFactory.java SortedBundle.java
Log Message:
As a matter of documention, using more generics
See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/util
Index: LocalizedEntryListFactory.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/util/LocalizedEntryListFactory.java,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -b -r1.53 -r1.54
--- LocalizedEntryListFactory.java 28 Aug 2008 11:41:36 -0000 1.53
+++ LocalizedEntryListFactory.java 4 Sep 2008 11:49:20 -0000 1.54
@@ -38,7 +38,7 @@
* partially by explicit values, though this is not recommended.
*
* @author Michiel Meeuwissen
- * @version $Id: LocalizedEntryListFactory.java,v 1.53 2008/08/28 11:41:36
michiel Exp $
+ * @version $Id: LocalizedEntryListFactory.java,v 1.54 2008/09/04 11:49:20
michiel Exp $
* @since MMBase-1.8
*/
public class LocalizedEntryListFactory<C> implements Serializable, Cloneable {
@@ -646,7 +646,7 @@
return "(localized: " + localized + "bundles: " + bundles +
"fallBack: " + fallBack + ")";
}
- private static class Bundle implements Serializable, PublicCloneable {
+ private static class Bundle<D> implements Serializable, PublicCloneable {
private static final long serialVersionUID = 1L; // increase this if
object serialization changes (which we shouldn't do!)
private String resource;
@@ -684,7 +684,7 @@
/**
* Collection of Map.Entry's
*/
- Collection get(Locale loc) throws MissingResourceException {
+ Collection<Map.Entry<D, String>> get(Locale loc) throws
MissingResourceException {
try {
return SortedBundle.getResource(resource, loc, classLoader,
constantsProvider, wrapper, comparator).entrySet();
} catch (IllegalArgumentException iae) {
Index: SortedBundle.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/util/SortedBundle.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- SortedBundle.java 13 Aug 2008 07:47:48 -0000 1.34
+++ SortedBundle.java 4 Sep 2008 11:49:20 -0000 1.35
@@ -29,7 +29,7 @@
*
* @author Michiel Meeuwissen
* @since MMBase-1.8
- * @version $Id: SortedBundle.java,v 1.34 2008/08/13 07:47:48 michiel Exp $
+ * @version $Id: SortedBundle.java,v 1.35 2008/09/04 11:49:20 michiel Exp $
*/
public class SortedBundle {
@@ -46,10 +46,10 @@
/**
* Constant which can be used as an argument for [EMAIL PROTECTED]
#getResource}
*/
- public static final HashMap<String,Object> NO_CONSTANTSPROVIDER = null;
+ public static final HashMap<String, Object> NO_CONSTANTSPROVIDER = null;
// cache of maps.
- private static final Cache<String,SortedMap<Object,Object>> knownResources
= new Cache<String,SortedMap<Object,Object>>(100) {
+ private static final Cache<String, SortedMap<?, String>> knownResources =
new Cache<String, SortedMap<?, String>>(100) {
public String getName() {
return "ConstantBundles";
}
@@ -135,9 +135,9 @@
* @throws MissingResourceException if no resource bundle for the
specified base name can be found
* @throws IllegalArgumentExcpetion if wrapper is not Comparable.
*/
- public static SortedMap<Object,Object> getResource(final String baseName,
Locale locale, final ClassLoader loader, final Map<String, Object>
constantsProvider, final Class<?> wrapper, Comparator<? super Object>
comparator) {
+ public static <C> SortedMap<C, String> getResource(final String baseName,
Locale locale, final ClassLoader loader, final Map<String, Object>
constantsProvider, final Class<?> wrapper, Comparator<? super Object>
comparator) {
String resourceKey = baseName + '/' + locale + (constantsProvider ==
null ? "" : "" + constantsProvider.hashCode()) + "/" + (comparator == null ? ""
: "" + comparator.hashCode()) + "/" + (wrapper == null ? "" :
wrapper.getName());
- SortedMap<Object,Object> m = knownResources.get(resourceKey);
+ SortedMap<C, String> m = (SortedMap<C, String>)
knownResources.get(resourceKey);
if (locale == null) locale = LocalizedString.getDefault();
if (m == null) { // find and make the resource
@@ -151,13 +151,13 @@
throw new IllegalArgumentException("Key wrapper " + wrapper +
" is not Comparable");
}
- m = new TreeMap<Object, Object>(comparator);
+ m = new TreeMap<C, String>(comparator);
Enumeration<String> keys = bundle.getKeys();
while (keys.hasMoreElements()) {
String bundleKey = keys.nextElement();
- Object value = bundle.getObject(bundleKey);
- Object key = castKey(bundleKey, value, constantsProvider,
wrapper, locale);
+ String value = bundle.getString(bundleKey);
+ C key = (C) castKey(bundleKey, value, constantsProvider,
wrapper, locale);
if (key == null) continue;
m.put(key, value);
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs