EnvironmentMember.java :  » Testing » jacareto » jacareto » system » Java Open Source

Java Open Source » Testing » jacareto 
jacareto » jacareto » system » EnvironmentMember.java
/*
 * Jacareto Copyright (c) 2002-2005
 * Applied Computer Science Research Group, Darmstadt University of
 * Technology, Institute of Mathematics & Computer Science,
 * Ludwigsburg University of Education, and Computer Based
 * Learning Research Group, Aachen University. All rights reserved.
 *
 * Jacareto is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * Jacareto 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 Jacareto; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

package jacareto.system;


import org.apache.log4j.Logger;

/**
 * A superclass for all classes which are a members of a Jacareto environment. A member of an
 * environment has access to the logger, the customization and the language instances contained in
 * that environment. If an environment member wants to access the environment instances like the
 * logger or the customization, the environment has to be specified before. There are two ways to
 * set the environment for an environment member:
 * 
 * <ul>
 * <li>
 * Call the constructor {@link #EnvironmentMember(Environment)} when creating the member.
 * </li>
 * <li>
 * If you have called the constructor without the environment as argument, then call the method
 * {@link #setEnvironment(Environment)} before you want to access the environment instances.
 * </li>
 * </ul>
 * 
 * You may access the environment instances in a subclass by using one of the following ways:
 * 
 * <ul>
 * <li>
 * <code>getEnvironment().getLogger()</code>
 * </li>
 * <li>
 * <code>env.getLogger()</code>
 * </li>
 * <li>
 * <code>getLogger()</code>
 * </li>
 * <li>
 * <code>logger</code>
 * </li>
 * </ul>
 * 
 * Just use the way you like most.
 *
 * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
 * @version 1.00
 */
public class EnvironmentMember {
    /** The env this member belongs to. */
    protected Environment env;

    /** The logger instance contained in the env. */
    protected Logger logger;

    /** The customization instance contained in the env. */
    protected Customization customization;

    /** The language instance contained in the env. */
    protected Language language;

    /** The files instance contained in the env. */
    protected Files files;

    /**
     * Creates a new env member object with the specified env.
     *
     * @param env the Jacareto env
     */
    public EnvironmentMember (Environment env) {
        setEnvironment (env);
    }

    /**
     * Creates a new env member of no env.
     */
    public EnvironmentMember () {
        this(null);
    }

    /**
     * Changes the env of this member.
     *
     * @param env {@link Environment}
     */
    public void setEnvironment (Environment env) {
        this.env = env;

        if (env != null) {
            this.logger = env.getLogger ();
            this.customization = env.getCustomization ();
            this.language = env.getLanguage ();
            this.files = env.getFiles ();
        } else {
            this.logger = null;
            this.customization = null;
            this.language = null;
            this.files = null;
        }
    }

    /**
     * Returns the member's env.
     *
     * @return DOCUMENT ME!
     */
    public Environment getEnvironment () {
        return env;
    }

    /**
     * Returns the logger instance of the member's env.
     *
     * @return DOCUMENT ME!
     */
    public Logger getLogger () {
        return logger;
    }

    /**
     * Returns the customization instance of the member's env.
     *
     * @return DOCUMENT ME!
     */
    public Customization getCustomization () {
        return customization;
    }

    /**
     * Returns the language instance of the member's env.
     *
     * @return DOCUMENT ME!
     */
    public Language getLanguage () {
        return language;
    }

    /**
     * returns the files instance of the member's env.
     *
     * @return DOCUMENT ME!
     */
    public Files getFiles () {
        return files;
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.