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