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", justification = "Desired pattern is repeated class names with package-level access to members")
015
016@javax.annotation.concurrent.Immutable
017
018/*
019 * Provides standard access for resource bundles in a package.
020 *
021 * Convention is to provide a subclass of this name in each package, working off
022 * the local resource bundle name.
023 *
024 * @author Bob Jacobsen Copyright (C) 2012
025 * @since 3.3.1
026 */
027public class Bundle extends jmri.jmrix.loconet.Bundle {
028
029    @CheckForNull
030    private final static String name = "jmri.jmrix.loconet.lnsvf1.Lnsv1Bundle"; // NOI18N
031
032    //
033    // below here is boilerplate to be copied exactly
034    //
035    /**
036     * Provides a translated string for a given key from the package resource
037     * bundle or parent.
038     * <p>
039     * Note that this is intentionally package-local access.
040     *
041     * @param key Bundle key to be translated
042     * @return Internationalized text
043     */
044    static String getMessage(String key) {
045        log.debug("interpreting key {} without parameters", key);
046        return getBundle().handleGetMessage(key);
047    }
048
049    /**
050     * Merges user data with a translated string for a given key from the
051     * package resource bundle or parent.
052     * <p>
053     * Uses the transformation conventions of the Java MessageFormat utility.
054     * <p>
055     * Note that this is intentionally package-local access.
056     *
057     * @see java.text.MessageFormat
058     * @param key  Bundle key to be translated
059     * @param subs One or more objects to be inserted into the message
060     * @return Internationalized text
061     */
062    static String getMessage(String key, Object... subs) {
063        log.debug("interpreting key {} with {} parameters", key, subs.length);
064        return getBundle().handleGetMessage(key, subs);
065    }
066    private final static Bundle b = new Bundle();
067
068    @Override
069    @CheckForNull
070    protected String bundleName() {
071        return name;
072    }
073
074    protected static jmri.Bundle getBundle() {
075        return b;
076    }
077
078    @Override
079    protected String retry(Locale locale, String key) {
080        return super.getBundle().handleGetMessage(locale,key);
081    }
082    // initialize logging
083    private final static Logger log = LoggerFactory.getLogger(Bundle.class);
084
085    /**
086     * Merges user data with a translated string for a given key in a given
087     * locale from the package resource bundle or parent.
088     * <p>
089     * Uses the transformation conventions of the Java MessageFormat utility.
090     * <p>
091     * Note that this is intentionally package-local access.
092     *
093     * @see java.text.MessageFormat
094     * @param locale The locale to be used
095     * @param key    Bundle key to be translated
096     * @param subs   One or more objects to be inserted into the message
097     * @return Internationalized text
098     */
099    static String getMessage(Locale locale, String key, Object... subs) {
100        return getBundle().handleGetMessage(locale, key, subs);
101    }
102
103}