de.smartics.exceptions.i18n.message
Class LocalizedInfo

Package class diagram package LocalizedInfo
java.lang.Object
  extended by de.smartics.exceptions.i18n.message.LocalizedInfo
All Implemented Interfaces:
Serializable

public class LocalizedInfo
     
     
extends Object
implements Serializable

Controls the localized information for a throwable.

See Also:
Serialized Form

Field Summary
static String BUNDLE_NAME_SUFFIX
          The suffix for the auto generated bundle name.
protected  String bundleBaseName
          The fully qualified base name of the bundle to use.
protected  Throwable cause
          The cause to the problem.
protected  String resourceKey
          The localization key to fetch messages from message bundles.
 
Constructor Summary
LocalizedInfo(Code code)
          Convenience constructor.
LocalizedInfo(Code code, String bundleBaseName, String resourceKey)
          Convenience constructor without cause trail.
LocalizedInfo(Code code, Throwable cause)
          Convenience constructor.
LocalizedInfo(Code code, Throwable cause, String bundleBaseName, String resourceKey)
          Default constructor.
 
Method Summary
 String createLocalizedMessage(Object bean, String keyPrefix, Locale locale, MessageType messageType, ClassLoader loader)
          Creates a localized message.
 String createMessage(Object bean, String keyPrefix, MessageType messageType, ClassLoader loader)
          Creates a message.
 String getBundleBaseName()
          Returns the fully qualified base name of the bundle to use.
 Throwable getCause()
          Returns the cause to the exception.
 CauseTrailMessages getCauseTrail()
          Returns the messages of the cause up to the root cause.
 CauseTrailMessages getCauseTrail(Locale locale)
          Returns the messages of the cause up to the root cause.
 String getLocalizedMessage(Object bean, Locale locale, ClassLoader loader)
          Returns the localized message for the given locale.
 String getLocalizedMessage(Object bean, String keyPrefix, Locale locale, MessageType messageType, ClassLoader loader)
          Returns the localized message for the given locale.
 String getLocalizedSingleLineMessage(Object bean, Locale locale, ClassLoader loader, boolean standard)
          Returns the localized message for the given locale.
 String getLocalizedTextMessage(Object bean, Locale locale, ClassLoader loader)
          Returns the structured and localized message for the given locale, returning each part of information that is provided.
 String getResourceKey()
          Returns the localization key to fetch messages from message bundles.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUNDLE_NAME_SUFFIX

public static final String BUNDLE_NAME_SUFFIX
The suffix for the auto generated bundle name.

The value of this constant is "Bundle".

Constant Field Value:
"Bundle"

resourceKey

protected final String resourceKey
The localization key to fetch messages from message bundles. If this value is not set, the String representation of the provided code instance is used.


bundleBaseName

protected final String bundleBaseName
The fully qualified base name of the bundle to use.

This bundle base name must never be null.


cause

protected final Throwable cause
The cause to the problem.

Constructor Detail

LocalizedInfo

public LocalizedInfo(Code code)
Convenience constructor.

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

LocalizedInfo

public LocalizedInfo(Code code,
                     Throwable cause)
Convenience constructor.

Parameters:
code - the error or exception code of the exception.
cause - the cause to the problem.

LocalizedInfo

public LocalizedInfo(Code code,
                     String bundleBaseName,
                     String resourceKey)
Convenience constructor without cause trail.

Parameters:
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.

LocalizedInfo

public LocalizedInfo(Code code,
                     Throwable cause,
                     String bundleBaseName,
                     String resourceKey)
Default constructor.

Parameters:
code - the error or exception code of the exception.
cause - the cause to the problem.
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()
Returns the localization key to fetch messages from message bundles. If this value is not set, the String representation of the code instance is used.

Returns:
the localization key to fetch messages from message bundles.

getBundleBaseName

public String getBundleBaseName()
Returns the fully qualified base name of the bundle to use.

Returns:
the fully qualified base name of the bundle to use.

getLocalizedMessage

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

Parameters:
bean - the throwable to construct the localized message.
locale - the locale for which the message is requested.
loader - the loader to read the message bundle.
Returns:
returns the localized message of this exception.

getLocalizedSingleLineMessage

public String getLocalizedSingleLineMessage(Object bean,
                                            Locale locale,
                                            ClassLoader loader,
                                            boolean standard)
Returns the localized message for the given locale.

Parameters:
bean - the throwable to construct the localized message.
locale - the locale for which the message is requested.
loader - the loader to read the message bundle.
standard - the flag that adds all information to the exception text ( true) or only the summary ( false).
Returns:
returns the localized message of this exception.

getLocalizedTextMessage

public String getLocalizedTextMessage(Object bean,
                                      Locale locale,
                                      ClassLoader loader)
Returns the structured and localized message for the given locale, returning each part of information that is provided.

Parameters:
bean - the throwable to construct the localized message.
locale - the locale for which the message is requested.
loader - the loader to read the message bundle.
Returns:
returns the localized message of this exception.

getLocalizedMessage

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

Parameters:
bean - the throwable to construct the localized message.
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.

createLocalizedMessage

public String createLocalizedMessage(Object bean,
                                     String keyPrefix,
                                     Locale locale,
                                     MessageType messageType,
                                     ClassLoader loader)
Creates a localized message.

Parameters:
bean - the throwable to construct the localized message.
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.

createMessage

public String createMessage(Object bean,
                            String keyPrefix,
                            MessageType messageType,
                            ClassLoader loader)
Creates a message.

Parameters:
bean - the throwable to construct the localized message.
keyPrefix - the prefix of the key to load from the bundle.
messageType - the type of message to localize.
loader - the loader to read the message bundle.
Returns:
returns the message of this exception.

getCauseTrail

public final CauseTrailMessages getCauseTrail()
Returns the messages of the cause up to the root cause.

Returns:
the messages of the cause up to the root cause.

getCause

public final Throwable getCause()
Returns the cause to the exception. May be null.

Returns:
the cause to the exception. May be null.

getCauseTrail

public final CauseTrailMessages getCauseTrail(Locale locale)
Returns the messages of the cause up to the root cause.

Parameters:
locale - the locale for which the message is requested.
Returns:
the messages of the cause up to the root cause.


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