FileDocCategorySizeDatePackage
Localizer.javaAPI DocGlassfish v2 API4299Fri May 04 22:35:00 BST 2007com.sun.enterprise.instance

Localizer

public class Localizer extends Object
The purpose of this class is to create localized ConfigException objects conveniently. The code is here instead of in ConfigException itself to avoid passing in a StringManager reference everytime a ConfigException is thrown -- and the concommitant increase in the number of constructors. To use this class you create one instance for each calling class so that the correct properties file is chosen automatically. Note that StringManager only uses the *package* name to locate the properties file. Also note that only this package can access this class. Thus the StringManager can be shared by all callers of this class.
author
Byron Nevins

Fields Summary
private static com.sun.enterprise.util.i18n.StringManager
localStrings
Constructors Summary
private Localizer()

	
Methods Summary
static java.lang.StringgetValue(ExceptionType type)

		String key = type.getString();
		
		if(localStrings == null)
			return key;
		
		try
		{
			return localStrings.getStringWithDefault(key, key);
		}
		catch(Exception e)
		{
			return key;
		}
	
static java.lang.StringgetValue(ExceptionType type, java.lang.String arg1of1)

		return getValue(type, new Object[] { arg1of1 });
	
static java.lang.StringgetValue(ExceptionType type, int arg1of1)

		return getValue(type, new Object[] { new Integer(arg1of1) });
	
static java.lang.StringgetValue(ExceptionType type, java.lang.Object[] objs)

		if(objs == null || objs.length <= 0)
			return getValue(type);

		String key = type.getString();
		
		if(localStrings == null)
			return key;
		
		try
		{
			return localStrings.getStringWithDefault(key, key, objs);
		}
		catch(Exception e)
		{
			return key;
		}