File: Version.j

package info (click to toggle)
eclipselink 2.7.15-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 44,708 kB
  • sloc: java: 476,807; xml: 547; makefile: 21
file content (247 lines) | stat: -rw-r--r-- 8,654 bytes parent folder | download | duplicates (2)
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
/*
 * Copyright (c) 1998, 2018 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0,
 * or the Eclipse Distribution License v. 1.0 which is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
 */

// Contributors:
//     Oracle - initial API and implementation from Oracle TopLink
//     egwin  - Changed buildNumber to buildDate. Added buildRevision,
//              buildType, getBuildDate(), getBuildRevision(), getBuildType(),
//              getVersionString(), printVersionString(), and main()
package org.eclipse.persistence;

import org.eclipse.persistence.internal.helper.JavaSEPlatform;

/**
 * This class stores variables for the version and build numbers that are used
 * in printouts and exceptions.
 *
 * @author Eric Gwin
 * @since 1.0,
 */
public class Version {
    // The current version of EclipseLink.
    // This will be used by all product components and included in exceptions.
    private static String product = "Eclipse Persistence Services";
    // A three part version number (major.minor.service)
    private static final String version = "@VERSION@";
    // A string that describes this build i.e.( vYYYYMMDD-HHMM, etc.)
    private static final String qualifier = "@QUALIFIER@";
    // Should be in the format YYYYMMDD
    private static final String buildDate = "@BUILD_DATE@";
    // Should be in the format HHMM
    private static final String buildTime = "@BUILD_TIME@";
    // revision of source from the repository
    private static final String buildRevision = "@BUILD_REVISION@";
    // Typically SNAPSHOT, Milestone name (M1,M2,etc), or RELEASE
    private static final String buildType = "@BUILD_TYPE@";

    /** Version numbers separator. */
    private static final char SEPARATOR = '.';

    // This is replaced by JavaSEPlatform. It's here just because of backward compatibility.
    /**
     * Keep track of JDK version in order to make some decisions about data structures.
     * @deprecated Use {@link JavaSEPlatform} instead. Will be removed in 2.7.
     */
    @Deprecated
    public static final int JDK_VERSION_NOT_SET = 0;
    /** @deprecated Use {@link JavaSEPlatform} instead. Will be removed in 2.7. */
    @Deprecated
    public static final int JDK_1_5 = 1;
    /** @deprecated Use {@link JavaSEPlatform} instead. Will be removed in 2.7. */
    @Deprecated
    public static final int JDK_1_6 = 2;
    /** @deprecated Use {@link JavaSEPlatform} instead. Will be removed in 2.7. */
    @Deprecated
    public static final int JDK_1_7 = 3;
    /** @deprecated Use {@link JavaSEPlatform} instead. Will be removed in 2.7. */
    @Deprecated
    public static final int JDK_1_8 = 4;
    /** @deprecated Use {@link JavaSEPlatform} instead. Will be removed in 2.7. */
    @Deprecated
    public static final int JDK_1_9 = 5;
    /** @deprecated Use {@link JavaSEPlatform} instead. Will be removed in 2.7. */
    @Deprecated
    public static int JDK_VERSION = JDK_VERSION_NOT_SET;

    /**
     * Returns version {@link String} containing three part version number
     * and build qualifier.
     * @return Version {@link String}.
     */
    public static String getVersionString ( ) {
        StringBuilder sb = new StringBuilder(
                version.length() + 1 + qualifier.length());
        sb.append(version);
        sb.append(SEPARATOR);
        sb.append(qualifier);
        return sb.toString();
    }

    public static String getProduct() {
        return product;
    }

    public static void setProduct(String ProductName) {
        product = ProductName;
    }

    public static String getVersion() {
        return version;
    }

    public static String getQualifier() {
        return qualifier;
    }

    public static String getBuildNumber() {
        return getBuildDate();
    }

    public static String getBuildDate() {
        return buildDate;
    }

    public static String getBuildTime() {
        return buildTime;
    }

    public static String getBuildRevision() {
        return buildRevision;
    }

    public static String getBuildType() {
        return buildType;
    }

    /**
     * INTERNAL:
     * Return the JDK version we are using.
     * @deprecated Use {@code JavaSEPlatform.CURRENT} instead.
     *             Will be removed in 2.7.
     */
    @Deprecated
    public static int getJDKVersion() {
        switch(JavaSEPlatform.CURRENT) {
            case v1_7:
                JDK_VERSION = JDK_1_7;
                break;
            case v1_8:
                JDK_VERSION = JDK_1_8;
                break;
            case v9_0:
                JDK_VERSION = JDK_1_9;
                break;
            default:
                throw new IllegalStateException("Running on unsupported Java SE: "
                        + JavaSEPlatform.CURRENT.toString());
        }
        return JDK_VERSION;
    }

    /**
     * Set 1.5 as current Java SE version.
     * @throws UnsupportedOperationException when invoked because Java SE 1.5
     *         is not supported by current EclipseLink.
     * @deprecated Use {@link JavaSEPlatform} instead. Will be removed in 2.7.
     */
    @Deprecated
    public static void useJDK15() {
        throw new UnsupportedOperationException(
                "Java SE 1.5 is not supported by current EclipseLink.");
    }

    /**
     * Set 1.6 as current Java SE version.
     * @throws UnsupportedOperationException when invoked because Java SE 1.6
     *         is not supported by current EclipseLink.
     * @deprecated Use {@link JavaSEPlatform} instead. Will be removed in 2.7.
     */
    @Deprecated
    public static void useJDK16() {
        throw new UnsupportedOperationException(
                "Java SE 1.6 is not supported by current EclipseLink.");
    }

    // Public API wrapper, use JavaSEPlatform.is(JavaSEPlatform.v1_5)
    // internally.
    /**
     * Check whether we are running on Java SE 1.5.
     * This will always return {@code false} because Java SE 1.5 is not
     * supported by current EclipseLink.
     * @return Value of {@code true} when we do and value of {@code false}
     *         when we do not run on Java SE 1.5.
     */
    public static boolean isJDK15() {
        return JavaSEPlatform.is(JavaSEPlatform.v1_5);
    }

    // Public API wrapper, use JavaSEPlatform.is(JavaSEPlatform.v1_6)
    // internally.
    /**
     * Check whether we are running on Java SE 1.6.
     * This will always return {@code false} because Java SE 1.6 is not
     * supported by current EclipseLink.
     * @return Value of {@code true} when we do and value of {@code false}
     *         when we do not run on Java SE 1.6.
     */
    public static boolean isJDK16() {
        return JavaSEPlatform.is(JavaSEPlatform.v1_6);
    }

    // Public API wrapper, use JavaSEPlatform.is(JavaSEPlatform.v1_7)
    // internally.
    /**
     * Check whether we are running on Java SE 1.7.
     * @return Value of {@code true} when we do and value of {@code false}
     *         when we do not run on Java SE 1.7.
     */
    public static boolean isJDK17() {
        return JavaSEPlatform.is(JavaSEPlatform.v1_7);
    }

    // Public API wrapper, use JavaSEPlatform.is(JavaSEPlatform.v1_8)
    // internally.
    /**
     * Check whether we are running on Java SE 1.8.
     * @return Value of {@code true} when we do and value of {@code false}
     *         when we do not run on Java SE 1.8.
     */
    public static boolean isJDK18() {
        return JavaSEPlatform.is(JavaSEPlatform.v1_8);
    }

    // Public API wrapper, use JavaSEPlatform.is(JavaSEPlatform.v1_9)
    // internally.
    /**
     * Check whether we are running on Java SE 1.9.
     * @return Value of {@code true} when we do and value of {@code false}
     *         when we do not run on Java SE 1.9.
     */
    public static boolean isJDK19() {
        return JavaSEPlatform.is(JavaSEPlatform.v9_0);
    }

    public static void printVersion ( ) {
        System.out.println( getVersionString() );
    }

    public static void main ( String[] args ) {
        System.out.println(
             "\n" + getProduct() + " (EclipseLink)"
             + "\n   Build Version:   " + getVersionString()
             + "\n   Build Qualifier: " + getQualifier()
             + "\n   Build Date:      " + getBuildDate()
             + "\n   Build Time:      " + getBuildTime()
             + "\n   SVN Revision:    " + getBuildRevision()
        );
    }
}