FileDocCategorySizeDatePackage
StringHelper.javaAPI DocGlassfish v2 API4351Fri May 04 22:23:14 BST 2007com.sun.enterprise.config.backup

StringHelper

public class StringHelper extends Object
author
bnevins

Fields Summary
private static ResourceBundle
bundle
Constructors Summary
private StringHelper()

	
Methods Summary
static java.lang.Stringget(java.lang.String s)

return
the String from LocalStrings or the supplied String if it doesn't exist

		try 
		{
			return bundle.getString(s);
		} 
		catch (Exception e) 
		{
			// it is not an error to have no key...
			return s;
		}
	
static java.lang.Stringget(java.lang.String s, java.lang.Object o)
Convenience method which calls get(String, Object[])

return
the String from LocalStrings or the supplied String if it doesn't exist -- using the one supplied argument
see
get(String, Object[])

		return get(s, new Object[] { o });
	
static java.lang.Stringget(java.lang.String s, java.lang.Object o1, java.lang.Object o2)
Convenience method which calls get(String, Object[])

return
the String from LocalStrings or the supplied String if it doesn't exist -- using the two supplied arguments
see
get(String, Object[])

		return get(s, new Object[] { o1, o2 });
	
static java.lang.Stringget(java.lang.String s, java.lang.Object o1, java.lang.Object o2, java.lang.Object o3)
Convenience method which calls get(String, Object[])

return
the String from LocalStrings or the supplied String if it doesn't exist -- using the three supplied arguments
see
get(String, Object[])

		return get(s, new Object[] { o1, o2, o3 });
	
static java.lang.Stringget(java.lang.String s, java.lang.Object[] objects)
Get and format a String from LocalStrings.properties

return
the String from LocalStrings or the supplied String if it doesn't exist -- using the array of supplied Object arguments

		s = get(s);
		
		try
		{
			MessageFormat mf = new MessageFormat(s);
			return mf.format(objects);
		}
		catch(Exception e)
		{
			return s;
		}
	
static voidmain(java.lang.String[] notUsed)

		try 
		{   
			String props = StringHelper.class.getPackage().getName() + ".LocalStrings";
			bundle = ResourceBundle.getBundle(props);
		} 
		catch (Exception e) 
		{
			LoggerHelper.warning("No resource bundle found: " + Constants.exceptionResourceBundle, e);
			bundle = null;
		}
	
		System.out.println("key=backup-res.BadProjectBackupDir, value =" + get("backup-res.BadProjectBackupDir"));