3 * Copyright 2004 The Ant-Contrib project
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 package net
.sf
.antcontrib
.cpptasks
;
19 import java
.io
.IOException
;
20 import java
.io
.Writer
;
22 import org
.apache
.tools
.ant
.BuildException
;
23 import org
.apache
.tools
.ant
.Project
;
24 import org
.apache
.tools
.ant
.types
.DataType
;
25 import org
.apache
.tools
.ant
.types
.Reference
;
28 * Version Information. (Non-functional prototype)
31 public class VersionInfo
extends DataType
{
35 private String ifCond
;
39 private String unlessCond
;
44 private String extendsId
;
50 private String fileVersion
;
55 private String productVersion
;
60 private String language
;
66 private String fileComments
;
71 private String companyName
;
76 private String description
;
80 private String internalName
;
85 private String legalCopyright
;
90 private String legalTrademark
;
95 private String originalFilename
;
100 private String privateBuild
;
105 private String productName
;
109 private String specialBuild
;
111 * compatibility version
114 private String compatibilityVersion
;
121 public VersionInfo() {
123 public void execute() throws org
.apache
.tools
.ant
.BuildException
{
124 throw new org
.apache
.tools
.ant
.BuildException(
125 "Not an actual task, but looks like one for documentation purposes");
128 * Returns true if the define's if and unless conditions (if any) are
131 * @exception BuildException
132 * throws build exception if name is not set
134 public final boolean isActive() throws BuildException
{
135 return CUtil
.isActive(getProject(), ifCond
, unlessCond
);
138 * Sets an id that can be used to reference this element.
143 public void setId(String id
) {
145 // this is actually accomplished by a different
146 // mechanism, but we can document it
150 * Sets the name of a version info that this info extends.
155 public void setExtends(String id
) {
161 * Sets the property name for the 'if' condition.
163 * The define will be ignored unless the property is defined.
165 * The value of the property is insignificant, but values that would imply
166 * misinterpretation ("false", "no") will throw an exception when
172 public final void setIf(String propName
) {
176 * Specifies that this element should behave as if the content of the
177 * element with the matching id attribute was inserted at this location. If
178 * specified, no other attributes should be specified.
181 public void setRefid(Reference r
) throws BuildException
{
185 * Set the property name for the 'unless' condition.
187 * If named property is set, the define will be ignored.
189 * The value of the property is insignificant, but values that would imply
190 * misinterpretation ("false", "no") of the behavior will throw an
191 * exception when evaluated.
196 public final void setUnless(String propName
) {
197 unlessCond
= propName
;
201 * @return file version, may be null.
204 public String
getFileversion() {
206 VersionInfo refVersion
= (VersionInfo
)
207 getCheckedRef(VersionInfo
.class,
209 return refVersion
.getFileversion();
214 * Gets Product version.
215 * @return product version, may be null
217 public String
getProductversion() {
219 VersionInfo refVersion
= (VersionInfo
)
220 getCheckedRef(VersionInfo
.class,
222 return refVersion
.getProductversion();
224 return productVersion
;
227 * Gets compatibility version.
228 * @return compatibility version, may be null
230 public String
getCompatibilityversion() {
232 VersionInfo refVersion
= (VersionInfo
)
233 getCheckedRef(VersionInfo
.class,
235 return refVersion
.getCompatibilityversion();
237 return compatibilityVersion
;
240 * Gets file language, should be an IETF RFC 3066 identifier, for example, en-US.
241 * @return language, may be null.
243 public String
getLanguage() {
245 VersionInfo refVersion
= (VersionInfo
)
246 getCheckedRef(VersionInfo
.class,
248 return refVersion
.getLanguage();
255 * @return comments, may be null.
257 public String
getFilecomments() {
259 VersionInfo refVersion
= (VersionInfo
)
260 getCheckedRef(VersionInfo
.class,
262 return refVersion
.getFilecomments();
268 * @return company name, may be null.
270 public String
getCompanyname() {
272 VersionInfo refVersion
= (VersionInfo
)
273 getCheckedRef(VersionInfo
.class,
275 return refVersion
.getCompanyname();
281 * @return description, may be null.
283 public String
getDescription() {
285 VersionInfo refVersion
= (VersionInfo
)
286 getCheckedRef(VersionInfo
.class,
288 return refVersion
.getDescription();
293 * Gets internal name.
294 * @return internal name, may be null.
296 public String
getInternalname() {
298 VersionInfo refVersion
= (VersionInfo
)
299 getCheckedRef(VersionInfo
.class,
301 return refVersion
.getInternalname();
306 * Gets legal copyright.
307 * @return legal copyright, may be null.
309 public String
getLegalcopyright() {
311 VersionInfo refVersion
= (VersionInfo
)
312 getCheckedRef(VersionInfo
.class,
314 return refVersion
.getLegalcopyright();
316 return legalCopyright
;
319 * Gets legal trademark.
320 * @return legal trademark, may be null;
322 public String
getLegaltrademark() {
324 VersionInfo refVersion
= (VersionInfo
)
325 getCheckedRef(VersionInfo
.class,
327 return refVersion
.getLegaltrademark();
329 return legalTrademark
;
332 * Gets original filename.
333 * @return original filename, may be null.
335 public String
getOriginalfilename() {
337 VersionInfo refVersion
= (VersionInfo
)
338 getCheckedRef(VersionInfo
.class,
340 return refVersion
.getOriginalfilename();
342 return originalFilename
;
345 * Gets private build.
346 * @return private build, may be null.
348 public String
getPrivatebuild() {
350 VersionInfo refVersion
= (VersionInfo
)
351 getCheckedRef(VersionInfo
.class,
353 return refVersion
.getPrivatebuild();
359 * @return product name, may be null.
361 public String
getProductname() {
363 VersionInfo refVersion
= (VersionInfo
)
364 getCheckedRef(VersionInfo
.class,
366 return refVersion
.getProductname();
372 * @return special build, may be null.
374 public String
getSpecialbuild() {
376 VersionInfo refVersion
= (VersionInfo
)
377 getCheckedRef(VersionInfo
.class,
379 return refVersion
.getSpecialbuild();
386 * @param value new value
387 * @throws BuildException if specified with refid
389 public void setFileversion(String value
) throws BuildException
{
391 throw tooManyAttributes();
396 * Sets product version.
397 * @param value new value
398 * @throws BuildException if specified with refid
400 public void setProductversion(String value
) throws BuildException
{
402 throw tooManyAttributes();
404 productVersion
= value
;
407 * Sets compatibility version.
408 * @param value new value
409 * @throws BuildException if specified with refid
411 public void setCompatibilityversion(String value
) throws BuildException
{
413 throw tooManyAttributes();
415 compatibilityVersion
= value
;
419 * @param value new value, should be an IETF RFC 3066 language identifier.
420 * @throws BuildException if specified with refid
422 public void setLanguage(String value
) throws BuildException
{
424 throw tooManyAttributes();
430 * @param value new value
431 * @throws BuildException if specified with refid
433 public void setFilecomments(String value
) throws BuildException
{
435 throw tooManyAttributes();
437 fileComments
= value
;
442 * @param value new value
443 * @throws BuildException if specified with refid
445 public void setCompanyname(String value
) throws BuildException
{
447 throw tooManyAttributes();
454 * Sets internal name. Internal name will automatically be
455 * specified from build step, only set this value if
456 * intentionally overriding that value.
458 * @param value new value
459 * @throws BuildException if specified with refid
461 public void setInternalname(String value
) throws BuildException
{
463 throw tooManyAttributes();
465 internalName
= value
;
469 * Sets legal copyright.
470 * @param value new value
471 * @throws BuildException if specified with refid
473 public void setLegalcopyright(String value
) throws BuildException
{
475 throw tooManyAttributes();
477 legalCopyright
= value
;
480 * Sets legal trademark.
481 * @param value new value
482 * @throws BuildException if specified with refid
484 public void setLegaltrademark(String value
) throws BuildException
{
486 throw tooManyAttributes();
488 legalTrademark
= value
;
491 * Sets original name. Only set this value if
492 * intentionally overriding the value from the build set.
494 * @param value new value
495 * @throws BuildException if specified with refid
497 public void setOriginalfilename(String value
) throws BuildException
{
499 throw tooManyAttributes();
501 originalFilename
= value
;
504 * Sets private build.
505 * @param value new value
506 * @throws BuildException if specified with refid
508 public void setPrivatebuild(String value
) throws BuildException
{
510 throw tooManyAttributes();
512 privateBuild
= value
;
516 * @param value new value
517 * @throws BuildException if specified with refid
519 public void setProductname(String value
) throws BuildException
{
521 throw tooManyAttributes();
526 * Sets private build.
527 * @param value new value
528 * @throws BuildException if specified with refid
530 public void setSpecialbuild(String value
) throws BuildException
{
532 throw tooManyAttributes();
534 specialBuild
= value
;
538 * Writes windows resource
539 * @param writer writer, may not be null.
540 * @param project project, may not be null
541 * @param executableName name of executable
543 public void writeResource(final Writer writer
,
545 final String executableName
) throws IOException
{