multex
Class MsgText

java.lang.Object
  |
  +--multex.MsgText

public class MsgText
extends java.lang.Object

Services for getting the message text for exceptions. It handles exceptions

For normal message reporting you should use the services of one of the destination oriented reporting classes, e.g. Msg or Awt.

MulTEx 5: Parameter i_lineSeparator removed in all methods. Always uses the platform default. See the discussion in the description of class Msg.

Author:
Christoph Knabe, Berlin, Copyright 1999-2003

Field Summary
static java.lang.String causeMarker
          The String used by default to introduce the message of an exception, which was causing the exception justly reported.
static java.lang.String causeMarkerKey
          The key used to get the cause marker from a ResourceBundle.
static java.lang.String resourceBundleName
          The name of the ResourceBundle used on static default internationalization.
 
Method Summary
protected static void appendMessageChain(java.lang.StringBuffer io_destination, java.lang.Throwable i_throwable, java.util.ResourceBundle i_resourceBundle)
          Appends the message for i_throwable along with its causal chain.
static void appendMessageLine(java.lang.StringBuffer io_destination, java.lang.Throwable i_throwable)
          Appends the usually one-line message text for the exception i_throwable with inserted parameters to io_buffer.
static java.lang.String appendMessageLine(java.lang.StringBuffer io_destination, java.lang.Throwable i_throwable, java.util.ResourceBundle i_resourceBundle)
          Appends the usually one-line message text for the exception i_throwable with inserted parameters to io_buffer, localizable.
static java.util.ResourceBundle getResourceBundle()
          Returns the actual ResourceBundle used for static internationalization or null, if no one is provided.
static void setInternationalization(boolean i_internationalization)
          If true, activates the static default internationalization of message texts.
static void setInternationalization(java.util.ResourceBundle i_resourceBundle)
          Activates a specific static internationalization of message texts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resourceBundleName

public static final java.lang.String resourceBundleName
The name of the ResourceBundle used on static default internationalization.

See Also:
setInternationalization(boolean), Constant Field Values

causeMarker

public static final java.lang.String causeMarker
The String used by default to introduce the message of an exception, which was causing the exception justly reported. You can customize this by defining a cause marker in the localization ResourceBundle under the key causeMarkerKey.

See Also:
Constant Field Values

causeMarkerKey

public static final java.lang.String causeMarkerKey
The key used to get the cause marker from a ResourceBundle. It is the fully qualified name of the field causeMarker, In the .properties file for a localization you should define it e.g.:
multex.MsgText.causeMarker = Cause: 

Method Detail

setInternationalization

public static void setInternationalization(boolean i_internationalization)
If true, activates the static default internationalization of message texts. Further calls to appendMessageLine(java.lang.StringBuffer, java.lang.Throwable) or appendMessageChain(java.lang.StringBuffer, java.lang.Throwable, java.util.ResourceBundle) will deliver the localized message text for an exception instead of the default message text contained in the MultexException-object. The localized message text will be taken from the resource bundle with the name resourceBundleName. If false, deactivates static internationalization. The Message text for a MultexException will be taken directly from the exception object itself.

Since:
MulTEx 1c

setInternationalization

public static void setInternationalization(java.util.ResourceBundle i_resourceBundle)
                                    throws java.lang.IllegalArgumentException
Activates a specific static internationalization of message texts. Further calls to appendMessageLine(java.lang.StringBuffer, java.lang.Throwable) or appendMessageChain(java.lang.StringBuffer, java.lang.Throwable, java.util.ResourceBundle) will deliver the localized message text for an exception instead of the default message text contained in the MultexException-object.

Parameters:
i_resourceBundle - How to localize exception message texts
Throws:
java.lang.IllegalArgumentException - If null is provided as i_locale
Since:
MulTEx 4
See Also:
setInternationalization(boolean)

getResourceBundle

public static java.util.ResourceBundle getResourceBundle()
Returns the actual ResourceBundle used for static internationalization or null, if no one is provided.


appendMessageChain

protected static void appendMessageChain(java.lang.StringBuffer io_destination,
                                         java.lang.Throwable i_throwable,
                                         java.util.ResourceBundle i_resourceBundle)
Appends the message for i_throwable along with its causal chain. Preferably use Msg.printMessages(StringBuffer,Throwable,ResourceBundle) instead.


appendMessageLine

public static void appendMessageLine(java.lang.StringBuffer io_destination,
                                     java.lang.Throwable i_throwable)
Appends the usually one-line message text for the exception i_throwable with inserted parameters to io_buffer. The message text pattern for the exception is taken from the mostly localized variant of the properties file "MsgText.properties" or helpwise from the default message text pattern in the exception object itself. A local message text pattern for the german language (de) in its swiss (CH) variant would be taken from file "MsgText_de_CH.properties", see the Java Tutorial chapter on internationalization at february 1999.

This file must contain definition lines of the form:

      packageName.ExceptionName = message text pattern
   
or
      packageName.ClassName$InnerExceptionName = message text pattern
   
with parameter substitutors in the message text pattern, e.g.:
      CopyNP$CopyFailure = The file "{0}" could not be copied to "{1}"
   


appendMessageLine

public static java.lang.String appendMessageLine(java.lang.StringBuffer io_destination,
                                                 java.lang.Throwable i_throwable,
                                                 java.util.ResourceBundle i_resourceBundle)
Appends the usually one-line message text for the exception i_throwable with inserted parameters to io_buffer, localizable.

The message line format is produced according to the following case list:

Parameters:
i_resourceBundle - Source for the message text pattern for reporting i_throwable. The text pattern is taken with the class name of i_throwable as key from i_resourceBundle. Controls the formatting of the message parameters, too, by containing a Locale. If null, falls back to no internationalization.
Returns:
The appended line, if it was created by i_throwable.toString() If not null, i_throwable had neither a text pattern, nor message parameters. Useful only for efficiently deleting redundant info in legacy string chain of platform exceptions.
See Also:
for details of parameter substitution