KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > examples > jet > article2 > codegen > Config


1 package org.eclipse.emf.examples.jet.article2.codegen;
2
3
4 import org.eclipse.core.runtime.Platform;
5
6
7 /**
8  * Meta-data for code generation.
9  *
10  * @author Remko Popma
11  * @version $Revision: 1.1 $ ($Date: 2004/05/31 21:35:35 $)
12  */

13 public class Config
14 {
15
16   private Object JavaDoc mModel;
17
18   private String JavaDoc mPluginId;
19
20   private String JavaDoc mClasspathVariable;
21
22   private String JavaDoc mTemplateRelativeUri;
23
24   private String JavaDoc mMergeXmlRelativeUri;
25
26   private String JavaDoc mTargetFolder;
27
28   private String JavaDoc mTargetFile;
29
30   private String JavaDoc mPackageName;
31
32   private boolean mForceOverwrite = true;
33
34   /**
35    * Constructs an uninitialized instance.
36    */

37   public Config()
38   {
39   }
40
41   /**
42    * Returns the model object to pass to the JET template.
43    *
44    * @return the model object to pass to the JET template
45    */

46   public Object JavaDoc getModel()
47   {
48     return mModel;
49   }
50
51   /**
52    * Sets the model object to pass to the JET template.
53    *
54    * @param the
55    * model object to pass to the JET template
56    */

57   public void setModel(Object JavaDoc object)
58   {
59     mModel = object;
60   }
61
62   /**
63    * Returns the plugin id of the plugin containing the JET template file, the
64    * JMerge control model XML file, and the runtime library JAR file containing
65    * any classes necessary to compile the translated JET template implementation
66    * class.
67    *
68    * @return the plugin id
69    */

70   public String JavaDoc getPluginId()
71   {
72     return mPluginId;
73   }
74
75   /**
76    * Sets the plugin id of the plugin containing the JET template file, the
77    * JMerge control model XML file, and the runtime library JAR file containing
78    * any classes necessary to compile the translated JET template implementation
79    * class.
80    *
81    * @param id
82    * the plugin id
83    */

84   public void setPluginId(String JavaDoc id)
85   {
86     mPluginId = id;
87   }
88
89   /**
90    * Returns the relative URI of the XML file containing the settings for the
91    * JMerge control model.
92    *
93    * @return the relative URI of the jmerge settings XML file
94    */

95   public String JavaDoc getMergeXmlRelativeUri()
96   {
97     return mMergeXmlRelativeUri;
98   }
99
100   /**
101    * Sets the relative URI of the XML file containing the settings for the
102    * JMerge control model.
103    *
104    * @param uri
105    * the relative URI of the jmerge settings XML file
106    */

107   public void setMergeXmlRelativeUri(String JavaDoc uri)
108   {
109     mMergeXmlRelativeUri = uri;
110   }
111
112   /**
113    * Returns the relative uri of the JET template file.
114    *
115    * @return the relative uri of the JET template file
116    */

117   public String JavaDoc getTemplateRelativeUri()
118   {
119     return mTemplateRelativeUri;
120   }
121
122   /**
123    * Returns the relative uri of the JET template file.
124    *
125    * @param uri
126    * the relative uri of the JET template file
127    */

128   public void setTemplateRelativeUri(String JavaDoc uri)
129   {
130     mTemplateRelativeUri = uri;
131   }
132
133   /**
134    * Returns the target folder (relative to the workspace root) where the
135    * generated code should be saved.
136    *
137    * @return the target folder (relative to the workspace root) where the
138    * generated code should be saved
139    */

140   public String JavaDoc getTargetFolder()
141   {
142     return mTargetFolder;
143   }
144
145   /**
146    * Sets the target folder (relative to the workspace root) where the generated
147    * code should be saved.
148    *
149    * @param folder
150    * the target folder (relative to the workspace root) where the
151    * generated code should be saved
152    */

153   public void setTargetFolder(String JavaDoc folder)
154   {
155     mTargetFolder = folder;
156   }
157
158   /**
159    * Returns the package name of the resource to generate.
160    *
161    * @return the package name of the resource to generate
162    */

163   public String JavaDoc getPackageName()
164   {
165     return mPackageName;
166   }
167
168   /**
169    * Sets the package name of the resource to generate.
170    *
171    * @param name
172    * the package name of the resource to generate
173    */

174   public void setPackageName(String JavaDoc name)
175   {
176     mPackageName = name;
177   }
178
179   /**
180    * Returns whether existing read-only files should be overwritten. This method
181    * returns <code>true</code> by default.
182    *
183    * @return whether existing read-only files should be overwritten
184    */

185   public boolean isForceOverwrite()
186   {
187     return mForceOverwrite;
188   }
189
190   /**
191    * Returns whether existing read-only files should be overwritten. This method
192    * returns <code>true</code> by default.
193    *
194    * @return whether existing read-only files should be overwritten
195    */

196   public void setForceOverwrite(boolean force)
197   {
198     mForceOverwrite = force;
199   }
200
201   /**
202    * Returns the full URI of the JET template. This URI is found by appending
203    * the relative template URI to the installation URI of the plugin specified
204    * by the {@link #getPluginId() plugin id}.
205    *
206    * @return the full URI of the JET template
207    */

208   public String JavaDoc getTemplateFullUri()
209   {
210     return getUri(getPluginId(), getTemplateRelativeUri());
211   }
212
213   /**
214    * Returns the full URI of the the XML file containing the settings for the
215    * JMerge control model. This URI is found by appending the relative merge XML
216    * URI to the installation URI of the plugin specified by the
217    * {@link #getPluginId() plugin id}.
218    *
219    * @return the full URI of the the XML file containing the settings for the
220    * JMerge control model
221    */

222   public String JavaDoc getMergeXmlFullUri()
223   {
224     return getUri(getPluginId(), getMergeXmlRelativeUri());
225   }
226
227   private String JavaDoc getUri(String JavaDoc pluginId, String JavaDoc relativeUri)
228   {
229     String JavaDoc base = Platform.getBundle(pluginId).getEntry("/").toString();
230     String JavaDoc result = base + relativeUri;
231     return result;
232   }
233
234   /**
235    * Returns the file name of the file where the generated code should be saved.
236    *
237    * @return the file name of the file where the generated code should be saved
238    */

239   public String JavaDoc getTargetFile()
240   {
241     return mTargetFile;
242   }
243
244   /**
245    * Sets the file name of the file where the generated code should be saved.
246    *
247    * @param name
248    * the file name of the file where the generated code should be saved
249    */

250   public void setTargetFile(String JavaDoc name)
251   {
252     mTargetFile = name;
253   }
254
255   /**
256    * Returns the classpath variable name to bind to the first jar in the plugin
257    * identified by {@link #getPluginId()}.
258    *
259    * @return classpath variable name
260    */

261   public String JavaDoc getClasspathVariable()
262   {
263     return mClasspathVariable;
264   }
265
266   /**
267    * Sets the classpath variable name to bind to the first jar in the plugin
268    * identified by {@link #getPluginId()}.
269    *
270    * @param name
271    * classpath variable name
272    */

273   public void setClasspathVariable(String JavaDoc name)
274   {
275     mClasspathVariable = name;
276   }
277
278 }
Popular Tags