Version.java revision 953:221a84ef44c0
192108Sphk/* 292108Sphk * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 392108Sphk * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 492108Sphk * 592108Sphk * This code is free software; you can redistribute it and/or modify it 692108Sphk * under the terms of the GNU General Public License version 2 only, as 792108Sphk * published by the Free Software Foundation. Oracle designates this 892108Sphk * particular file as subject to the "Classpath" exception as provided 992108Sphk * by Oracle in the LICENSE file that accompanied this code. 1092108Sphk * 1192108Sphk * This code is distributed in the hope that it will be useful, but WITHOUT 1292108Sphk * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1392108Sphk * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1492108Sphk * version 2 for more details (a copy is included in the LICENSE file that 1592108Sphk * accompanied this code). 1692108Sphk * 1792108Sphk * You should have received a copy of the GNU General Public License version 1892108Sphk * 2 along with this work; if not, write to the Free Software Foundation, 1992108Sphk * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2092108Sphk * 2192108Sphk * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2292108Sphk * or visit www.oracle.com if you need additional information or have any 2392108Sphk * questions. 2492108Sphk */ 2592108Sphk 2692108Sphkpackage jdk.nashorn.internal.runtime; 2792108Sphk 2892108Sphkimport java.util.MissingResourceException; 2992108Sphkimport java.util.ResourceBundle; 3092108Sphk 3192108Sphk/** 3292108Sphk * Class to handle version strings for Nashorn. 3392108Sphk */ 3492108Sphkpublic final class Version { 3592108Sphk // Don't create me! 36116196Sobrien private Version() { 37116196Sobrien } 38116196Sobrien 3992108Sphk /** 4092108Sphk * The current version number as a string. 4192108Sphk * @return version string 4292108Sphk */ 4392108Sphk public static String version() { 4492108Sphk return version("release"); // mm.nn.oo[-milestone] 4592108Sphk } 4692108Sphk 47130712Sphk /** 4892108Sphk * The current full version number as a string. 4992108Sphk * @return full version string 5092108Sphk */ 5192108Sphk public static String fullVersion() { 52114216Skan return version("full"); // mm.mm.oo[-milestone]-build 5392108Sphk } 5495323Sphk 5592108Sphk private static final String VERSION_RB_NAME = "jdk.nashorn.internal.runtime.resources.version"; 5692108Sphk private static ResourceBundle versionRB; 5792108Sphk 5892108Sphk private static String version(final String key) { 5992108Sphk if (versionRB == null) { 6092108Sphk try { 6192108Sphk versionRB = ResourceBundle.getBundle(VERSION_RB_NAME); 62126080Sphk } catch (final MissingResourceException e) { 63111815Sphk return "version not available"; 64111815Sphk } 65111815Sphk } 66111815Sphk try { 67111815Sphk return versionRB.getString(key); 68111815Sphk } 69111815Sphk catch (final MissingResourceException e) { 70126080Sphk return "version not available"; 7192108Sphk } 7292108Sphk } 7392108Sphk} 7492108Sphk