org.netbeans.modules.jellytools.platform/3 3.13

org.netbeans.jellytools
Class Bundle

java.lang.Object
  extended by org.netbeans.jellytools.Bundle

public class Bundle
extends Object

Helper class to get strings from NetBeans Bundle.properties files.
Everytime someone wants to identify a component by its title, label, caption or whatever, he should not use hard coded string in his test case but he should use Bundle.getString(bundleName, key) to obtain string from bundle. Then test cases can be executed on different than English locale because getString() methods returns string according to current locale.

Usage:

        // "OK"
        Bundle.getString("org.netbeans.core.windows.services.Bundle", "OK_OPTION_CAPTION");
        // "Properties of AnObject"
        Bundle.getString("org.netbeans.core.Bundle", "CTL_FMT_LocalProperties", new Object[] {new Integer(1), "AnObject"});
        // "View"
        Bundle.getStringTrimmed("org.netbeans.core.Bundle", "Menu/View");
 


Method Summary
static ResourceBundle getBundle(String bundle)
          Returns ResourceBundle from specified path.
static String getString(ResourceBundle bundle, String key)
          Gets string from specified ResourceBundle.
static String getString(ResourceBundle bundle, String key, Object[] params)
          Gets string from bundle specified by path to bundle and format it.
static String getString(String bundle, String key)
          Gets string from bundle specified by path to bundle.
static String getString(String bundle, String key, Object[] params)
          Gets string from bundle specified by path to bundle and format it.
static String getStringTrimmed(String bundle, String key)
          Gets string from bundle, removes mnemonic (i.e.
static String getStringTrimmed(String bundle, String key, Object[] params)
          Gets string from bundle and formats it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getBundle

public static ResourceBundle getBundle(String bundle)
Returns ResourceBundle from specified path.

Parameters:
bundle - path to bundle (e.g. "org.netbeans.core.Bundle")
Returns:
ResourceBundle instance

getString

public static String getString(ResourceBundle bundle,
                               String key)
Gets string from specified ResourceBundle.

Parameters:
bundle - instance of ResourceBundle
key - key of requested string
Returns:
string from bundle in current locale

getString

public static String getString(ResourceBundle bundle,
                               String key,
                               Object[] params)
Gets string from bundle specified by path to bundle and format it.

Parameters:
bundle - path to bundle (e.g. "org.netbeans.core.Bundle")
key - key of requested string
params - parameters to be formatted
Returns:
string from bundle in current locale with formatted parameters

getString

public static String getString(String bundle,
                               String key)
Gets string from bundle specified by path to bundle.

Parameters:
bundle - path to bundle (e.g. "org.netbeans.core.Bundle")
key - key of requested string
Returns:
string from bundle in current locale

getStringTrimmed

public static String getStringTrimmed(String bundle,
                                      String key)
Gets string from bundle, removes mnemonic (i.e. '&' or '(&X)') from it and cuts parameters like {0} from the end.

Parameters:
bundle - path to bundle (e.g. "org.netbeans.core.Bundle")
key - key of requested string
Returns:
string from bundle in current locale. Mnemonic (i.e. '&' or '(&X)') is removed and parameter patterns are also removed starting by first '{'.

getString

public static String getString(String bundle,
                               String key,
                               Object[] params)
Gets string from bundle specified by path to bundle and format it.

Parameters:
bundle - path to bundle (e.g. "org.netbeans.core.Bundle")
key - key of requested string
params - parameter to be formatted
Returns:
string from bundle in current locale with formatted parameters

getStringTrimmed

public static String getStringTrimmed(String bundle,
                                      String key,
                                      Object[] params)
Gets string from bundle and formats it. It removes mnemonic (i.e. '&' or '(&X)') from it and cuts parameters like {0} from the end if any.

Parameters:
bundle - path to bundle (e.g. "org.netbeans.core.Bundle")
key - key of requested string
params - parameter to be formatted
Returns:
string from bundle in current locale. Mnemonic and parameters like {0} removed from the end.

org.netbeans.modules.jellytools.platform/3 3.13

Built on May 22 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.