001package jmri.jmrix.ipocs;
002
003import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
004
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@javax.annotation.concurrent.Immutable
014/**
015 * @author Bob Jacobsen Copyright (C) 2012
016 * @author Fredrik Elestedt Copyright (C) 2020
017 * @since 4.21.2
018 */
019public class Bundle extends jmri.jmrix.Bundle {
020  
021  @CheckForNull
022  private static final String name = "jmri.jmrix.ipocs.Bundle"; // NOI18N
023
024  public static final String UNABLE_PREFIX = "UNABLE_PREFIX";
025  public static final String UNABLE_CONNNAME = "UNABLE_CONNNAME";
026  public static final String UNABLE_PORT = "UNABLE_PORT";
027  public static final String PORT_TOOLTIP = "PORT_TOOLTIP";
028  public static final String PORT_LABEL = "PORT_LABEL";
029
030
031  //
032  // below here is boilerplate to be copied exactly
033  //
034  /**
035   * Provides a translated string for a given key from the package resource
036   * bundle or parent.
037   * <p>
038   * Note that this is intentionally package-local access.
039   *
040   * @param key Bundle key to be translated
041   * @return Internationalized text
042   */
043  static String getMessage(String key) {
044      return getBundle().handleGetMessage(key);
045  }
046
047  /**
048   * Provides a translated string for a given key in a given locale from the
049   * package resource bundle or parent.
050   * <p>
051   * Note that this is intentionally package-local access.
052   *
053   * @param locale The locale to be used
054   * @param key    Bundle key to be translated
055   * @return Internationalized text
056   */
057  static String getMessage(Locale locale, String key) {
058      return getBundle().handleGetMessage(locale, key);
059  }
060
061  /**
062   * Merges user data with a translated string for a given key from the
063   * 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 key  Bundle key to be translated
071   * @param subs One or more objects to be inserted into the message
072   * @return Internationalized text
073   */
074  static String getMessage(String key, Object... subs) {
075      return getBundle().handleGetMessage(key, subs);
076  }
077
078  /**
079   * Merges user data with a translated string for a given key in a given
080   * locale from the package resource bundle or parent.
081   * <p>
082   * Uses the transformation conventions of the Java MessageFormat utility.
083   * <p>
084   * Note that this is intentionally package-local access.
085   *
086   * @see java.text.MessageFormat
087   * @param locale The locale to be used
088   * @param key    Bundle key to be translated
089   * @param subs   One or more objects to be inserted into the message
090   * @return Internationalized text
091   */
092  static String getMessage(Locale locale, String key, Object... subs) {
093      return getBundle().handleGetMessage(locale, key, subs);
094  }
095
096  private final static Bundle b = new Bundle();
097
098  @Override
099  @CheckForNull
100  protected String bundleName() {
101      return name;
102  }
103
104  protected static jmri.Bundle getBundle() {
105      return b;
106  }
107
108  @Override
109  protected String retry(Locale locale, String key) {
110      return super.getBundle().handleGetMessage(locale,key);
111  }
112}