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", "HSM_HIDING_METHOD"}, 018 justification = "Desired pattern is repeated class names with package-level access to members") 019public class Bundle extends jmri.jmrit.Bundle { 020 021 @CheckForNull 022 private static final String name = "jmri.jmrit.z21server.z21serverBundle"; // NOI18N 023 024 // 025 // below here is boilerplate to be copied exactly 026 // 027 /** 028 * Provides a translated string for a given key from the package resource 029 * bundle or parent. 030 * <p> 031 * Note that this is intentionally package-local access. 032 * 033 * @param key Bundle key to be translated 034 * @return Internationalized text 035 */ 036 static String getMessage(String key) { 037 return getBundle().handleGetMessage(key); 038 } 039 040 /** 041 * Merges user data with a translated string for a given key from the 042 * package resource bundle or parent. 043 * <p> 044 * Uses the transformation conventions of the Java MessageFormat utility. 045 * <p> 046 * Note that this is intentionally package-local access. 047 * 048 * @see java.text.MessageFormat 049 * @param key Bundle key to be translated 050 * @param subs One or more objects to be inserted into the message 051 * @return Internationalized text 052 */ 053 static String getMessage(String key, Object... subs) { 054 return getBundle().handleGetMessage(key, subs); 055 } 056 057 /** 058 * Merges user data with a translated string for a given key in a given 059 * locale from the package resource bundle or parent. 060 * <p> 061 * Uses the transformation conventions of the Java MessageFormat utility. 062 * <p> 063 * Note that this is intentionally package-local access. 064 * 065 * @see java.text.MessageFormat 066 * @param locale The locale to be used 067 * @param key Bundle key to be translated 068 * @param subs One or more objects to be inserted into the message 069 * @return Internationalized text 070 */ 071 static String getMessage(Locale locale, String key, Object... subs) { 072 return getBundle().handleGetMessage(locale, key, subs); 073 } 074 075 076 private final static jmri.jmrit.z21server.Bundle b = new jmri.jmrit.z21server.Bundle(); 077 078 @Override 079 @CheckForNull 080 protected String bundleName() { 081 return name; 082 } 083 084 protected static jmri.Bundle getBundle() { 085 return b; 086 } 087 088 @Override 089 protected String retry(Locale locale, String key) { 090 return super.getBundle().handleGetMessage(locale,key); 091 } 092 093}