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