1 /*
 2  * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
 3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 4  *
 5  * This code is free software; you can redistribute it and/or modify it
 6  * under the terms of the GNU General Public License version 2 only, as
 7  * published by the Free Software Foundation.
 8  *
 9  * This code is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * version 2 for more details (a copy is included in the LICENSE file that
13  * accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  */
23 package org.openjdk.asmtools.util;
24 
25 import java.util.ResourceBundle;
26 
27 /**
28  * Class providing an access to the product info.
29  * <i>productinfo.properties</i> will be generated during the build
30  */
31 public class ProductInfo {
32 
33     static {
34         init();
35     }
36 
37     ;
38 
39     /**
40      * Returns the value of the specified property
41      */
42     public static String getProperty(String propName) {
43         try {
44             return bundle.getString(propName);
45         } catch (java.util.MissingResourceException e) {
46             return null;
47         }
48     }
49 
50     /**
51      * Version of the product in the short format, like 5.0
52      */
53     public static final String VERSION = version();
54 
55     /**
56      * Full version of the product, including build number and date of creation
57      */
58     public static final String FULL_VERSION = fullVersion();
59 
60     private static final String BUNDLE_NAME = "org.openjdk.asmtools.util.productinfo";
61 
62     private static ResourceBundle bundle;
63 
64     /**
65      * Initializes the bundle
66      */
67     private static void init() {
68         bundle = ResourceBundle.getBundle(BUNDLE_NAME);
69     }
70 
71     private static String version() {
72         return getProperty("PRODUCT_VERSION");
73     }
74 
75     private static String fullVersion() {
76         return getProperty("PRODUCT_NAME_LONG") + ", version " + version()
77                 + " " + getProperty("PRODUCT_MILESTONE")
78                 + " " + getProperty("PRODUCT_BUILDNUMBER")
79                 + " (" + getProperty("PRODUCT_DATE") + ")";
80 
81     }
82 
83 }