001package jmri.jmrit.display.logixng.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.display.logixng.Bundle { 027 028 @CheckForNull 029 private static final String name = "jmri.jmrit.display.logixng.swing.SwingBundle"; // 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 private final static Bundle b = new Bundle(); 083 084 /** 085 * @return the name of the bundle 086 */ 087 @Override 088 @CheckForNull 089 protected String bundleName() { 090 return name; 091 } 092 093 /** 094 * @return the bundle for this bundle 095 */ 096 protected static jmri.Bundle getBundle() { 097 return b; 098 } 099 100 @Override 101 protected String retry(Locale locale, String key) { 102 return super.getBundle().handleGetMessage(locale,key); 103 } 104}