aboutsummaryrefslogtreecommitdiffstats
path: root/build-tools/VersionInfo.java
blob: 3450fc568784298d272eced6c358f9834bb9cba3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
/*
 * $RCSfile$
 *
 * Copyright (c) 2004 Sun Microsystems, Inc. All rights reserved.
 *
 * Use is subject to license terms.
 *
 * $Revision$
 * $Date$
 * $State$
 */

package javax.media.j3d;

/**
 * The VersionInfo class contains strings that describe the implementation
 * and specification version of Java 3D.  These strings are made available
 * as properties obtained from the VirtualUniverse class.
 *
 * <h4>NOTE TO DEVELOPERS:</h4>
 *
 * <p>
 * Developers are required to do the following whenever they modify
 * Java 3D:
 *
 * <ol>
 * <li>The VENDOR_DEVELOPER string must be modified to
 * indicate the name of the individuals or organizations who have
 * modified the source code.</li>
 *
 * <li>The VERSION_DEV_STRING may be modified to indicate
 * additional information about the particular build, but this is
 * not required.</li>
 *
 * <li>The strings denoted as being unmodifiable must <i>not</i> be
 * modified.</li>
 * </ol>
 *
 * <p>
 * The tags of the form @STRING@ are populated by ant when the project is built
 *
 * <p>
 * Additionally, developers are required to comply with the terms
 * of the Java 3D API specification, which prohibits releasing an
 * implementation of the Java 3D API without first licensing and
 * passing the TCK tests.
 *
 * @see VirtualUniverse#getProperties
 */
class VersionInfo extends Object {
    /**
     * Developer who has modified Java 3D.
     * This string <i>must</i> be modified to indicate the name of the
     * individual(s) or organization(s) who modified the code.
     */
    private static final String VENDOR_DEVELOPER = null;


    /**
     * An optional string appended to the end of the version string,
     * after the time stamp.  A space will be automatically prepended
     * to this string.  This string should be null if no dev string is
     * desired.
     */
    private static final String VERSION_DEV_STRING = null;

    // -------------------------------------------------------------------
    // -------------------------------------------------------------------
    // END OF DEVELOPER-MODIFIABLE PARAMETERS
    // -------------------------------------------------------------------
    // -------------------------------------------------------------------


    // -------------------------------------------------------------------
    // The following set of constants must not be modified by developers.
    //
    // Only qualified licensees of the Java 3D API specification and
    // TCK tests, who are releasing their own implementation of Java 3D
    // are permitted to change these constants.
    // -------------------------------------------------------------------

    /**
     * Constant that indicates whether or not this is a debug build.
     */
    static final boolean isDebug = @IS_DEBUG@;

    /**
     * This static final variable is used to enable debugging and
     * assertion checking during the development phase of a particular
     * version of Java 3D. It is disabled for "opt" production builds
     * (beta, release candidate, fcs, and patch builds). It is enabled
     * for all "debug" builds and for daily and stable "opt" builds.
     *
     * <p>
     * This parameter is controlled by ant via the build.xml file. The
     * default value is true.
     */
    static final boolean isDevPhase = @IS_DEV_PHASE@;

    /**
     * This static final variable is used indicate a production
     * (beta, release candidate, fcs, or patch) build.
     * <p>
     * This parameter is controlled by ant via the build.xml file. The
     * default value is false.
     */
    static final boolean isProduction = @IS_PRODUCTION@;

    /**
     * If this flag is set to true, the verbose buildtime string
     * will be appended to the version string)
     * <p>
     * This parameter is controlled by ant via the build.xml file. The
     * default value is true.
     */
    private static final boolean useVerboseBuildTime = @USE_VERBOSE_BUILDTIME@;

    /**
     * String identifying the type of  Java 3D build, one of:
     * "daily", "stable", "beta", "fcs", or "patch". The default value
     * is "daily".
     */
    private static final String BUILD_TYPE = "@BUILD_TYPE@";

    /**
     * String identifying the build number of Java 3D in the format
     * "buildNN", where "NN" is the sequential build number, for
     * example, build47.  This string contain only letters and
     * numbers, It must not contain any other characters or spaces.
     *
     * For production builds, this string appears parenthetically,
     * after the first space.
     */
    private static final String VERSION_BUILD = "@VERSION_BUILD@";

    /**
     * String identifying the particular build of Java 3D, for
     * example, "-beta1", "-build47", "-rc1", "_01", etc. Note that
     * this includes the leading dash or underscore. It will typically
     * be empty for FCS builds. This string may only contain letters,
     * numbers, periods, dashes, or underscores. It must not contain
     * any other characters or spaces.
     *
     * This us used as part of the j3d.version that appears before the
     * optional first space.
     */
    private static final String VERSION_SUFFIX = "@VERSION_SUFFIX@";

    /**
     * Date stamp
     *
     * This is only used for daily builds.
     */
    private static final String BUILDTIME = "@BUILDTIME@";

    /**
     * Specification version (major and minor version only). This
     * string must not be modified by developers.
     */
    private static final String SPECIFICATION_VERSION = "1.3";

    /**
     * Specification vendor. This should never change and must not
     * be modified by developers.
     */
    private static final String SPECIFICATION_VENDOR = "Sun Microsystems, Inc.";

    /**
     * Primary implementation vendor. This should only be changed by a
     * platform vendor who has licensed the TCK tests and who is
     * releasing their own implementation of Java 3D.
     */
    private static final String VENDOR_PRIMARY = "Sun Microsystems, Inc.";

    /**
     * Base version number.  This is the major.minor.subminor version
     * number.  Version qualifiers are specified separately.  The
     * major and minor version <i>must</i> be the same as the specification
     * version.
     */
    private static final String VERSION_BASE = "@VERSION_BASE@";

    /**
     * Boolean flag indicating that the version of Java 3D is
     * experimental.  This must <i>not</i> be modified by developers.
     * All non-official builds <i>must</i> contain the string
     * <code>"experimental"</code> as part of the release name that
     * appears before the optional first space.
     */
    private static final boolean isExperimental = !isProduction;

    /**
     * The composite version string.  This is composed in the static
     * initializer for this class.
     */
    private static final String VERSION;

    /**
     * The composite vendor string.  This is composed in the static
     * initializer for this class.
     */
    private static final String VENDOR;

    /**
     * Build type string, one of "fcs", "fcs-patch", or "", that is
     * appended to the end of the version string after the build
     * identifier (and after the first space, which will automatically
     * be added) and before the optional verbose time and date stamp.
     */
    private static final String BUILD_QUALIFIER = "@BUILD_QUALIFIER@";

    /**
     * Verbose time and date stamp appended to the end of the version string.
     * This is appended to the version string
     * after the build identifier (and after the first space, which
     * will automatically be added) and before the optional dev
     * string.  This string is only used for non-fcs builds.
     */
    private static final String BUILDTIME_VERBOSE = "@BUILDTIME_VERBOSE@";

    private static boolean isNonEmpty(String str) {
	if ((str == null) || (str.length() == 0)) {
	    return false;
	}
	else {
	    return true;
	}
    }

    // The static initializer composes the version and vendor strings
    static {
	final boolean isPatchBuild = BUILD_TYPE.equals("patch");
	final boolean isFcsBuild = BUILD_TYPE.equals("fcs");
	final boolean isBetaBuild = BUILD_TYPE.equals("beta");
	final boolean isStableBuild = BUILD_TYPE.equals("stable");
	final boolean isDailyBuild = BUILD_TYPE.equals("daily");

	// Assign the vendor by concatenating primary and developer
	// vendor strings
	String tmpVendor = VENDOR_PRIMARY;
	if (isNonEmpty(VENDOR_DEVELOPER)) {
	    tmpVendor += " & " + VENDOR_DEVELOPER;
	}

	String tmpVersion = VERSION_BASE;
	if (isNonEmpty(VERSION_SUFFIX)) {
	    if (isPatchBuild) {
		tmpVersion += "_";
	    }
	    else {
		tmpVersion += "-";
	    }
	    tmpVersion += VERSION_SUFFIX;
	}

	if (isDailyBuild && isNonEmpty(BUILDTIME)) {
	    tmpVersion += "-" + BUILDTIME;
	}

	if (isExperimental) {
	    tmpVersion += "-experimental";
	}

	// Append the optional fields that follow the first space

	if (isProduction) {
	    if (isFcsBuild) {
		tmpVersion += " fcs";
	    }
	    else if (isPatchBuild) {
		tmpVersion += " fcs+patch";
	    }

	    if (isNonEmpty(VERSION_BUILD)) {
		tmpVersion += " (" + VERSION_BUILD + ")";
	    }
	}

	if (useVerboseBuildTime && isNonEmpty(BUILDTIME_VERBOSE)) {
	    tmpVersion += " " + BUILDTIME_VERBOSE;
	}

	if (isNonEmpty(VERSION_DEV_STRING)) {
	    tmpVersion += " " + VERSION_DEV_STRING;
	}

	VERSION = tmpVersion;
	VENDOR = tmpVendor;
    }

    /**
     * Returns the specification version string.
     * @return the specification version string
     */
    static String getSpecificationVersion() {
	return SPECIFICATION_VERSION;
    }

    /**
     * Returns the specification vendor string.
     * @return the specification vendor string
     */
    static String getSpecificationVendor() {
	return SPECIFICATION_VENDOR;
    }


    /**
     * Returns the implementation version string.
     * @return the implementation version string
     */
    static String getVersion() {
	return VERSION;
    }

    /**
     * Returns the implementation vendor string.
     * @return the implementation vendor string
     */
    static String getVendor() {
	return VENDOR;
    }

}