de.smartics.exceptions.i18n
Class AbstractMessageException

Package class diagram package AbstractMessageException
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.AbstractMessageException
All Implemented Interfaces:
CoreException, LocalizedException, Serializable

public abstract class AbstractMessageException
     
     
extends AbstractCoreException
implements LocalizedException

The base implementation of exceptions that support internationalization for checked exceptions and whose message information is based on a message bean.

See Also:
Serialized Form

Field Summary
protected  MessageBean messageBean
          The message information for the exception.
 
Fields inherited from class de.smartics.exceptions.AbstractCoreException
info
 
Constructor Summary
protected AbstractMessageException(Code code)
          Constructor without message bean.
protected AbstractMessageException(Code code, String bundleBaseName)
          Constructor without message bean.
protected AbstractMessageException(MessageBean messageBean)
          Default constructor for message bean aware exception types.
protected AbstractMessageException(Throwable cause, Code code)
          Constructor without message bean.
protected AbstractMessageException(Throwable cause, Code code, String bundleBaseName)
          Constructor without message bean.
protected AbstractMessageException(Throwable cause, Code code, String bundleBaseName, String resourceKey)
          Constructor without message bean.
 
Method Summary
 Messages createMessages()
          Returns a created messages instance.
 Messages createMessages(Locale locale)
          Returns a created messages instance.
 CauseTrailMessages getCauseTrail()
          Returns the cause trail of messages.
 CauseTrailMessages getCauseTrail(Locale locale)
          Returns the cause trail of messages.
 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>).
 MessageBean getMessageBean()
          Returns the message information for the exception.
 String getMessages()
          Returns the messages in one string.
 String getMessages(Locale locale)
          Returns the messages in one string.
 String toString()
          Returns the string representation of the exception.
 
Methods inherited from class de.smartics.exceptions.AbstractCoreException
getCause, getCode, getId, getTime, 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

messageBean

protected final MessageBean messageBean
The message information for the exception.

Constructor Detail

AbstractMessageException

protected AbstractMessageException(Code code)
Constructor without message bean.

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

AbstractMessageException

protected AbstractMessageException(Code code,
                                   String bundleBaseName)
Constructor without message bean.

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

AbstractMessageException

protected AbstractMessageException(Throwable cause,
                                   Code code)
Constructor without message bean.

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.

AbstractMessageException

protected AbstractMessageException(Throwable cause,
                                   Code code,
                                   String bundleBaseName)
Constructor without message bean.

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.

AbstractMessageException

protected AbstractMessageException(Throwable cause,
                                   Code code,
                                   String bundleBaseName,
                                   String resourceKey)
Constructor without message bean.

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.

AbstractMessageException

protected AbstractMessageException(MessageBean messageBean)
Default constructor for message bean aware exception types.

Parameters:
messageBean - the message information for the exception.
Method Detail

getMessageBean

public MessageBean getMessageBean()
Returns the message information for the exception.

Allowed to be overridden to return covariant.

Returns:
the message information for the exception.

getMessage

public final 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).

getMessage

public final 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.
See Also:
getMessage(java.util.Locale, de.smartics.exceptions.i18n.message.MessageType)
Returns:
the message for the given type.

getMessage

public final String getMessage(Locale locale,
                               MessageType messageType)
Description copied from interface: LocalizedException
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.

getLocalizedMessage

public final 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
See Also:
getLocalizedMessage(java.util.Locale)
Returns:
returns the localized message of this exception.

getLocalizedMessage

public final 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.
See Also:
getLocalizedMessage(java.util.Locale, ClassLoader)
Returns:
returns the localized message of this exception.

getLocalizedMessage

public final 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.
See Also:
getLocalizedMessage(String,java.util.Locale,de.smartics.exceptions.i18n.message.MessageType,java.lang.ClassLoader)
Returns:
returns the localized message of this exception.

getLocalizedMessage

public final 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 final String getLocalizedTextMessage()
Returns the localized message for the given locale as formatted multi-line text.

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

getLocalizedTextMessage

public final 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.
See Also:
getLocalizedMessage(java.util.Locale, ClassLoader)
Returns:
returns the localized message of this exception.

getLocalizedTextMessage

public final 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.
See Also:
getLocalizedMessage(String,java.util.Locale,de.smartics.exceptions.i18n.message.MessageType,java.lang.ClassLoader)
Returns:
returns the localized message of this exception.

getMessages

public final String getMessages()
Description copied from interface: LocalizedException
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.

getMessages

public final String getMessages(Locale locale)
Description copied from interface: LocalizedException
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.

createMessages

public final Messages createMessages()
Description copied from interface: LocalizedException
Returns a created messages instance.

Uses the default locale to access the messages.

Specified by:
createMessages in interface LocalizedException
Returns:
messages of all types.

createMessages

public final Messages createMessages(Locale locale)
Description copied from interface: LocalizedException
Returns a created messages instance.

Specified by:
createMessages in interface LocalizedException
Parameters:
locale - the locale to use for the dump.
Returns:
messages of all types.

getCauseTrail

public final CauseTrailMessages getCauseTrail()
Description copied from interface: LocalizedException
Returns the cause trail of messages. These are all messages of the cause to the root cause.

Specified by:
getCauseTrail in interface LocalizedException
Returns:
the cause trail of messages.

getCauseTrail

public final CauseTrailMessages getCauseTrail(Locale locale)
Description copied from interface: LocalizedException
Returns the cause trail of messages. These are all messages of the cause to the root cause.

Specified by:
getCauseTrail in interface LocalizedException
Parameters:
locale - the locale to use for the dump.
Returns:
the cause trail of messages.

toString

public String toString()
Returns the string representation of the exception.

May be overridden by subclasses in an application (not a library) to change the string representation. Usually an implementation of I18nCodeMessageFormatter should be set to the ExceptionContext.

Overrides:
toString in class AbstractCoreException
Returns:
the string representation of the object.


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