001package jmri.jmrit.operations.logixng; 002 003import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 004 005import java.util.Locale; 006 007import javax.annotation.CheckReturnValue; 008import javax.annotation.CheckForNull; 009import javax.annotation.ParametersAreNonnullByDefault; 010 011@ParametersAreNonnullByDefault 012@CheckReturnValue 013@SuppressFBWarnings(value = {"NM_SAME_SIMPLE_NAME_AS_SUPERCLASS", "HSM_HIDING_METHOD"}, 014 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.jmrit.operations.Bundle { 028 029 @CheckForNull 030 private static final String name = "jmri.jmrit.operations.logixng.JmritOperationsLogixNGBundle"; // 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 return getBundle().handleGetMessage(key); 046 } 047 048 /** 049 * Merges user data with a translated string for a given key from the 050 * package resource bundle or parent. 051 * <p> 052 * Uses the transformation conventions of the Java MessageFormat utility. 053 * <p> 054 * Note that this is intentionally package-local access. 055 * 056 * @see java.text.MessageFormat 057 * @param key Bundle key to be translated 058 * @param subs One or more objects to be inserted into the message 059 * @return Internationalized text 060 */ 061 static String getMessage(String key, Object... subs) { 062 return getBundle().handleGetMessage(key, subs); 063 } 064 065 /** 066 * Merges user data with a translated string for a given key in a given 067 * locale from the package resource bundle or parent. 068 * <p> 069 * Uses the transformation conventions of the Java MessageFormat utility. 070 * <p> 071 * Note that this is intentionally package-local access. 072 * 073 * @see java.text.MessageFormat 074 * @param locale The locale to be used 075 * @param key Bundle key to be translated 076 * @param subs One or more objects to be inserted into the message 077 * @return Internationalized text 078 */ 079 static String getMessage(Locale locale, String key, Object... subs) { 080 return getBundle().handleGetMessage(locale, key, subs); 081 } 082 083 private final static Bundle b = new Bundle(); 084 085 @Override 086 @CheckForNull 087 protected String bundleName() { 088 return name; 089 } 090 091 protected static jmri.Bundle getBundle() { 092 return b; 093 } 094 095 @Override 096 protected String retry(Locale locale, String key) { 097 return super.getBundle().handleGetMessage(locale,key); 098 } 099 100}