KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > launcher > parser > ContextDescription


1 /*====================================================================
2
3 ObjectWeb Util Launcher Package.
4 Copyright (C) 2004 INRIA & USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Romain Rouvoy.
23 Contributor(s): .
24
25 --------------------------------------------------------------------
26 $Id: ContextDescription.java,v 1.1 2004/05/19 15:58:29 rouvoy Exp $
27 ====================================================================*/

28
29 package org.objectweb.util.launcher.parser ;
30
31
32 import java.util.Properties JavaDoc ;
33
34 import org.objectweb.util.launcher.StringList ;
35 import org.objectweb.util.trace.TraceSystem;
36
37
38 /**
39  * Representation of an context.<BR>
40  * <p>
41  * An context describe additionnal informations on an application.
42  * It contains:
43  * <li>
44  * <ul>an identifier</ul>
45  * <ul>a list of arguments</ul>
46  * <ul>a list of properties</ul>
47  * <ul>a list of Java classes</ul>
48  * </li>
49  * </p>
50  *
51  * @author <a HREF="mailto:Romain.Rouvoy@lifl.fr">Romain Rouvoy</a>
52  * @version 0.1
53  */

54 public class ContextDescription
55 {
56     /** The name of the context. */
57     protected String JavaDoc name_ ;
58
59     /** The arguments list. */
60     protected StringList arguments_;
61
62     /** The properties list. */
63     protected Properties JavaDoc properties_;
64
65     /** The class list. */
66     protected StringList classpath_ ;
67     
68     /** The description list. */
69     protected StringList descriptions_;
70
71     /**
72      * Default Constructor.
73      */

74     public ContextDescription() {
75         this.arguments_ = new StringList();
76         this.classpath_ = new StringList();
77         this.properties_ = new Properties JavaDoc();
78         this.descriptions_ = new StringList();
79     }
80
81
82     /**
83      * Defines the identifer of the context.
84      *
85      * @param name identifier of the context.
86      */

87     public void setName(String JavaDoc name) {
88         TraceSystem.get("description").debug("Setting name: \""+name+"\"");
89         name_ = name;
90     }
91
92     /**
93      * Provides the identifier of the context.
94      *
95      * @return identifier of the context.
96      */

97     public String JavaDoc getName() {
98         return name_;
99     }
100
101
102     /**
103      * Adds an argument in the content of the context.
104      *
105      * @param arg argument to add.
106      */

107     public void addArgument(String JavaDoc arg) {
108         TraceSystem.get("description").debug("Adding argument: \""+arg+"\"");
109         arguments_.add(arg);
110     }
111     
112     /**
113      * Provides the list of arguments for the context.
114      *
115      * @return the list of arguments.
116      */

117     public StringList getArguments() {
118         return arguments_;
119     }
120
121     
122     /**
123      * Adds a property in the content of the context.
124      *
125      * @param key the key of the property.
126      * @param value the value of the property.
127      */

128     public void addProperty(String JavaDoc key, String JavaDoc value) {
129         TraceSystem.get("description").debug("Adding property: \""+key+"\"=\""+value+"\"");
130         properties_.put(key,value);
131         System.getProperties().put(key,value);
132     }
133     
134     /**
135      * Provides the list of properties for the context.
136      *
137      * @return the list of Java Properties.
138      */

139     public Properties JavaDoc getProperties() {
140         return properties_;
141     }
142
143     /**
144      * Adds an element in the classpath of the context.
145      *
146      * @param classname the name of the class to add.
147      */

148     public void addClass(String JavaDoc classname) {
149         TraceSystem.get("description").debug("Adding class: \""+classname+"\"");
150         classpath_.add(classname);
151     }
152
153     /**
154      * Provides the list of classes considered by the context.
155      *
156      * @return the list of classes to load.
157      */

158     public StringList getClasses() {
159         return classpath_;
160     }
161     
162     /**
163      * Adds the identifier of a loaded description.
164      * @param desc the description to add.
165      */

166     public void addDescription(String JavaDoc desc) {
167         if (checkDescription(desc))
168             TraceSystem.get("description").debug("Description"+desc+" has still been loaded!");
169         else
170             descriptions_.add(desc);
171     }
172     
173     /**
174      * Checks if the description have still been loaded for this context (true if loaded).
175      * @param desc the description to check.
176      * @return true if the description desc have still been added.
177      */

178     public boolean checkDescription(String JavaDoc desc) {
179         return descriptions_.contains(desc);
180     }
181 }
182
Popular Tags