FileDocCategorySizeDatePackage
MergedBundle.javaAPI DocGlassfish v2 API3789Fri May 04 22:35:20 BST 2007com.sun.jdo.spi.persistence.utility

MergedBundle

public class MergedBundle extends ResourceBundle
Special resource bundle which delegates to two others. Ideally could just set the parent on the first, but this is protected, so it might not work. It's still unclear whether that approach would work in this subclass because it may break the localization fall through mechanism if used. Note: This code is copied from NbBundle in the openide sources with the following modifications: - reformatting - making variables final - renaming variables and some params - removing locale code - creating the merged set of keys using jdk classes and not nb utils
author
Rochelle Raccah
version
%I%

Fields Summary
private final ResourceBundle
_mainBundle
private final ResourceBundle
_parentBundle
Constructors Summary
public MergedBundle(ResourceBundle mainBundle, ResourceBundle parentBundle)

		_mainBundle = mainBundle;
		_parentBundle = parentBundle;
	
Methods Summary
private java.util.CollectiongetCollection(java.util.Enumeration enumeration)

		List returnList = new ArrayList();

		if (enumeration != null)
		{
			while (enumeration.hasMoreElements())
				returnList.add(enumeration.nextElement());
		}

		return returnList;
	
public java.util.EnumerationgetKeys()

 return mergeKeys(); 
protected java.lang.ObjecthandleGetObject(java.lang.String key)

		try
		{
			return _mainBundle.getObject(key);
		}
		catch (MissingResourceException mre)	// try the other bundle
		{
			return _parentBundle.getObject(key);
		}
	
private java.util.EnumerationmergeKeys()

		Set noDuplicatesMerge = 
			new HashSet(getCollection(_mainBundle.getKeys()));

		noDuplicatesMerge.addAll(getCollection(_parentBundle.getKeys()));

		return Collections.enumeration(noDuplicatesMerge);