it.eng.spagobi.commons.utilities.messages
Class MessageBuilder

java.lang.Object
  extended by it.eng.spagobi.commons.utilities.messages.MessageBuilder
All Implemented Interfaces:
IMessageBuilder

public class MessageBuilder
extends java.lang.Object
implements IMessageBuilder


Constructor Summary
MessageBuilder()
           
 
Method Summary
static java.util.Locale getBrowserLocaleFromSpago()
           
 java.util.Locale getLocale(javax.servlet.http.HttpServletRequest request)
           
 java.lang.String getMessage(java.lang.String code)
          Returns the message associated with code in the default bundle
 java.lang.String getMessage(java.lang.String code, javax.servlet.http.HttpServletRequest request)
          Returns the message associated with code in the default bundle.
 java.lang.String getMessage(java.lang.String code, javax.servlet.http.HttpServletRequest request, java.util.Locale locale)
          If the specified locale is valid, returns the message associated with code in the default bundle with the specified locale; otherwise returns the message associated with code in the default bundle with request locale.
 java.lang.String getMessage(java.lang.String code, java.util.Locale locale)
          If the specified locale is valid, returns the message associated with code in the default bundle with the specified locale; otherwise returns the message associated with code in the default bundle with default locale.
 java.lang.String getMessage(java.lang.String code, java.lang.String bundle)
          Returns the message associated with code in the given bundle.
 java.lang.String getMessage(java.lang.String code, java.lang.String bundle, javax.servlet.http.HttpServletRequest request)
          Returns the message associated with code in the given bundle.
 java.lang.String getMessage(java.lang.String code, java.lang.String bundle, javax.servlet.http.HttpServletRequest request, java.util.Locale locale)
          If the specified locale is valid, returns the message associated with code in the input bundle with the specified locale; otherwise returns the message associated with code in the input bundle with request locale.
 java.lang.String getMessage(java.lang.String code, java.lang.String bundle, java.util.Locale locale)
          If the specified locale is valid, returns the message associated with code in the input bundle with the specified locale; otherwise returns the message associated with code in the input bundle with default locale.
 java.lang.String getMessageTextFromResource(java.lang.String resourceName, javax.servlet.http.HttpServletRequest request)
          Gets a localized information text given the resource name which contains the text information.
 java.lang.String getMessageTextFromResource(java.lang.String resourceName, java.util.Locale locale)
          If the specified locale is valid, returns the localized text contained into the resource with the specified locale; otherwise returns the localized text contained into the resource with default locale.
 java.lang.String getSpagoBIMode(javax.servlet.http.HttpServletRequest request)
           
 java.lang.String getUserMessage(java.lang.String code, java.lang.String bundle, javax.servlet.http.HttpServletRequest request)
          Returns the message associated with code in the given bundle only if starts with #.
 java.lang.String getUserMessage(java.lang.String code, java.lang.String bundle, java.util.Locale locale)
          Returns the message associated with code in the given bundle only if starts with #.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageBuilder

public MessageBuilder()
Method Detail

getMessageTextFromResource

public java.lang.String getMessageTextFromResource(java.lang.String resourceName,
                                                   java.util.Locale locale)
Description copied from interface: IMessageBuilder
If the specified locale is valid, returns the localized text contained into the resource with the specified locale; otherwise returns the localized text contained into the resource with default locale.

Specified by:
getMessageTextFromResource in interface IMessageBuilder
Parameters:
resourceName - The complete name of the resource
locale - the locale
Returns:
if the specified locale is valid, returns the localized text contained into the resource with the specified locale; otherwise returns the localized text contained into the resource with default locale

getMessage

public java.lang.String getMessage(java.lang.String code)
Description copied from interface: IMessageBuilder
Returns the message associated with code in the default bundle

Specified by:
getMessage in interface IMessageBuilder

getMessage

public java.lang.String getMessage(java.lang.String code,
                                   java.util.Locale locale)
Description copied from interface: IMessageBuilder
If the specified locale is valid, returns the message associated with code in the default bundle with the specified locale; otherwise returns the message associated with code in the default bundle with default locale.

Specified by:
getMessage in interface IMessageBuilder
Parameters:
code - the code
locale - the locale
Returns:
if the specified locale is valid, returns the message associated with code in the default bundle with the specified locale; otherwise returns the message associated with code in the default bundle with default locale

getMessage

public java.lang.String getMessage(java.lang.String code,
                                   java.lang.String bundle)
Description copied from interface: IMessageBuilder
Returns the message associated with code in the given bundle.

Specified by:
getMessage in interface IMessageBuilder
Parameters:
code - the code
bundle - the bundle
Returns:
the message associated with code in the given bundle

getMessage

public java.lang.String getMessage(java.lang.String code,
                                   java.lang.String bundle,
                                   java.util.Locale locale)
Description copied from interface: IMessageBuilder
If the specified locale is valid, returns the message associated with code in the input bundle with the specified locale; otherwise returns the message associated with code in the input bundle with default locale.

Specified by:
getMessage in interface IMessageBuilder
Parameters:
code - the code
bundle - the bundle
locale - the locale
Returns:
if the specified locale is valid, returns the message associated with code in the input bundle with the specified locale; otherwise returns the message associated with code in the input bundle with default locale

getMessage

public java.lang.String getMessage(java.lang.String code,
                                   javax.servlet.http.HttpServletRequest request)
Description copied from interface: IMessageBuilder
Returns the message associated with code in the default bundle.

Specified by:
getMessage in interface IMessageBuilder
Parameters:
code - the code
request - the request
Returns:
the message associated with code in the default bundle

getMessage

public java.lang.String getMessage(java.lang.String code,
                                   javax.servlet.http.HttpServletRequest request,
                                   java.util.Locale locale)
Description copied from interface: IMessageBuilder
If the specified locale is valid, returns the message associated with code in the default bundle with the specified locale; otherwise returns the message associated with code in the default bundle with request locale.

Specified by:
getMessage in interface IMessageBuilder
Parameters:
code - the code
request - the request
locale - the locale
Returns:
if the specified locale is valid, returns the message associated with code in the default bundle with the specified locale; otherwise returns the message associated with code in the default bundle with request locale

getMessage

public java.lang.String getMessage(java.lang.String code,
                                   java.lang.String bundle,
                                   javax.servlet.http.HttpServletRequest request)
Description copied from interface: IMessageBuilder
Returns the message associated with code in the given bundle.

Specified by:
getMessage in interface IMessageBuilder
Parameters:
code - the code
bundle - the bundle
request - the request
Returns:
the message associated with code in the given bundle

getUserMessage

public java.lang.String getUserMessage(java.lang.String code,
                                       java.lang.String bundle,
                                       javax.servlet.http.HttpServletRequest request)
Description copied from interface: IMessageBuilder
Returns the message associated with code in the given bundle only if starts with #.

Specified by:
getUserMessage in interface IMessageBuilder
Parameters:
code - the code
bundle - the bundle
request - the request
Returns:
the message associated with code in the given bundle

getUserMessage

public java.lang.String getUserMessage(java.lang.String code,
                                       java.lang.String bundle,
                                       java.util.Locale locale)
Description copied from interface: IMessageBuilder
Returns the message associated with code in the given bundle only if starts with #.

Specified by:
getUserMessage in interface IMessageBuilder
Parameters:
code - the code
bundle - the bundle
locale - the locale
Returns:
the message associated with code in the given bundle

getMessage

public java.lang.String getMessage(java.lang.String code,
                                   java.lang.String bundle,
                                   javax.servlet.http.HttpServletRequest request,
                                   java.util.Locale locale)
Description copied from interface: IMessageBuilder
If the specified locale is valid, returns the message associated with code in the input bundle with the specified locale; otherwise returns the message associated with code in the input bundle with request locale.

Specified by:
getMessage in interface IMessageBuilder
Parameters:
code - the code
bundle - the bundle
request - the request
locale - the locale
Returns:
if the specified locale is valid, returns the message associated with code in the input bundle with the specified locale; otherwise returns the message associated with code in the input bundle with request locale

getBrowserLocaleFromSpago

public static java.util.Locale getBrowserLocaleFromSpago()

getLocale

public java.util.Locale getLocale(javax.servlet.http.HttpServletRequest request)

getSpagoBIMode

public java.lang.String getSpagoBIMode(javax.servlet.http.HttpServletRequest request)

getMessageTextFromResource

public java.lang.String getMessageTextFromResource(java.lang.String resourceName,
                                                   javax.servlet.http.HttpServletRequest request)
Description copied from interface: IMessageBuilder
Gets a localized information text given the resource name which contains the text information. The resource will be searched into the classpath of the application

Specified by:
getMessageTextFromResource in interface IMessageBuilder
Parameters:
resourceName - The complete name of the resource.
request - The http request for locale retrieving
Returns:
the localized text contained into the resource