de.smartics.exceptions.i18n
Class AbstractLocalizedException

Package class diagram package AbstractLocalizedException
java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by de.smartics.exceptions.AbstractCoreException
              extended by de.smartics.exceptions.i18n.AbstractLocalizedException
All Implemented Interfaces:
CoreException, LocalizedException, Serializable

public abstract class AbstractLocalizedException
     
     
extends AbstractCoreException
implements LocalizedException

The base implementation of exceptions that support Internationalization for checked exceptions.

Author:
Robert Reiner
See Also:
Serialized Form

Field Summary
protected  LocalizedInfo localizedInfo
          The localized information controls the localization information.
 
Fields inherited from class de.smartics.exceptions.AbstractCoreException
info
 
Constructor Summary
protected AbstractLocalizedException(Code code)
          Constructor.
protected AbstractLocalizedException(Code code, String bundleBaseName)
          Constructor.
protected AbstractLocalizedException(Throwable cause, Code code)
          Constructor.
protected AbstractLocalizedException(Throwable cause, Code code, String bundleBaseName)
          Constructor.
protected AbstractLocalizedException(Throwable cause, Code code, String bundleBaseName, String resourceKey)
          Constructor.
 
Method Summary
 String getBundleBaseName()
          Delegates call to LocalizedInfo.getBundleBaseName() .
 String getLocalizedMessage()
          Returns the localized message for the given locale.
 String getLocalizedMessage(Locale locale)
          Returns the localized message for the given locale.
 String getLocalizedMessage(Locale locale, ClassLoader loader)
          Returns the localized message for the given locale.
 String getLocalizedMessage(String keyPrefix, Locale locale, MessageType messageType, ClassLoader loader)
          Returns the localized message for the given locale.
 String getLocalizedTextMessage()
          Returns the localized message for the given locale as formatted multi-line text.
 String getLocalizedTextMessage(Locale locale)
          Returns the localized message for the given locale as formatted multi-line text.
 String getLocalizedTextMessage(Locale locale, ClassLoader loader)
          Returns the localized message for the given locale as formatted multi-line text.
 String getMessage()
          Returns the detail message string of this throwable.
 String getMessage(Locale locale, MessageType messageType)
          Returns the message for the given message type.
 String getMessage(MessageType messageType)
          Calls getMessage(java.util.Locale, de.smartics.exceptions.i18n.message.MessageType) with argument list (Locale.getDefault(), <messageType>).
 String getMessages()
          Returns the messages in one string.
 String getMessages(Locale locale)
          Returns the messages in one string.
 String getResourceKey()
          Delegates call to LocalizedInfo.getResourceKey().
 
Methods inherited from class de.smartics.exceptions.AbstractCoreException
getCause, getCode, getId, getTime, toString, truncateCause
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.smartics.exceptions.CoreException
getCause, getCode, getId, getStackTrace, getTime, setStackTrace, truncateCause
 

Field Detail

localizedInfo

protected final LocalizedInfo localizedInfo
The localized information controls the localization information.

Constructor Detail

AbstractLocalizedException

protected AbstractLocalizedException(Code code)
Constructor.

Parameters:
code - the error or exception code of the exception.

AbstractLocalizedException

protected AbstractLocalizedException(Code code,
                                     String bundleBaseName)
Constructor.

Parameters:
code - the error or exception code of the exception.
bundleBaseName - the fully qualified name of the bundle to use.

AbstractLocalizedException

protected AbstractLocalizedException(Throwable cause,
                                     Code code)
Constructor.

Parameters:
cause - the cause (which is saved for later retrieval by the AbstractCoreException.getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
code - the error or exception code of the exception.

AbstractLocalizedException

protected AbstractLocalizedException(Throwable cause,
                                     Code code,
                                     String bundleBaseName)
Constructor.

Parameters:
cause - the cause (which is saved for later retrieval by the AbstractCoreException.getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
code - the error or exception code of the exception.
bundleBaseName - the fully qualified name of the bundle to use.

AbstractLocalizedException

protected AbstractLocalizedException(Throwable cause,
                                     Code code,
                                     String bundleBaseName,
                                     String resourceKey)
Constructor.

Parameters:
cause - the cause (which is saved for later retrieval by the AbstractCoreException.getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
code - the error or exception code of the exception.
bundleBaseName - the fully qualified name of the bundle to use.
resourceKey - the localization key to fetch messages from message bundles.
Method Detail

getResourceKey

public String getResourceKey()
Delegates call to LocalizedInfo.getResourceKey().

Returns:
the result of the call to LocalizedInfo.getResourceKey() .
See Also:
LocalizedInfo.getResourceKey()

getBundleBaseName

public String getBundleBaseName()
Delegates call to LocalizedInfo.getBundleBaseName() .

Returns:
the result of the call to LocalizedInfo.getBundleBaseName() .
See Also:
LocalizedInfo.getBundleBaseName()

getMessage

public String getMessage()
Returns the detail message string of this throwable.

Returns the localized message for the default locale.

Specified by:
getMessage in interface CoreException
Overrides:
getMessage in class Throwable
Returns:
the detail message string of this Throwable instance (which may be null).
See Also:
Throwable.getMessage()

getMessage

public String getMessage(MessageType messageType)
Calls getMessage(java.util.Locale, de.smartics.exceptions.i18n.message.MessageType) with argument list ( Locale.getDefault(), <messageType>).

Specified by:
getMessage in interface LocalizedException
Parameters:
messageType - the type of message to fetch.
Returns:
the message for the given type.
See Also:
getMessage(java.util.Locale, de.smartics.exceptions.i18n.message.MessageType)

getMessage

public String getMessage(Locale locale,
                         MessageType messageType)
Returns the message for the given message type.

Specified by:
getMessage in interface LocalizedException
Parameters:
locale - the locale to select the localized message.
messageType - the type if message to return.
Returns:
the message for the given message type.
See Also:
LocalizedException.getMessage(java.util.Locale, de.smartics.exceptions.i18n.message.MessageType)

getLocalizedMessage

public String getLocalizedMessage()
Returns the localized message for the given locale.

Calls getLocalizedMessage(java.util.Locale) with argument list ( Locale.getDefault()).

Specified by:
getLocalizedMessage in interface CoreException
Overrides:
getLocalizedMessage in class Throwable
Returns:
returns the localized message of this exception.
See Also:
getLocalizedMessage(java.util.Locale)

getLocalizedMessage

public String getLocalizedMessage(Locale locale)
Returns the localized message for the given locale.

Calls getLocalizedMessage(java.util.Locale,ClassLoader) with argument list (<locale>, null).

Parameters:
locale - locale the locale for which the message is requested.
Returns:
returns the localized message of this exception.
See Also:
getLocalizedMessage(java.util.Locale, ClassLoader)

getLocalizedMessage

public String getLocalizedMessage(Locale locale,
                                  ClassLoader loader)
Returns the localized message for the given locale.

Calls getLocalizedMessage(String,java.util.Locale,de.smartics.exceptions.i18n.message.MessageType,java.lang.ClassLoader) with argument list (null, <locale>, MessageType.SUMMARY, <loader>).

Parameters:
locale - locale the locale for which the message is requested.
loader - loader the loader to read the message bundle.
Returns:
returns the localized message of this exception.
See Also:
getLocalizedMessage(String,java.util.Locale,de.smartics.exceptions.i18n.message.MessageType,java.lang.ClassLoader)

getLocalizedMessage

public String getLocalizedMessage(String keyPrefix,
                                  Locale locale,
                                  MessageType messageType,
                                  ClassLoader loader)
Returns the localized message for the given locale.

Parameters:
keyPrefix - the prefix of the key to load from the bundle.
locale - the locale for which the message is requested.
messageType - the type of message to localize.
loader - the loader to read the message bundle.
Returns:
returns the localized message of this exception.

getLocalizedTextMessage

public String getLocalizedTextMessage()
Returns the localized message for the given locale as formatted multi-line text.

Returns:
returns the localized message of this exception.
See Also:
getLocalizedMessage(java.util.Locale)

getLocalizedTextMessage

public String getLocalizedTextMessage(Locale locale)
Returns the localized message for the given locale as formatted multi-line text.

Parameters:
locale - locale the locale for which the message is requested.
Returns:
returns the localized message of this exception.
See Also:
getLocalizedMessage(java.util.Locale, ClassLoader)

getLocalizedTextMessage

public String getLocalizedTextMessage(Locale locale,
                                      ClassLoader loader)
Returns the localized message for the given locale as formatted multi-line text.

Parameters:
locale - locale the locale for which the message is requested.
loader - loader the loader to read the message bundle.
Returns:
returns the localized message of this exception.
See Also:
getLocalizedMessage(String,java.util.Locale,de.smartics.exceptions.i18n.message.MessageType,java.lang.ClassLoader)

getMessages

public String getMessages()
Returns the messages in one string. Useful to make a dump of all text information for all message types for debugging.

Uses the default locale to access the messages.

Specified by:
getMessages in interface LocalizedException
Returns:
a dump of all types of messages.
See Also:
LocalizedException.getMessages()

getMessages

public String getMessages(Locale locale)
Returns the messages in one string. Useful to make a dump of all text information for all message types for debugging.

Specified by:
getMessages in interface LocalizedException
Parameters:
locale - the locale to use for the dump.
Returns:
a dump of all types of messages.
See Also:
LocalizedException.getMessages(java.util.Locale)


Copyright © 2007-null Kronseder & Reiner GmbH - smartics. All Rights Reserved.