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