org.tigris.scarab.tools.localization
Interface Localizable

All Known Subinterfaces:
LocalizationKey
All Known Implementing Classes:
L10NKey, L10NMessage, ScarabLocalizedTorqueException, ScarabLocalizedTurbineSecurityException

public interface Localizable

Interface identifying instances capable of being localized using a ScarabLocalizationTool instance.

In order to localize throwables, one could reuse the following pattern: public class MyLocalizedThrowable extends MyThrowableClass implements Localizable { // may be null private ScarabLocalizationTool localizer; // Set the localizer to be used in later calls to #getLocalizedMessage() // @param theLocalizer the localizer (may be null) public void setLocalizer(final ScarabLocalizationTool theLocalizer) { localizer = theLocalizer; } // Return the localized message for that throwable, if a localizer // was defined using #setLocalizer(ScarabLocalizationTool) // @return the localized message. public String getLocalizedMessage() { // we effectively implement an IoC pattern, made necessary by // the design of the Throwable base class if (localizer != null) { return toString(localizer); } else { return super.getLocalizedMessage(); } } } This should be particularly thought when one subclasses instances from a different framework, because that framework may be or may become localized one day.

Version:
$Id: Localizable.java 9104 2004-05-10 21:04:51Z dabbous $
Author:
Hussayn Dabbous

Method Summary
 java.lang.String getMessage()
          resolve the instance to the ScarabLocalizationTool.DEFAULT_LOCALE Note: This method should return english messages independent of any l10n settings.
 java.lang.String getMessage(ScarabLocalizationTool l10n)
          resolve the message according to the parameters of the given ScarabLocalizationTool instance.
 

Method Detail

getMessage

public java.lang.String getMessage()
resolve the instance to the ScarabLocalizationTool.DEFAULT_LOCALE Note: This method should return english messages independent of any l10n settings. If a ScarabLocalizationTool instance is available, it is preferreable to use resolve(ScarabLocalizationTool) instead.

Returns:
the resolved String

getMessage

public java.lang.String getMessage(ScarabLocalizationTool l10n)
resolve the message according to the parameters of the given ScarabLocalizationTool instance. It may contain L10NMessage instances and Exceptions. The parameters should be resolved recursively if necessary.

Returns:


Copyright © 2000-2004 Tigris.org. All Rights Reserved.