aboutsummaryrefslogtreecommitdiffstats
path: root/build/lib/BridgeVersion.java.txt
blob: 95d41d201e1b1647d88b2681303e8dfd5da52f92 (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
/* ********************************************************************
 * Copyright (c) 1998-2001 Xerox Corporation, 
 *               2002 Palo Alto Research Center, Incorporated (PARC).
 * All rights reserved. 
 * This program and the accompanying materials are made available 
 * under the terms of the Common Public License v1.0 
 * which accompanies this distribution and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 * 
 * Contributors:
 *     Xerox/PARC     initial implementation
 * *******************************************************************/

package org.aspectj.bridge;

import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;

/** release-specific version information */
public class Version {
    
    /** default version value for development version */
    public static final String DEVELOPMENT = "DEVELOPMENT";

    /** default time value for development version */
    public static final long NOTIME = 0L;
    
    /** set by build script */
    public static final String text = "@build.version@";
    
    /** 
      * Time text set by build script using SIMPLE_DATE_FORMAT.
      * (if DEVELOPMENT version, invalid)
      */
    public static final String time_text = "@build.time@";

    /** 
      * time in seconds-since-... format, used by programmatic clients.
      * (if DEVELOPMENT version, NOTIME)
      */
    public static final long time;
    
	/** format used by build script to set time_text */
    public static final String SIMPLE_DATE_FORMAT = "@build.time.format@";
    
    // if not DEVELOPMENT version, read time text using format used to set time 
    static {
        long foundTime = NOTIME;
        if (!DEVELOPMENT.equals(text)) {
	        try {
	            SimpleDateFormat format = new SimpleDateFormat(SIMPLE_DATE_FORMAT);
	            ParsePosition pos = new ParsePosition(0);
	            Date date = format.parse(time_text, pos);
	            foundTime = date.getTime();
	        } catch (Throwable t) {            
	        }
        }
        time = foundTime;
    }
}