001package jmri.jmrix.loconet.lnsvf1; 002 003import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 004import org.slf4j.Logger; 005import org.slf4j.LoggerFactory; 006 007import javax.annotation.CheckForNull; 008import javax.annotation.CheckReturnValue; 009import javax.annotation.ParametersAreNonnullByDefault; 010import java.util.Locale; 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.loconet.Bundle { 029 030 @CheckForNull 031 private final static String name = "jmri.jmrix.loconet.lnsvf1.Lnsv1Bundle"; // 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 log.debug("interpreting key {} without parameters", key); 047 return getBundle().handleGetMessage(key); 048 } 049 050 /** 051 * Merges user data with a translated string for a given key from the 052 * package resource bundle or parent. 053 * <p> 054 * Uses the transformation conventions of the Java MessageFormat utility. 055 * <p> 056 * Note that this is intentionally package-local access. 057 * 058 * @see java.text.MessageFormat 059 * @param key Bundle key to be translated 060 * @param subs One or more objects to be inserted into the message 061 * @return Internationalized text 062 */ 063 static String getMessage(String key, Object... subs) { 064 log.debug("interpreting key {} with {} parameters", key, subs.length); 065 return getBundle().handleGetMessage(key, subs); 066 } 067 private final static Bundle b = new Bundle(); 068 069 @Override 070 @CheckForNull 071 protected String bundleName() { 072 return name; 073 } 074 075 protected static jmri.Bundle getBundle() { 076 return b; 077 } 078 079 @Override 080 protected String retry(Locale locale, String key) { 081 return super.getBundle().handleGetMessage(locale,key); 082 } 083 // initialize logging 084 private final static Logger log = LoggerFactory.getLogger(Bundle.class); 085 086 /** 087 * Merges user data with a translated string for a given key in a given 088 * locale from the package resource bundle or parent. 089 * <p> 090 * Uses the transformation conventions of the Java MessageFormat utility. 091 * <p> 092 * Note that this is intentionally package-local access. 093 * 094 * @see java.text.MessageFormat 095 * @param locale The locale to be used 096 * @param key Bundle key to be translated 097 * @param subs One or more objects to be inserted into the message 098 * @return Internationalized text 099 */ 100 static String getMessage(Locale locale, String key, Object... subs) { 101 return getBundle().handleGetMessage(locale, key, subs); 102 } 103 104}