001package jmri.jmrix.mrc.swing.monitor; 002 003import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 004import java.util.Locale; 005import javax.annotation.CheckReturnValue; 006import javax.annotation.CheckForNull; 007import javax.annotation.ParametersAreNonnullByDefault; 008 009@ParametersAreNonnullByDefault 010@CheckReturnValue 011@SuppressFBWarnings(value = "NM_SAME_SIMPLE_NAME_AS_SUPERCLASS", justification = "Desired pattern is repeated class names with package-level access to members") 012 013@javax.annotation.concurrent.Immutable 014 015/** 016 * Provides standard access for resource bundles in a package. 017 * 018 * Convention is to provide a subclass of this name in each package, working off 019 * the local resource bundle name. 020 * 021 * @author Bob Jacobsen Copyright (C) 2012 022 * Copied for MRC Monitor 023 * @author Ken Cameron Copyright (C) 2016 024 * @since 3.3.1 025 */ 026public class Bundle extends jmri.jmrix.mrc.Bundle { 027 028 @CheckForNull 029 private static final String name = "jmri.jmrix.mrc.swing.MrcSwingBundle"; // NOI18N 030 031 // 032 // below here is boilerplate to be copied exactly 033 // 034 /** 035 * Provides a translated string for a given key from the package resource 036 * bundle or parent. 037 * <p> 038 * Note that this is intentionally package-local access. 039 * 040 * @param key Bundle key to be translated 041 * @return Internationalized text 042 */ 043 static String getMessage(String key) { 044 return getBundle().handleGetMessage(key); 045 } 046 047 /** 048 * Merges user data with a translated string for a given key from the 049 * package resource bundle or parent. 050 * <p> 051 * Uses the transformation conventions of the Java MessageFormat utility. 052 * <p> 053 * Note that this is intentionally package-local access. 054 * 055 * @see java.text.MessageFormat 056 * @param key Bundle key to be translated 057 * @param subs One or more objects to be inserted into the message 058 * @return Internationalized text 059 */ 060 static String getMessage(String key, Object... subs) { 061 return getBundle().handleGetMessage(key, subs); 062 } 063 064 /** 065 * Merges user data with a translated string for a given key in a given 066 * locale from the package resource bundle or parent. 067 * <p> 068 * Uses the transformation conventions of the Java MessageFormat utility. 069 * <p> 070 * Note that this is intentionally package-local access. 071 * 072 * @see java.text.MessageFormat 073 * @param locale The locale to be used 074 * @param key Bundle key to be translated 075 * @param subs One or more objects to be inserted into the message 076 * @return Internationalized text 077 */ 078 static String getMessage(Locale locale, String key, Object... subs) { 079 return getBundle().handleGetMessage(locale, key, subs); 080 } 081 082 083 private final static Bundle b = new Bundle(); 084 085 @Override 086 @CheckForNull 087 protected String bundleName() { 088 return name; 089 } 090 091 protected static jmri.Bundle getBundle() { 092 return b; 093 } 094 095 @Override 096 protected String retry(Locale locale, String key) { 097 return super.getBundle().handleGetMessage(locale,key); 098 } 099 100}