dps.webapplication.i18n.LocalizedStrings Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dps.webapplication Show documentation
Show all versions of dps.webapplication Show documentation
Common classes for webapplications
package dps.webapplication.i18n;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
import java.util.Collection;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.Set;
@Named("localized")
@RequestScoped
public class LocalizedStrings implements Map> {
@Inject
CurrentLocale locale;
@Inject
ResourceBundles bundles;
@Override
public boolean containsKey(Object key) {
return bundles.getBundle(locale.getLocale(),(String)key) != null;
}
@Override
public Map get(Object key) {
ResourceBundle bundle = bundles.getBundle(locale.getLocale(),(String)key);
return new Map() {
@Override
public boolean containsKey(Object key) {
return bundle.containsKey((String)key);
}
@Override
public String get(Object key) {
return bundle.getString((String)key);
}
@Override
public int size() {
return 0;
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public boolean containsValue(Object value) {
return false;
}
@Override
public String put(String key, String value) {
return null;
}
@Override
public String remove(Object key) {
return null;
}
@Override
public void putAll(Map extends String, ? extends String> m) {
}
@Override
public void clear() {
}
@Override
public Set keySet() {
return bundle.keySet();
}
@Override
public Collection values() {
return null;
}
@Override
public Set> entrySet() {
return null;
}
};
}
@Override
public int size() {
return 0;
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public boolean containsValue(Object value) {
return false;
}
@Override
public Map put(String key, Map value) {
return null;
}
@Override
public Map remove(Object key) {
return null;
}
@Override
public void putAll(Map extends String, ? extends Map> m) {
}
@Override
public void clear() {
}
@Override
public Set keySet() {
return null;
}
@Override
public Collection