001package jmri.jmrix.oaktree.simulator; 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@net.jcip.annotations.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 * @since 3.3.1 023 */ 024public class Bundle extends jmri.jmrix.oaktree.Bundle { 025 026 @CheckForNull 027 private static final String name = null; // no local resources 028 // 029 // below here is boilerplate to be copied exactly 030 // 031 /** 032 * Provides a translated string for a given key from the package resource 033 * bundle or parent. 034 * <p> 035 * Note that this is intentionally package-local access. 036 * 037 * @param key Bundle key to be translated 038 * @return Internationalized text 039 */ 040 static String getMessage(String key) { 041 return getBundle().handleGetMessage(key); 042 } 043 044 /** 045 * Merges user data with a translated string for a given key from the 046 * package resource bundle or parent. 047 * <p> 048 * Uses the transformation conventions of the Java MessageFormat utility. 049 * <p> 050 * Note that this is intentionally package-local access. 051 * 052 * @see java.text.MessageFormat 053 * @param key Bundle key to be translated 054 * @param subs One or more objects to be inserted into the message 055 * @return Internationalized text 056 */ 057 static String getMessage(String key, Object... subs) { 058 return getBundle().handleGetMessage(key, subs); 059 } 060 061 /** 062 * Merges user data with a translated string for a given key in a given 063 * locale from the 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 locale The locale to be used 071 * @param key Bundle key to be translated 072 * @param subs One or more objects to be inserted into the message 073 * @return Internationalized text 074 */ 075 static String getMessage(Locale locale, String key, Object... subs) { 076 return getBundle().handleGetMessage(locale, key, subs); 077 } 078 079 080 private final static Bundle b = new Bundle(); 081 082 @Override 083 @CheckForNull 084 protected String bundleName() { 085 return name; 086 } 087 088 protected static jmri.Bundle getBundle() { 089 return b; 090 } 091 092 @Override 093 protected String retry(Locale locale, String key) { 094 return super.getBundle().handleGetMessage(locale,key); 095 } 096 097}