All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dps.webapplication.i18n.LocalizedStrings Maven / Gradle / Ivy

There is a newer version: 1.2.5
Show newest version
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 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> m) {

    }

    @Override
    public void clear() {

    }

    @Override
    public Set keySet() {
        return null;
    }

    @Override
    public Collection> values() {
        return null;
    }

    @Override
    public Set>> entrySet() {
        return null;
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy