KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > DocletContext


1 /*
2  * Copyright (c) 2001, 2002 The XDoclet team
3  * All rights reserved.
4  */

5 package xdoclet;
6
7 import java.util.Collections JavaDoc;
8 import java.util.HashMap JavaDoc;
9 import java.util.Hashtable JavaDoc;
10 import java.util.Map JavaDoc;
11
12 /**
13  * @author Ara Abrahamian (ara_e@email.com)
14  * @created June 19, 2001
15  * @version $Revision: 1.17 $
16  */

17 public class DocletContext
18 {
19     private static DocletContext singleInstance = null;
20     private String JavaDoc destDir;
21     private String JavaDoc mergeDir;
22     private String JavaDoc excludedTags;
23     private SubTask[] subTasks;
24     private Hashtable JavaDoc properties;
25     private HashMap JavaDoc configs;
26     private boolean force;
27     private boolean verbose;
28     private String JavaDoc addedTags;
29     private Map JavaDoc unmodifiableProperties;
30     private SubTask activeSubTask;
31
32     /**
33      * Describe what the DocletContext constructor does
34      *
35      * @param destDir Describe what the parameter does
36      * @param mergeDir Describe what the parameter does
37      * @param excludedTags Describe what the parameter does
38      * @param subTasks Describe what the parameter does
39      * @param properties Describe what the parameter does
40      * @param configs Describe what the parameter does
41      * @param force Describe what the parameter does
42      * @param addedTags
43      * @param verbose
44      */

45     public DocletContext(
46         String JavaDoc destDir,
47         String JavaDoc mergeDir,
48         String JavaDoc excludedTags,
49         SubTask[] subTasks,
50         Hashtable JavaDoc properties,
51         HashMap JavaDoc configs,
52         boolean force,
53         boolean verbose,
54         String JavaDoc addedTags
55         )
56     {
57         this.destDir = destDir;
58         this.mergeDir = mergeDir;
59         this.excludedTags = excludedTags;
60         this.subTasks = subTasks;
61         this.properties = properties;
62         this.configs = configs;
63         this.force = force;
64         this.verbose = verbose;
65         this.addedTags = addedTags;
66     }
67
68     /**
69      * Gets the Instance attribute of the DocletContext class
70      *
71      * @return The Instance value
72      */

73     public static DocletContext getInstance()
74     {
75         return singleInstance;
76     }
77
78     /**
79      * Sets the SingleInstance attribute of the DocletContext class
80      *
81      * @param singleInstance The new SingleInstance value
82      */

83     public static void setSingleInstance(DocletContext singleInstance)
84     {
85         DocletContext.singleInstance = singleInstance;
86     }
87
88     /**
89      * Gets the ActiveSubTask attribute of the DocletContext object
90      *
91      * @return The ActiveSubTask value
92      */

93     public SubTask getActiveSubTask()
94     {
95         return activeSubTask;
96     }
97
98     /**
99      * Gets the DestDir attribute of the DocletContext object
100      *
101      * @return The DestDir value
102      */

103     public String JavaDoc getDestDir()
104     {
105         return destDir;
106     }
107
108     /**
109      * Gets the MergeDir attribute of the DocletContext object
110      *
111      * @return The MergeDir value
112      */

113     public String JavaDoc getMergeDir()
114     {
115         return mergeDir;
116     }
117
118     /**
119      * Gets the Force attribute of the DocletContext object.
120      *
121      * @return The Force value
122      */

123     public boolean isForce()
124     {
125         return force;
126     }
127
128     /**
129      * Gets the Verbose attribute of the DocletContext object.
130      *
131      * @return The Verbose value
132      */

133     public boolean isVerbose()
134     {
135         return verbose;
136     }
137
138     public String JavaDoc getAddedTags()
139     {
140         return addedTags;
141     }
142
143     /**
144      * Gets the ExcludedTags attribute of the DocletContext object
145      *
146      * @return The ExcludedTags value
147      */

148     public String JavaDoc getExcludedTags()
149     {
150         if (excludedTags == null) {
151             return "";
152         }
153         else {
154             return excludedTags;
155         }
156     }
157
158     /**
159      * Gets the SubTasks attribute of the DocletContext object
160      *
161      * @return The SubTasks value
162      */

163     public SubTask[] getSubTasks()
164     {
165         return subTasks;
166     }
167
168     /**
169      * Gets the Property attribute of the DocletContext object
170      *
171      * @param name Describe what the parameter does
172      * @return The Property value
173      */

174     public String JavaDoc getProperty(String JavaDoc name)
175     {
176         return (String JavaDoc) properties.get(name);
177     }
178
179     /**
180      * Gets the Properties attribute of the DocletContext object
181      *
182      * @return The Properties value
183      */

184     public Map JavaDoc getProperties()
185     {
186         // create one unmodifiableProperties instance and serve the world.
187
// It's a safe bet because there's no DocletContext.setProperty method
188
if (unmodifiableProperties == null) {
189             unmodifiableProperties = Collections.unmodifiableMap(properties);
190         }
191
192         return unmodifiableProperties;
193     }
194
195     /**
196      * Gets the ConfigParam attribute of the DocletContext object
197      *
198      * @param name Describe what the parameter does
199      * @return The ConfigParam value
200      */

201     public Object JavaDoc getConfigParam(String JavaDoc name)
202     {
203         return configs.get(name.toLowerCase());
204     }
205
206     /**
207      * Gets the SubTaskDefined attribute of the DocletContext object
208      *
209      * @param subtaskName Describe what the parameter does
210      * @return The SubTaskDefined value
211      */

212     public boolean isSubTaskDefined(String JavaDoc subtaskName)
213     {
214         return getSubTaskBy(subtaskName) != null;
215     }
216
217     /**
218      * Gets the SubTaskBy attribute of the DocletContext object
219      *
220      * @param subtaskName Describe what the parameter does
221      * @return The SubTaskBy value
222      */

223     public SubTask getSubTaskBy(String JavaDoc subtaskName)
224     {
225         for (int i = 0; i < subTasks.length; i++) {
226             if (subTasks[i] != null && subTasks[i].getSubTaskName().toLowerCase().equals(subtaskName.toLowerCase())) {
227                 return subTasks[i];
228             }
229         }
230
231         return null;
232     }
233
234     /**
235      * Sets the ActiveSubTask attribute of the DocletContext object
236      *
237      * @param activeSubTask The new ActiveSubTask value
238      */

239     public void setActiveSubTask(SubTask activeSubTask)
240     {
241         this.activeSubTask = activeSubTask;
242     }
243 }
244
Popular Tags