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