com.ls.util
Class ResourceBasedErrorHandler

java.lang.Object
  |
  +--com.ls.util.ResourceBasedErrorHandler
All Implemented Interfaces:
IErrorHandler

public class ResourceBasedErrorHandler
extends Object
implements IErrorHandler

Handle errors based on a resource bundle. All error messages are received from a resource bundle.

Version:
$Revision: 1.8 $
Author:
Last modified by $Author: TBerk $

Fields inherited from interface com.ls.util.IErrorHandler
DEFAULT_ERROR_MESSAGE, DEFAULT_LOCALE
 
Constructor Summary
ResourceBasedErrorHandler()
          Constructor.
 
Method Summary
 String getErrorMessage(String key)
          Returns a error message from the resourceBundle specified by the key It uses IErrorHandler.DEFAULT_LOCALE as local value.
 String getErrorMessage(String key, String localeString)
          Returns a error message from the resourceBundle specified by the key
 void setResourceBundle(String bundleName)
          Sets an error bundle.
 void setResourceBundle(String bundleName, String localeString)
          Sets an error bundle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceBasedErrorHandler

public ResourceBasedErrorHandler()
Constructor. Default empty constructor.
Method Detail

setResourceBundle

public void setResourceBundle(String bundleName)
                       throws ResourceBundleException
Sets an error bundle. It sets local value as IErrorHandler.DEFAULT_LOCALE.
Parameters:
bundleName - The name of the error bundle.
Throws:
ResourceBundleException - If any error occurs while opening the error bundle

setResourceBundle

public void setResourceBundle(String bundleName,
                              String localeString)
                       throws ResourceBundleException
Sets an error bundle.
Parameters:
bundleName - The name of the bundle which contains the error messages
localeString - The locale of the resource bundle that should be used
Throws:
ResourceBundleException - If any error occurs while opening the error bundle

getErrorMessage

public String getErrorMessage(String key)
                       throws ResourceBundleException
Returns a error message from the resourceBundle specified by the key It uses IErrorHandler.DEFAULT_LOCALE as local value.
Specified by:
getErrorMessage in interface IErrorHandler
Parameters:
key - The key of the error message
Returns:
The value (error message itself) which belongs to the given key.
Throws:
ResourceBundleException - If any error occurs while opening the error bundle

getErrorMessage

public String getErrorMessage(String key,
                              String localeString)
                       throws ResourceBundleException
Returns a error message from the resourceBundle specified by the key
Specified by:
getErrorMessage in interface IErrorHandler
Parameters:
key - The key of the error message
localeString - locale like "en_GB", "en_US" or "de_LU_EURO"...
Returns:
The value (error message itself) which belongs to the given key.
Throws:
ResourceBundleException - If any error occurs while opening the error bundle