/*
 * $Id: EffectConfig.java 220 2007-07-16 10:32:15Z sugimotokenichi $
 * Copyright (C) 2005 SUGIMOTO Ken-ichi
 * 作成日: 2006/02/20
 */
package feat2.config;

import feat2.Action;
import feat2.Effector;
import feat2.FeatError;
import feat2.FeatErrors;

/**
 * エフェクトコンポーネントの設定。
 * @author SUGIMOTO Ken-ichi
 */
public class EffectConfig extends ActionConfigBase {

    // Configのメソッド -------------------------------------------------------

    public String getElementName() {
        return "effect";
    }


    public Action getActionInstance() {

        try {

            return (Action) getActionClass().newInstance();

        }
        catch (InstantiationException ex) {
            throw new ConfigurationException(ex);
        }
        catch (IllegalAccessException ex) {
            throw new ConfigurationException(ex);
        }

    }


    public boolean validate(FeatErrors errs) {

        boolean ret = super.validate(errs);

        if ( !Effector.class.isAssignableFrom(getActionClass()) ) {
            ret = false;
            errs.add( new ConfigError(getClassName().getValue(), "class", ConfigError.TYPE_EFFECTOR_INTERFACE, FeatError.ERROR, this) );
        }

        return ret;
    }


}
