com.sas.text
Class LocalizableException

com.sas.text.LocalizableException
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AttributeSetException

public class LocalizableException

An exception class whose exception message can be localized. Construct a LocalizableException with a resource bundle name, a resource key, and an array of arguments.

Since:
1.0
See Also:
Serialized Form

Constructor Summary
LocalizableException()
          Create a default LocalizableException instance.
LocalizableException(java.lang.String message)
          Create a LocalizableException instance with a default message.
LocalizableException(java.lang.String bundleName, java.lang.String resourceName, java.lang.Object[] args, java.lang.ClassLoader classLoader)
          Construct a LocalizableException using the elements necessary to render the exception under different locales.
LocalizableException(java.lang.String message, java.lang.Throwable cause)
          Contructs a LocalizableException with a message and causal exception.
 
Method Summary
 java.lang.String getBundleName()
          Return the bundleName property, which names the resource bundle that contains the localizable message format.
 java.lang.ClassLoader getClassLoader()
          Get the value of the classLoader property.
protected  java.lang.String getDefaultMessage()
          Return the default, non-localized message string.
 java.lang.String getMessage()
          Return the exception message using the default locale, Locale.getDefault().
 java.lang.String getMessage(java.util.Locale locale)
          Return the exception message for the specificed locale.
 java.lang.Object[] getMessageArguments()
          Return the arguments with which a message format, based on the resource name, is formatted via MessageFormat.format(String, Object[])
 java.lang.String getResourceName()
          Return the name of the resource string within the resource bundle.
 void setBundleName(java.lang.String _bundleName)
          Set the name of the resource bundle from which the localizable exception message is read.
 void setClassLoader(java.lang.ClassLoader _classLoader)
          Set the value of the classLoader property.
 void setMessage(java.lang.String bundleName, java.lang.String resourceName, java.lang.Object[] args)
          Set the elements of a localizable message.
 void setMessage(java.lang.String bundleName, java.lang.String resourceName, java.lang.Object[] args, java.lang.ClassLoader classLoader)
          Set the elements of a localizable message.
 void setMessageArguments(java.lang.Object[] _messageArguments)
          Set the message format arguments.
 void setResourceName(java.lang.String _resourceName)
          Set the name of the resource string within the resource bundle.
 

Constructor Detail

LocalizableException

public LocalizableException()
Create a default LocalizableException instance. If you use this constructor, you should set all the properties necessary for making a localizable message, using setMessage(String bundleName, String resourceName, Object[] args, ClassLoader classLoader) Consider using the LocalizableException(String bundleName, String resourceName, Object[] args, ClassLoader classLoader) constructor instead.


LocalizableException

public LocalizableException(java.lang.String message)
Create a LocalizableException instance with a default message. If you use this constructor, you should set all the properties necessary for making a localizable message, using setMessage(String bundleName, String resourceName, Object[] args) Consider using the LocalizableException(String bundleName, String resourceName, Object[] args, ClassLoader classLoader) constructor instead.


LocalizableException

public LocalizableException(java.lang.String bundleName,
                            java.lang.String resourceName,
                            java.lang.Object[] args,
                            java.lang.ClassLoader classLoader)
Construct a LocalizableException using the elements necessary to render the exception under different locales.

Parameters:
bundleName - the name of a resource bundle, such as "com.sas.text.Resources"
resourceName - The name of a resource within the resource bundle.
args - An array of arguments which are formatted using a MessageFormat and the message obtained from the resourceName
classLoader - The class loader of the class from which the resource bundle is loaded. Normally, this is the instaniating class' class loader. Since the client which formats the exception may reside in a different class loader, it may not be able to find the correct resource bundle. This class loader allows this LocalizableException to find the correct resource bundle.

LocalizableException

public LocalizableException(java.lang.String message,
                            java.lang.Throwable cause)
Contructs a LocalizableException with a message and causal exception.

Parameters:
message - The
cause -
Method Detail

getClassLoader

public java.lang.ClassLoader getClassLoader()
Get the value of the classLoader property.

Returns:
value of the classLoader property.

setClassLoader

public void setClassLoader(java.lang.ClassLoader _classLoader)
Set the value of the classLoader property.

Parameters:
classLoader - New value to assign to the classLoader property.

getBundleName

public java.lang.String getBundleName()
Return the bundleName property, which names the resource bundle that contains the localizable message format.


setBundleName

public void setBundleName(java.lang.String _bundleName)
Set the name of the resource bundle from which the localizable exception message is read.

Parameters:
bundleName - The name of the resource bundle.

getResourceName

public java.lang.String getResourceName()
Return the name of the resource string within the resource bundle. This string is a message format string which can be localized by formatting via MessageFormat.format(String, Object[])


setResourceName

public void setResourceName(java.lang.String _resourceName)
Set the name of the resource string within the resource bundle.


getMessageArguments

public java.lang.Object[] getMessageArguments()
Return the arguments with which a message format, based on the resource name, is formatted via MessageFormat.format(String, Object[])


setMessageArguments

public void setMessageArguments(java.lang.Object[] _messageArguments)
Set the message format arguments.


setMessage

public void setMessage(java.lang.String bundleName,
                       java.lang.String resourceName,
                       java.lang.Object[] args)
Set the elements of a localizable message.

Parameters:
bundleName - the name of a resource bundle
resourceName - the name of the resource from the bundle
args - the arguments to pass to a MessageFormat object.

setMessage

public void setMessage(java.lang.String bundleName,
                       java.lang.String resourceName,
                       java.lang.Object[] args,
                       java.lang.ClassLoader classLoader)
Set the elements of a localizable message.

Parameters:
bundleName - the name of a resource bundle
resourceName - the name of the resource from the bundle
args - the arguments to pass to a MessageFormat object.

getDefaultMessage

protected java.lang.String getDefaultMessage()
Return the default, non-localized message string. This message is the text passed in to the LocalizableException(String) constructor, or it is the concatenation of the bundle name and the resource name.


getMessage

public java.lang.String getMessage()
Return the exception message using the default locale, Locale.getDefault().

Overrides:
getMessage in class java.lang.Throwable

getMessage

public java.lang.String getMessage(java.util.Locale locale)
Return the exception message for the specificed locale.

Parameters:
locale - The locale in which the message should be formatted.
Returns:
a localized exception message for the locale



Copyright © 2009 SAS Institute Inc. All Rights Reserved.