public String getOptionalString( final String key ) { try { return strictString( key ); } catch ( Exception e ) { logger.trace( "Optional String is undefined", e ); // ignore it return null; } }
public String getString( final String key ) { try { return strictString( key ); } catch ( MissingResourceException mre ) { logger.warn( "ResourceBundleSupport#getString(,,)", mre ); return '!' + key + '!'; } }
public String getString(final String key) { try { return strictString(key); } catch (MissingResourceException mre) { logger.warn("ResourceBundleSupport#getString(,,)", mre); return '!' + key + '!'; } }
public String getOptionalString(final String key) { try { return strictString(key); } catch (Exception e) { logger.trace("Optional String is undefined", e); // ignore it return null; } }
/** * Returns an unscaled icon. * * @param key the name of the resource bundle key * @return the icon. */ public Icon getIcon( final String key ) { if ( key == null ) { throw new NullPointerException(); } final String name = strictString( key ); return createIcon( name, false, false ); }
/** * Returns a URL pointing to a resource located in the classpath. The resource is looked up using the given key. * <p/> * Example: The load a file named 'logo.gif' which is stored in a java package named 'org.jfree.resources': * <pre> * mainmenu.logo=org/jfree/resources/logo.gif * </pre> * The URL for that file can be queried with: <code>getResource("mainmenu.logo");</code>. * * @param key the key for the resource * @return the resource URL */ public URL getResourceURL( final String key ) { if ( key == null ) { throw new NullPointerException(); } final String name = strictString( key ); final URL in = sourceClassLoader.getResource( name ); if ( in == null ) { logger.warn( "Unable to find file in the class path: " + name + "; key=" + key ); } return in; }
/** * Returns an scaled icon suitable for buttons or menus. * * @param key the name of the resource bundle key * @param large true, if the image should be scaled to 24x24, or false for 16x16 * @return the icon. */ public Icon getIcon( final String key, final boolean large ) { if ( key == null ) { throw new NullPointerException(); } final String name = strictString( key ); return createIcon( name, true, large ); }
/** * Returns an unscaled icon. * * @param key the name of the resource bundle key * @return the icon. */ public Icon getIcon(final String key) { if (key == null) { throw new NullPointerException(); } final String name = strictString(key); return createIcon(name, false, false); }
/** * Returns a URL pointing to a resource located in the classpath. The * resource is looked up using the given key. * <p/> * Example: The load a file named 'logo.gif' which is stored in a java * package named 'org.jfree.resources': * <pre> * mainmenu.logo=org/jfree/resources/logo.gif * </pre> * The URL for that file can be queried with: <code>getResource("mainmenu.logo");</code>. * * @param key the key for the resource * @return the resource URL */ public URL getResourceURL(final String key) { if (key == null) { throw new NullPointerException(); } final String name = strictString(key); final URL in = sourceClassLoader.getResource(name); if (in == null) { logger.warn("Unable to find file in the class path: " + name + "; key=" + key); } return in; }
/** * Returns an scaled icon suitable for buttons or menus. * * @param key the name of the resource bundle key * @param large true, if the image should be scaled to 24x24, or false for * 16x16 * @return the icon. */ public Icon getIcon(final String key, final boolean large) { if (key == null) { throw new NullPointerException(); } final String name = strictString(key); return createIcon(name, true, large); }
/** * Formats the message stored in the resource bundle (using a MessageFormat). * * @param key the resourcebundle key * @param parameters the parameter collection for the message * @return the formated string */ public String formatMessage( final String key, final Object[] parameters ) { final MessageFormat format = new MessageFormat( strictString( key ) ); format.setLocale( getLocale() ); return format.format( parameters ); }
/** * Returns the mnemonic stored at the given resourcebundle key. The mnemonic should be either the symbolic name of one * of the KeyEvent.VK_* constants (without the 'VK_') or the character for that key. * <p/> * For the enter key, the resource bundle would therefore either contain "ENTER" or "\n". * <pre> * a.resourcebundle.key=ENTER * an.other.resourcebundle.key=\n * </pre> * * @param key the resourcebundle key * @return the mnemonic */ public Integer getMnemonic( final String key ) { if ( key == null ) { throw new NullPointerException(); } final String name = strictString( key ); return createMnemonic( name ); }
/** * Formats the message stored in the resource bundle (using a * MessageFormat). * * @param key the resourcebundle key * @param parameters the parameter collection for the message * @return the formated string */ public String formatMessage(final String key, final Object[] parameters) { final MessageFormat format = new MessageFormat(strictString(key)); format.setLocale(getLocale()); return format.format(parameters); }
/** * Returns the mnemonic stored at the given resourcebundle key. The mnemonic * should be either the symbolic name of one of the KeyEvent.VK_* constants * (without the 'VK_') or the character for that key. * <p/> * For the enter key, the resource bundle would therefore either contain * "ENTER" or "\n". * <pre> * a.resourcebundle.key=ENTER * an.other.resourcebundle.key=\n * </pre> * * @param key the resourcebundle key * @return the mnemonic */ public Integer getMnemonic(final String key) { if (key == null) { throw new NullPointerException(); } final String name = strictString(key); return createMnemonic(name); }
/** * Returns the keystroke stored at the given resourcebundle key. * <p/> * The keystroke will be composed of a simple key press and the given KeyMask. If the KeyMask is zero, a plain * Keystroke is returned. * <p/> * The keystrokes character key should be either the symbolic name of one of the KeyEvent.VK_* constants or the * character for that key. * <p/> * For the 'A' key, the resource bundle would therefore either contain "VK_A" or "a". * <pre> * a.resourcebundle.key=VK_A * an.other.resourcebundle.key=a * </pre> * * @param key the resourcebundle key * @param mask the key-moifier mask to be used to create the keystroke. * @return the keystroke that has been generated. * @see java.awt.Toolkit#getMenuShortcutKeyMask() */ public KeyStroke getKeyStroke( final String key, final int mask ) { if ( key == null ) { throw new NullPointerException(); } final String name = strictString( key ); //noinspection MagicConstant return KeyStroke.getKeyStroke( createMnemonic( name ).intValue(), mask ); }
final String name = strictString(key);
/** * Returns a JMenu created from a resource bundle definition. * <p/> * The menu definition consists of two keys, the name of the menu and the mnemonic for that menu. Both keys share a * common prefix, which is extended by ".name" for the name of the menu and ".mnemonic" for the mnemonic. * <p/> * <pre> * # define the file menu * menu.file.name=File * menu.file.mnemonic=F * </pre> * The menu definition above can be used to create the menu by calling <code>createMenu ("menu.file")</code>. * * @param keyPrefix the common prefix for that menu * @return the created menu */ public JMenu createMenu( final String keyPrefix ) { if ( keyPrefix == null ) { throw new NullPointerException(); } final JMenu retval = new JMenu(); retval.setText( strictString( keyPrefix + ".name" ) ); final Integer mnemonic = getOptionalMnemonic( keyPrefix + ".mnemonic" ); if ( mnemonic != null ) { retval.setMnemonic( mnemonic.intValue() ); } return retval; }
retval.setText(strictString(keyPrefix + ".name")); final Integer mnemonic = getOptionalMnemonic(keyPrefix + ".mnemonic"); if (mnemonic != null)
String name = strictString( key ); if ( StringUtils.isEmpty( name ) ) { return null;
String name = strictString(key); if (StringUtils.isEmpty(name))