/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package beans;

import java.util.*;
import java.text.DateFormat;


/**
 *
 * @author sinem
 */
public class LocationBean {
    static HashMap locales = null;
    static ArrayList localeNames = null;
    Locale selectedLocale;
    String selectedLocaleString;

    public LocationBean() {
        locales = new HashMap();
        localeNames = new ArrayList();
        localeNames.add(">MyHometown");

        Locale[] list = DateFormat.getAvailableLocales();


        for (int i = 0; i < list.length; i++) {
            locales.put(list[i].getDisplayName(), list[i]);
            localeNames.add(list[i].getDisplayName());
        }

        Collections.sort(localeNames);
        selectedLocale = null;
        selectedLocaleString = null;
    }

    public static boolean equals(String l1, String l2) {
        return l1.equals(l2);
    }

    public Collection getLocaleNames() {
        return localeNames;
    }

    public static void setLocations() {
  locales = new HashMap();
        localeNames = new ArrayList();

        Locale[] list = DateFormat.getAvailableLocales();

        for (int i = 0; i < list.length; i++) {
            locales.put(list[i].getDisplayName(), list[i]);
            localeNames.add(list[i].getDisplayName());
        }

        Collections.sort(localeNames);
    }

    public void setSelectedLocaleString(String displayName) {
        this.selectedLocaleString = displayName;
        this.selectedLocale = (Locale) locales.get(displayName);
    }

    public Locale getSelectedLocale() {
        return selectedLocale;
    }

    public String getSelectedLocaleString() {
        return selectedLocaleString;
    }
}
