/*
 * Copyright (C) [2004, 2005, 2006], Hyperic, Inc.
 * This file is part of SIGAR.
 * 
 * SIGAR is free software; you can redistribute it and/or modify
 * it under the terms version 2 of the GNU General Public License as
 * published by the Free Software Foundation. This program is distributed
 * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA.
 */

package org.hyperic.sigar.win32;

public class LocaleInfo extends Win32 {

    /**
     * English name of language
     */
    public static final int LOCALE_SENGLANGUAGE = 0x00001001;

    /**
     * English name of country
     */
    public static final int LOCALE_SENGCOUNTRY = 0x00001002;

    /**
     * English primary language id
     */
    public static final int LANG_ENGLISH = 0x09;

    private int id;

    private static native int getSystemDefaultLCID();

    private static native String getAttribute(int id, int attr);

    public LocaleInfo() {
        this(getSystemDefaultLCID());
    }

    public static final int makeLangId(int primary, int sub) {
        return (sub << 10) | primary;
    }

    public LocaleInfo(Integer id) {
        this(id.intValue());
    }

    public LocaleInfo(int id) {
        this.id = id;
    }

    public LocaleInfo(int primary, int sub) {
        this(makeLangId(primary, sub));
    }

    public int getId() {
        return this.id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getPrimaryLangId() {
        return this.id & 0x3ff;
    }

    public String getPerflibLangId() {
        String id =
            Integer.toHexString(getPrimaryLangId()).toUpperCase();

        //length always == 3
        int pad = 3 - id.length();
        StringBuffer fid = new StringBuffer(3);
        while (pad-- > 0) {
            fid.append("0");
        }
        fid.append(id);

        return fid.toString();
    }

    public int getSubLangId() {
        return this.id >> 10;
    }

    public String getAttribute(int attr) {
        return getAttribute(this.id, attr);
    }

    public String getEnglishLanguageName() {
        return getAttribute(LOCALE_SENGLANGUAGE);
    }

    public String getEnglishCountryName() {
        return getAttribute(LOCALE_SENGCOUNTRY);
    }

    public String toString() {
        return
            getId() + ":" +
            getEnglishLanguageName() +
            " (" + getEnglishCountryName() + ")";
    }
}

@@ -1796,69 +1796,459 @@
    p
-ublic int getPrimaryLangId() %7B%0A        return this.id & 0x3ff
+rivate static int getPrimaryLangId(int id) %7B%0A        return id & 0x3ff;%0A    %7D%0A%0A    public int getPrimaryLangId() %7B%0A        return getPrimaryLangId(this.id);%0A    %7D%0A%0A    private static int getSubLangId(int id) %7B%0A        return id %3E%3E 10;%0A    %7D%0A%0A    public int getSubLangId() %7B%0A        return getSubLangId(this.id);%0A    %7D%0A%0A    public static boolean isEnglish() %7B%0A        int id = getSystemDefaultLCID();%0A        return getPrimaryLangId(id) == LANG_ENGLISH
 ;%0A  
@@ -2579,24 +2579,24 @@
 ppend(id);%0A%0A
+
         retu
@@ -2625,77 +2625,8 @@
  %7D%0A%0A
-    public int getSubLangId() %7B%0A        return this.id %3E%3E 10;%0A    %7D%0A%0A
     

add isEnglish helper