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