]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /*\r |
2 | * \r | |
3 | * Copyright 2004 The Ant-Contrib project\r | |
4 | *\r | |
5 | * Licensed under the Apache License, Version 2.0 (the "License");\r | |
6 | * you may not use this file except in compliance with the License.\r | |
7 | * You may obtain a copy of the License at\r | |
8 | *\r | |
9 | * http://www.apache.org/licenses/LICENSE-2.0\r | |
10 | *\r | |
11 | * Unless required by applicable law or agreed to in writing, software\r | |
12 | * distributed under the License is distributed on an "AS IS" BASIS,\r | |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r | |
14 | * See the License for the specific language governing permissions and\r | |
15 | * limitations under the License.\r | |
16 | */\r | |
17 | package net.sf.antcontrib.cpptasks;\r | |
18 | \r | |
19 | import java.io.IOException;\r | |
20 | import java.io.Writer;\r | |
21 | \r | |
22 | import org.apache.tools.ant.BuildException;\r | |
23 | import org.apache.tools.ant.Project;\r | |
24 | import org.apache.tools.ant.types.DataType;\r | |
25 | import org.apache.tools.ant.types.Reference;\r | |
26 | \r | |
27 | /**\r | |
28 | * Version Information. (Non-functional prototype)\r | |
29 | * \r | |
30 | */\r | |
31 | public class VersionInfo extends DataType {\r | |
32 | /**\r | |
33 | * if property.\r | |
34 | */\r | |
35 | private String ifCond;\r | |
36 | /**\r | |
37 | * unless property.\r | |
38 | */\r | |
39 | private String unlessCond;\r | |
40 | \r | |
41 | /**\r | |
42 | * extends property.\r | |
43 | */\r | |
44 | private String extendsId;\r | |
45 | \r | |
46 | /**\r | |
47 | * file version.\r | |
48 | *\r | |
49 | */\r | |
50 | private String fileVersion;\r | |
51 | /**\r | |
52 | * Product version.\r | |
53 | *\r | |
54 | */\r | |
55 | private String productVersion;\r | |
56 | /**\r | |
57 | * file language.\r | |
58 | *\r | |
59 | */\r | |
60 | private String language;\r | |
61 | \r | |
62 | /**\r | |
63 | * comments.\r | |
64 | *\r | |
65 | */\r | |
66 | private String fileComments;\r | |
67 | /**\r | |
68 | * Company name.\r | |
69 | *\r | |
70 | */\r | |
71 | private String companyName;\r | |
72 | /**\r | |
73 | * Description.\r | |
74 | *\r | |
75 | */\r | |
76 | private String description;\r | |
77 | /**\r | |
78 | * internal name.\r | |
79 | */\r | |
80 | private String internalName;\r | |
81 | /**\r | |
82 | * legal copyright.\r | |
83 | *\r | |
84 | */\r | |
85 | private String legalCopyright;\r | |
86 | /**\r | |
87 | * legal trademark.\r | |
88 | *\r | |
89 | */\r | |
90 | private String legalTrademark;\r | |
91 | /**\r | |
92 | * original filename.\r | |
93 | *\r | |
94 | */\r | |
95 | private String originalFilename;\r | |
96 | /**\r | |
97 | * private build.\r | |
98 | *\r | |
99 | */\r | |
100 | private String privateBuild;\r | |
101 | /**\r | |
102 | * product name.\r | |
103 | *\r | |
104 | */\r | |
105 | private String productName;\r | |
106 | /**\r | |
107 | * Special build\r | |
108 | */\r | |
109 | private String specialBuild;\r | |
110 | /**\r | |
111 | * compatibility version\r | |
112 | *\r | |
113 | */\r | |
114 | private String compatibilityVersion;\r | |
115 | \r | |
116 | \r | |
117 | /**\r | |
118 | * Constructor.\r | |
119 | *\r | |
120 | */\r | |
121 | public VersionInfo() {\r | |
122 | }\r | |
123 | public void execute() throws org.apache.tools.ant.BuildException {\r | |
124 | throw new org.apache.tools.ant.BuildException(\r | |
125 | "Not an actual task, but looks like one for documentation purposes");\r | |
126 | }\r | |
127 | /**\r | |
128 | * Returns true if the define's if and unless conditions (if any) are\r | |
129 | * satisfied.\r | |
130 | * \r | |
131 | * @exception BuildException\r | |
132 | * throws build exception if name is not set\r | |
133 | */\r | |
134 | public final boolean isActive() throws BuildException {\r | |
135 | return CUtil.isActive(getProject(), ifCond, unlessCond);\r | |
136 | }\r | |
137 | /**\r | |
138 | * Sets an id that can be used to reference this element.\r | |
139 | * \r | |
140 | * @param id\r | |
141 | * id\r | |
142 | */\r | |
143 | public void setId(String id) {\r | |
144 | //\r | |
145 | // this is actually accomplished by a different\r | |
146 | // mechanism, but we can document it\r | |
147 | //\r | |
148 | }\r | |
149 | /**\r | |
150 | * Sets the name of a version info that this info extends.\r | |
151 | * \r | |
152 | * @param id\r | |
153 | * id\r | |
154 | */\r | |
155 | public void setExtends(String id) {\r | |
156 | extendsId = id;\r | |
157 | }\r | |
158 | \r | |
159 | \r | |
160 | /**\r | |
161 | * Sets the property name for the 'if' condition.\r | |
162 | * \r | |
163 | * The define will be ignored unless the property is defined.\r | |
164 | * \r | |
165 | * The value of the property is insignificant, but values that would imply\r | |
166 | * misinterpretation ("false", "no") will throw an exception when\r | |
167 | * evaluated.\r | |
168 | * \r | |
169 | * @param propName\r | |
170 | * property name\r | |
171 | */\r | |
172 | public final void setIf(String propName) {\r | |
173 | ifCond = propName;\r | |
174 | }\r | |
175 | /**\r | |
176 | * Specifies that this element should behave as if the content of the\r | |
177 | * element with the matching id attribute was inserted at this location. If\r | |
178 | * specified, no other attributes should be specified.\r | |
179 | * \r | |
180 | */\r | |
181 | public void setRefid(Reference r) throws BuildException {\r | |
182 | super.setRefid(r);\r | |
183 | }\r | |
184 | /**\r | |
185 | * Set the property name for the 'unless' condition.\r | |
186 | * \r | |
187 | * If named property is set, the define will be ignored.\r | |
188 | * \r | |
189 | * The value of the property is insignificant, but values that would imply\r | |
190 | * misinterpretation ("false", "no") of the behavior will throw an\r | |
191 | * exception when evaluated.\r | |
192 | * \r | |
193 | * @param propName\r | |
194 | * name of property\r | |
195 | */\r | |
196 | public final void setUnless(String propName) {\r | |
197 | unlessCond = propName;\r | |
198 | }\r | |
199 | /**\r | |
200 | * Gets file version.\r | |
201 | * @return file version, may be null.\r | |
202 | *\r | |
203 | */\r | |
204 | public String getFileversion() {\r | |
205 | if (isReference()) {\r | |
206 | VersionInfo refVersion = (VersionInfo) \r | |
207 | getCheckedRef(VersionInfo.class,\r | |
208 | "VersionInfo");\r | |
209 | return refVersion.getFileversion();\r | |
210 | }\r | |
211 | return fileVersion;\r | |
212 | }\r | |
213 | /**\r | |
214 | * Gets Product version.\r | |
215 | * @return product version, may be null\r | |
216 | */\r | |
217 | public String getProductversion() {\r | |
218 | if (isReference()) {\r | |
219 | VersionInfo refVersion = (VersionInfo) \r | |
220 | getCheckedRef(VersionInfo.class,\r | |
221 | "VersionInfo");\r | |
222 | return refVersion.getProductversion();\r | |
223 | }\r | |
224 | return productVersion;\r | |
225 | }\r | |
226 | /**\r | |
227 | * Gets compatibility version.\r | |
228 | * @return compatibility version, may be null\r | |
229 | */\r | |
230 | public String getCompatibilityversion() {\r | |
231 | if (isReference()) {\r | |
232 | VersionInfo refVersion = (VersionInfo) \r | |
233 | getCheckedRef(VersionInfo.class,\r | |
234 | "VersionInfo");\r | |
235 | return refVersion.getCompatibilityversion();\r | |
236 | }\r | |
237 | return compatibilityVersion;\r | |
238 | }\r | |
239 | /**\r | |
240 | * Gets file language, should be an IETF RFC 3066 identifier, for example, en-US.\r | |
241 | * @return language, may be null.\r | |
242 | */\r | |
243 | public String getLanguage() {\r | |
244 | if (isReference()) {\r | |
245 | VersionInfo refVersion = (VersionInfo) \r | |
246 | getCheckedRef(VersionInfo.class,\r | |
247 | "VersionInfo");\r | |
248 | return refVersion.getLanguage();\r | |
249 | }\r | |
250 | return language;\r | |
251 | }\r | |
252 | \r | |
253 | /**\r | |
254 | * Gets comments.\r | |
255 | * @return comments, may be null.\r | |
256 | */\r | |
257 | public String getFilecomments() {\r | |
258 | if (isReference()) {\r | |
259 | VersionInfo refVersion = (VersionInfo) \r | |
260 | getCheckedRef(VersionInfo.class,\r | |
261 | "VersionInfo");\r | |
262 | return refVersion.getFilecomments();\r | |
263 | }\r | |
264 | return fileComments;\r | |
265 | }\r | |
266 | /**\r | |
267 | * Gets Company name.\r | |
268 | * @return company name, may be null.\r | |
269 | */\r | |
270 | public String getCompanyname() {\r | |
271 | if (isReference()) {\r | |
272 | VersionInfo refVersion = (VersionInfo) \r | |
273 | getCheckedRef(VersionInfo.class,\r | |
274 | "VersionInfo");\r | |
275 | return refVersion.getCompanyname();\r | |
276 | }\r | |
277 | return companyName;\r | |
278 | }\r | |
279 | /**\r | |
280 | * Gets Description.\r | |
281 | * @return description, may be null.\r | |
282 | */\r | |
283 | public String getDescription() {\r | |
284 | if (isReference()) {\r | |
285 | VersionInfo refVersion = (VersionInfo) \r | |
286 | getCheckedRef(VersionInfo.class,\r | |
287 | "VersionInfo");\r | |
288 | return refVersion.getDescription();\r | |
289 | }\r | |
290 | return description;\r | |
291 | }\r | |
292 | /**\r | |
293 | * Gets internal name.\r | |
294 | * @return internal name, may be null.\r | |
295 | */\r | |
296 | public String getInternalname() {\r | |
297 | if (isReference()) {\r | |
298 | VersionInfo refVersion = (VersionInfo) \r | |
299 | getCheckedRef(VersionInfo.class,\r | |
300 | "VersionInfo");\r | |
301 | return refVersion.getInternalname();\r | |
302 | }\r | |
303 | return internalName;\r | |
304 | }\r | |
305 | /**\r | |
306 | * Gets legal copyright.\r | |
307 | * @return legal copyright, may be null.\r | |
308 | */\r | |
309 | public String getLegalcopyright() {\r | |
310 | if (isReference()) {\r | |
311 | VersionInfo refVersion = (VersionInfo) \r | |
312 | getCheckedRef(VersionInfo.class,\r | |
313 | "VersionInfo");\r | |
314 | return refVersion.getLegalcopyright();\r | |
315 | }\r | |
316 | return legalCopyright;\r | |
317 | }\r | |
318 | /**\r | |
319 | * Gets legal trademark.\r | |
320 | * @return legal trademark, may be null;\r | |
321 | */\r | |
322 | public String getLegaltrademark() {\r | |
323 | if (isReference()) {\r | |
324 | VersionInfo refVersion = (VersionInfo) \r | |
325 | getCheckedRef(VersionInfo.class,\r | |
326 | "VersionInfo");\r | |
327 | return refVersion.getLegaltrademark();\r | |
328 | }\r | |
329 | return legalTrademark;\r | |
330 | }\r | |
331 | /**\r | |
332 | * Gets original filename.\r | |
333 | * @return original filename, may be null.\r | |
334 | */\r | |
335 | public String getOriginalfilename() {\r | |
336 | if (isReference()) {\r | |
337 | VersionInfo refVersion = (VersionInfo) \r | |
338 | getCheckedRef(VersionInfo.class,\r | |
339 | "VersionInfo");\r | |
340 | return refVersion.getOriginalfilename();\r | |
341 | }\r | |
342 | return originalFilename;\r | |
343 | }\r | |
344 | /**\r | |
345 | * Gets private build.\r | |
346 | * @return private build, may be null.\r | |
347 | */\r | |
348 | public String getPrivatebuild() {\r | |
349 | if (isReference()) {\r | |
350 | VersionInfo refVersion = (VersionInfo) \r | |
351 | getCheckedRef(VersionInfo.class,\r | |
352 | "VersionInfo");\r | |
353 | return refVersion.getPrivatebuild();\r | |
354 | }\r | |
355 | return privateBuild;\r | |
356 | }\r | |
357 | /**\r | |
358 | * Gets product name.\r | |
359 | * @return product name, may be null.\r | |
360 | */\r | |
361 | public String getProductname() {\r | |
362 | if (isReference()) {\r | |
363 | VersionInfo refVersion = (VersionInfo) \r | |
364 | getCheckedRef(VersionInfo.class,\r | |
365 | "VersionInfo");\r | |
366 | return refVersion.getProductname();\r | |
367 | }\r | |
368 | return productName;\r | |
369 | }\r | |
370 | /**\r | |
371 | * Special build\r | |
372 | * @return special build, may be null.\r | |
373 | */\r | |
374 | public String getSpecialbuild() {\r | |
375 | if (isReference()) {\r | |
376 | VersionInfo refVersion = (VersionInfo) \r | |
377 | getCheckedRef(VersionInfo.class,\r | |
378 | "VersionInfo");\r | |
379 | return refVersion.getSpecialbuild();\r | |
380 | }\r | |
381 | return specialBuild;\r | |
382 | }\r | |
383 | \r | |
384 | /**\r | |
385 | * Sets file version.\r | |
386 | * @param value new value\r | |
387 | * @throws BuildException if specified with refid\r | |
388 | */\r | |
389 | public void setFileversion(String value) throws BuildException {\r | |
390 | if (isReference()) {\r | |
391 | throw tooManyAttributes();\r | |
392 | }\r | |
393 | fileVersion = value;\r | |
394 | }\r | |
395 | /**\r | |
396 | * Sets product version.\r | |
397 | * @param value new value\r | |
398 | * @throws BuildException if specified with refid\r | |
399 | */\r | |
400 | public void setProductversion(String value) throws BuildException {\r | |
401 | if (isReference()) {\r | |
402 | throw tooManyAttributes();\r | |
403 | }\r | |
404 | productVersion = value;\r | |
405 | }\r | |
406 | /**\r | |
407 | * Sets compatibility version.\r | |
408 | * @param value new value\r | |
409 | * @throws BuildException if specified with refid\r | |
410 | */\r | |
411 | public void setCompatibilityversion(String value) throws BuildException {\r | |
412 | if (isReference()) {\r | |
413 | throw tooManyAttributes();\r | |
414 | }\r | |
415 | compatibilityVersion = value;\r | |
416 | }\r | |
417 | /**\r | |
418 | * Sets language.\r | |
419 | * @param value new value, should be an IETF RFC 3066 language identifier.\r | |
420 | * @throws BuildException if specified with refid\r | |
421 | */\r | |
422 | public void setLanguage(String value) throws BuildException {\r | |
423 | if (isReference()) {\r | |
424 | throw tooManyAttributes();\r | |
425 | }\r | |
426 | language = value;\r | |
427 | }\r | |
428 | /**\r | |
429 | * Sets comments.\r | |
430 | * @param value new value\r | |
431 | * @throws BuildException if specified with refid\r | |
432 | */\r | |
433 | public void setFilecomments(String value) throws BuildException {\r | |
434 | if (isReference()) {\r | |
435 | throw tooManyAttributes();\r | |
436 | }\r | |
437 | fileComments = value;\r | |
438 | }\r | |
439 | \r | |
440 | /**\r | |
441 | * Sets company name.\r | |
442 | * @param value new value\r | |
443 | * @throws BuildException if specified with refid\r | |
444 | */\r | |
445 | public void setCompanyname(String value) throws BuildException {\r | |
446 | if (isReference()) {\r | |
447 | throw tooManyAttributes();\r | |
448 | }\r | |
449 | companyName = value;\r | |
450 | }\r | |
451 | \r | |
452 | \r | |
453 | /**\r | |
454 | * Sets internal name. Internal name will automatically be\r | |
455 | * specified from build step, only set this value if\r | |
456 | * intentionally overriding that value.\r | |
457 | * \r | |
458 | * @param value new value\r | |
459 | * @throws BuildException if specified with refid\r | |
460 | */\r | |
461 | public void setInternalname(String value) throws BuildException {\r | |
462 | if (isReference()) {\r | |
463 | throw tooManyAttributes();\r | |
464 | }\r | |
465 | internalName = value;\r | |
466 | }\r | |
467 | \r | |
468 | /**\r | |
469 | * Sets legal copyright.\r | |
470 | * @param value new value\r | |
471 | * @throws BuildException if specified with refid\r | |
472 | */\r | |
473 | public void setLegalcopyright(String value) throws BuildException {\r | |
474 | if (isReference()) {\r | |
475 | throw tooManyAttributes();\r | |
476 | }\r | |
477 | legalCopyright = value;\r | |
478 | }\r | |
479 | /**\r | |
480 | * Sets legal trademark.\r | |
481 | * @param value new value\r | |
482 | * @throws BuildException if specified with refid\r | |
483 | */\r | |
484 | public void setLegaltrademark(String value) throws BuildException {\r | |
485 | if (isReference()) {\r | |
486 | throw tooManyAttributes();\r | |
487 | }\r | |
488 | legalTrademark = value;\r | |
489 | }\r | |
490 | /**\r | |
491 | * Sets original name. Only set this value if\r | |
492 | * intentionally overriding the value from the build set.\r | |
493 | * \r | |
494 | * @param value new value\r | |
495 | * @throws BuildException if specified with refid\r | |
496 | */\r | |
497 | public void setOriginalfilename(String value) throws BuildException {\r | |
498 | if (isReference()) {\r | |
499 | throw tooManyAttributes();\r | |
500 | }\r | |
501 | originalFilename = value;\r | |
502 | }\r | |
503 | /**\r | |
504 | * Sets private build.\r | |
505 | * @param value new value\r | |
506 | * @throws BuildException if specified with refid\r | |
507 | */\r | |
508 | public void setPrivatebuild(String value) throws BuildException {\r | |
509 | if (isReference()) {\r | |
510 | throw tooManyAttributes();\r | |
511 | }\r | |
512 | privateBuild = value;\r | |
513 | }\r | |
514 | /**\r | |
515 | * Sets product name.\r | |
516 | * @param value new value\r | |
517 | * @throws BuildException if specified with refid\r | |
518 | */\r | |
519 | public void setProductname(String value) throws BuildException {\r | |
520 | if (isReference()) {\r | |
521 | throw tooManyAttributes();\r | |
522 | }\r | |
523 | productName= value;\r | |
524 | }\r | |
525 | /**\r | |
526 | * Sets private build.\r | |
527 | * @param value new value\r | |
528 | * @throws BuildException if specified with refid\r | |
529 | */\r | |
530 | public void setSpecialbuild(String value) throws BuildException {\r | |
531 | if (isReference()) {\r | |
532 | throw tooManyAttributes();\r | |
533 | }\r | |
534 | specialBuild = value;\r | |
535 | }\r | |
536 | \r | |
537 | /**\r | |
538 | * Writes windows resource \r | |
539 | * @param writer writer, may not be null.\r | |
540 | * @param project project, may not be null\r | |
541 | * @param executableName name of executable\r | |
542 | */\r | |
543 | public void writeResource(final Writer writer, \r | |
544 | final Project p, \r | |
545 | final String executableName) throws IOException {\r | |
546 | // TODO:\r | |
547 | \r | |
548 | }\r | |
549 | \r | |
550 | }\r |