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