com.swak.i18n.aggregate.AggregateBundle Maven / Gradle / Ivy
The newest version!
package com.swak.i18n.aggregate;
import com.swak.i18n.util.IteratorEnumeration;
import java.util.*;
/**
* @author colley.ma
* @since 3.0.0
*/
public class AggregateBundle extends ResourceBundle {
private final Map contents = new HashMap();
public AggregateBundle(List bundles) {
if ( bundles != null ) {
for ( ResourceBundle bundle : bundles ) {
Enumeration keys = bundle.getKeys();
while ( keys.hasMoreElements() ) {
String oneKey = keys.nextElement();
if ( !contents.containsKey( oneKey ) ) {
contents.put( oneKey, bundle.getObject( oneKey ) );
}
}
}
}
}
@Override
public Enumeration getKeys() {
return new IteratorEnumeration<>(contents.keySet().iterator());
}
@Override
protected Object handleGetObject(String key) {
return contents.get( key );
}
}