1 23 24 29 30 package com.sun.jdo.spi.persistence.utility; 31 32 import java.util.*; 33 34 50 public class MergedBundle extends ResourceBundle 51 { 52 private final ResourceBundle _mainBundle, _parentBundle; 53 54 public MergedBundle (ResourceBundle mainBundle, 55 ResourceBundle parentBundle) 56 { 57 _mainBundle = mainBundle; 58 _parentBundle = parentBundle; 59 } 60 61 public Enumeration getKeys () { return mergeKeys(); } 62 63 private Enumeration mergeKeys () 64 { 65 Set noDuplicatesMerge = 66 new HashSet(getCollection(_mainBundle.getKeys())); 67 68 noDuplicatesMerge.addAll(getCollection(_parentBundle.getKeys())); 69 70 return Collections.enumeration(noDuplicatesMerge); 71 } 72 73 private Collection getCollection (Enumeration enumeration) 74 { 75 List returnList = new ArrayList(); 76 77 if (enumeration != null) 78 { 79 while (enumeration.hasMoreElements()) 80 returnList.add(enumeration.nextElement()); 81 } 82 83 return returnList; 84 } 85 86 protected Object handleGetObject (String key) 87 throws MissingResourceException 88 { 89 try 90 { 91 return _mainBundle.getObject(key); 92 } 93 catch (MissingResourceException mre) { 95 return _parentBundle.getObject(key); 96 } 97 } 98 } 99 | Popular Tags |