Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/rmi/rmic/newrmic/Resources.java
38923 views
/*1* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.rmi.rmic.newrmic;2627import java.text.MessageFormat;28import java.util.MissingResourceException;29import java.util.ResourceBundle;3031/**32* Provides resource support for rmic.33*34* WARNING: The contents of this source file are not part of any35* supported API. Code that depends on them does so at its own risk:36* they are subject to change or removal without notice.37*38* @author Peter Jones39**/40public final class Resources {4142private static ResourceBundle resources = null;43private static ResourceBundle resourcesExt = null;44static {45try {46resources =47ResourceBundle.getBundle("sun.rmi.rmic.resources.rmic");48} catch (MissingResourceException e) {49// gracefully handle this later50}51try {52resourcesExt =53ResourceBundle.getBundle("sun.rmi.rmic.resources.rmicext");54} catch (MissingResourceException e) {55// OK if this isn't found56}57}5859private Resources() { throw new AssertionError(); }6061/**62* Returns the text of the rmic resource for the specified key63* formatted with the specified arguments.64**/65public static String getText(String key, String... args) {66String format = getString(key);67if (format == null) {68format = "missing resource key: key = \"" + key + "\", " +69"arguments = \"{0}\", \"{1}\", \"{2}\"";70}71return MessageFormat.format(format, (Object[]) args);72}7374/**75* Returns the rmic resource string for the specified key.76**/77private static String getString(String key) {78if (resourcesExt != null) {79try {80return resourcesExt.getString(key);81} catch (MissingResourceException e) {82}83}84if (resources != null) {85try {86return resources.getString(key);87} catch (MissingResourceException e) {88return null;89}90}91return "missing resource bundle: key = \"" + key + "\", " +92"arguments = \"{0}\", \"{1}\", \"{2}\"";93}94}959697