/*
 * $Id: VKCLanguage.java,v 1.11 2006/10/29 17:23:52 marbobo Exp $
 *
 * Copyright (c) Siemens AG 2008 
 *           (c) Universität Paderborn 2008 
 * Licensed under EUPL 1.1. 
 *
 * $Log: VKCLanguage.java,v $
 * Revision 1.11  2006/10/29 17:23:52  marbobo
 * + Arabische Locale hinzugefügt
 *
 * Revision 1.10  2006/03/09 01:26:46  marbobo
 * + Russische-Locale hinzugefügt
 *
 * Revision 1.9  2004/12/09 15:17:16  jonyp
 * added handling for new columns defaultLanguage/name_key
 *
 * Revision 1.8  2004/06/27 17:16:55  marbobo
 * + Quellcode maintenance
 *
 * Revision 1.7  2004/03/16 00:39:51  marbobo
 * + equals() hinzugefügt
 *
 * Revision 1.6  2004/03/08 18:22:14  bigmac
 * Obsolete Felder eliminiert
 *
 * Revision 1.5  2003/09/01 19:22:55  jonyp
 * rename templateFile to mailFile
 *
 * Revision 1.4  2003/09/01 16:31:38  jonyp
 * expdocfile/helpfile
 *
 * Revision 1.3  2003/04/25 13:36:49  jonyp
 * erweiterung "template..." aufgrund änderunge in tabelle languages
 *
 * Revision 1.2  2002/11/04 02:04:32  koppy
 * long --> Integer
 *
 * Revision 1.1  2002/10/21 14:35:39  bigmac
 * *** empty log message ***
 *
 * Revision 1.1  2002/09/16 12:13:54  koppy
 * Initial version
 *
 */

package vkc.db.entities;

import java.io.Serializable;
import java.util.Locale;

/**
 * Klasse representiert eine Sprache im
 * VKC-System
 *
 * @author koppy
 */
public class VKCLanguage implements Serializable {
    private Integer languageId = new Integer(-1);
    private String name;
    private String name_key;
    private String shortName;
    private String isoCode;
    private Integer defaultLanguage;

    public Integer getLanguageId() {
        return this.languageId;
    }

    public void setLanguageId(Integer languageId) {
        this.languageId = languageId;
    }
    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getShortName() {
        return this.shortName;
    }

    public void setShortName(String shortName) {
        this.shortName = shortName;
    }
    public String getIsoCode() {
        return this.isoCode;
    }

    public void setIsoCode(String isoCode) {
        this.isoCode = isoCode;
    }

	public Locale getLocale(){
		if (shortName.equalsIgnoreCase("en")) {
			return Locale.ENGLISH;
		} else if (shortName.equalsIgnoreCase("de")) {
			return Locale.GERMAN;
		} else if (shortName.equalsIgnoreCase("fr")) {
			return Locale.FRENCH;
		} else if (shortName.equalsIgnoreCase("it")) {
			return Locale.ITALIAN;
		} else if (shortName.equalsIgnoreCase("ru")) {
			return new Locale("ru", "RU");
		} else if (shortName.equalsIgnoreCase("ja")) {
			return Locale.JAPANESE;
		} else if (shortName.equalsIgnoreCase("ko")) {
			return Locale.KOREAN;
		} else if (shortName.equalsIgnoreCase("zh")) {
			return Locale.CHINESE;
		} else if (shortName.equalsIgnoreCase("ar")) {
			return new Locale("ar");
		} else { 
			return Locale.ENGLISH;
		}
	}

	public boolean equals(Object object) {
		if (object == null || object instanceof VKCLanguage == false) {
			return false;
		} 

		VKCLanguage lang = (VKCLanguage)object;
		
		return getLanguageId().intValue() == lang.getLanguageId().intValue();
	}

    public boolean isDefaultLanguage() {
        if (defaultLanguage.intValue() != 0) {
            return true;
        }
        
        return false;
    }

    public void setDefaultLanguage(Integer defaultLanguage) {
        this.defaultLanguage = defaultLanguage;
    }

    public String getName_key() {
        return name_key;
    }

    public void setName_key(String name_key) {
        this.name_key = name_key;
    }
}