/*
 * $Id: VKCLanguagePack.java,v 1.5 2004/11/10 15:02:52 koppy Exp $
 *
 * Copyright (c) Siemens AG 2008 
 *           (c) Universität Paderborn 2008 
 * Licensed under EUPL 1.1. 
 *
 * $Log: VKCLanguagePack.java,v $
 * Revision 1.5  2004/11/10 15:02:52  koppy
 * Projektweite Überarbeitung von Error-Logs, Stacktraces,..
 *
 * Revision 1.4  2004/07/20 08:18:23  jonyp
 * added copyright info + cvs log
 *
 * Revision 1.3  2003/12/24 10:12:12  bigmac
 * Projektweite Import-Optimierung
 *
 * Revision 1.2  2003/07/30 12:02:01  jonyp
 * new file
 *
 * Revision 1.1  2003/07/24 09:32:18  jonyp
 * first strike
 *
 */

package vkc.db.entities;

import java.io.Serializable;

import vkc.analyse.Analyser;
import vkc.misc.VKCLogManager;

/**
 * Klasse representiert eine Sprachepacket für die Analyse im
 * VKC-System
 *
 * @author koppy
 */
public class VKCLanguagePack implements Serializable {

    private java.lang.Integer langPackId = new Integer(0);
    private java.lang.String countryCode = null;
    private java.lang.String name = null;
    private java.lang.String nameKey = null;
    private java.lang.String description = null;
	private java.lang.String descrKey = null;
	private java.lang.String className = null;
	private java.lang.String classPath = null;
	private java.lang.Integer enabled = new Integer(0);
	private Analyser analyser = null;
    
    public VKCLanguagePack() {
    }
	
	public java.lang.String getClassName() {
		return className;
	}

	public java.lang.String getClassPath() {
		return classPath;
	}

	public java.lang.String getCountryCode() {
		return countryCode;
	}

	public java.lang.String getDescription() {
		return description;
	}

	public java.lang.String getDescrKey() {
		return descrKey;
	}

	public Integer getLangPackId() {
		return langPackId;
	}

	public java.lang.String getName() {
		return name;
	}

	public void setClassName(java.lang.String string) {
		className = string;
	}

	public void setClassPath(java.lang.String string) {
		classPath = string;
	}

	public void setCountryCode(java.lang.String string) {
		countryCode = string;
	}

	public void setDescription(java.lang.String string) {
		description = string;
	}

	public void setDescrKey(java.lang.String string) {
		descrKey = string;
	}

	public void setLangPackId(Integer integer) {
		langPackId = integer;
	}

	public void setName(java.lang.String string) {
		name = string;
	}

	public java.lang.Integer getEnabled() {
		return enabled;
	}

	public void setEnabled(java.lang.Integer integer) {
		enabled = integer;
	}

    public boolean isEnabled() {
  	
    	if (this.enabled.intValue() == 0) 
    	    return false;
    	
    	return true;
    }
    
    public Analyser getAnalyser() {
		if (this.analyser != null)    	
    	    return loadAnalyser();
    	    
    	return null; 
    }
    
    private Analyser loadAnalyser() {
        if (this.className != null && this.langPackId.intValue() != 0) { 
            try {
				Class c = Class.forName(this.className);
				return (Analyser) c.newInstance();
			} catch (ClassNotFoundException e) {				
				VKCLogManager.errorLog(this, "1", "Could not load Analyser " + this.className, e);
				VKCLogManager.errorLog(this, "", e.getMessage(),e);
			} catch (InstantiationException e) {
				VKCLogManager.errorLog(this, "", e.getMessage(),e);								
			} catch (IllegalAccessException e) {
				VKCLogManager.errorLog(this, "", e.getMessage(),e);
			}
        }

        return null; 
    	
    }

	public java.lang.String getNameKey() {
		return this.nameKey;
	}

	public void setNameKey(java.lang.String nameKey) {
		this.nameKey = nameKey;
	}

}
