001: /*
002: * Jacareto Copyright (c) 2002-2005
003: * Applied Computer Science Research Group, Darmstadt University of
004: * Technology, Institute of Mathematics & Computer Science,
005: * Ludwigsburg University of Education, and Computer Based
006: * Learning Research Group, Aachen University. All rights reserved.
007: *
008: * Jacareto is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation; either
011: * version 2 of the License, or (at your option) any later version.
012: *
013: * Jacareto is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * General Public License for more details.
017: *
018: * You should have received a copy of the GNU General Public
019: * License along with Jacareto; if not, write to the Free
020: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021: *
022: */
023:
024: package jacareto.system;
025:
026: import org.apache.log4j.Logger;
027:
028: /**
029: * A superclass for all classes which are a members of a Jacareto environment. A member of an
030: * environment has access to the logger, the customization and the language instances contained in
031: * that environment. If an environment member wants to access the environment instances like the
032: * logger or the customization, the environment has to be specified before. There are two ways to
033: * set the environment for an environment member:
034: *
035: * <ul>
036: * <li>
037: * Call the constructor {@link #EnvironmentMember(Environment)} when creating the member.
038: * </li>
039: * <li>
040: * If you have called the constructor without the environment as argument, then call the method
041: * {@link #setEnvironment(Environment)} before you want to access the environment instances.
042: * </li>
043: * </ul>
044: *
045: * You may access the environment instances in a subclass by using one of the following ways:
046: *
047: * <ul>
048: * <li>
049: * <code>getEnvironment().getLogger()</code>
050: * </li>
051: * <li>
052: * <code>env.getLogger()</code>
053: * </li>
054: * <li>
055: * <code>getLogger()</code>
056: * </li>
057: * <li>
058: * <code>logger</code>
059: * </li>
060: * </ul>
061: *
062: * Just use the way you like most.
063: *
064: * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
065: * @version 1.00
066: */
067: public class EnvironmentMember {
068: /** The env this member belongs to. */
069: protected Environment env;
070:
071: /** The logger instance contained in the env. */
072: protected Logger logger;
073:
074: /** The customization instance contained in the env. */
075: protected Customization customization;
076:
077: /** The language instance contained in the env. */
078: protected Language language;
079:
080: /** The files instance contained in the env. */
081: protected Files files;
082:
083: /**
084: * Creates a new env member object with the specified env.
085: *
086: * @param env the Jacareto env
087: */
088: public EnvironmentMember(Environment env) {
089: setEnvironment(env);
090: }
091:
092: /**
093: * Creates a new env member of no env.
094: */
095: public EnvironmentMember() {
096: this (null);
097: }
098:
099: /**
100: * Changes the env of this member.
101: *
102: * @param env {@link Environment}
103: */
104: public void setEnvironment(Environment env) {
105: this .env = env;
106:
107: if (env != null) {
108: this .logger = env.getLogger();
109: this .customization = env.getCustomization();
110: this .language = env.getLanguage();
111: this .files = env.getFiles();
112: } else {
113: this .logger = null;
114: this .customization = null;
115: this .language = null;
116: this .files = null;
117: }
118: }
119:
120: /**
121: * Returns the member's env.
122: *
123: * @return DOCUMENT ME!
124: */
125: public Environment getEnvironment() {
126: return env;
127: }
128:
129: /**
130: * Returns the logger instance of the member's env.
131: *
132: * @return DOCUMENT ME!
133: */
134: public Logger getLogger() {
135: return logger;
136: }
137:
138: /**
139: * Returns the customization instance of the member's env.
140: *
141: * @return DOCUMENT ME!
142: */
143: public Customization getCustomization() {
144: return customization;
145: }
146:
147: /**
148: * Returns the language instance of the member's env.
149: *
150: * @return DOCUMENT ME!
151: */
152: public Language getLanguage() {
153: return language;
154: }
155:
156: /**
157: * returns the files instance of the member's env.
158: *
159: * @return DOCUMENT ME!
160: */
161: public Files getFiles() {
162: return files;
163: }
164: }
|