info.magnolia.cms.i18n
Class AbstractMessagesImpl

java.lang.Object
  extended by info.magnolia.cms.i18n.AbstractMessagesImpl
All Implemented Interfaces:
Messages
Direct Known Subclasses:
DefaultMessagesImpl, EmptyMessages, MessagesChain

public abstract class AbstractMessagesImpl
extends Object
implements Messages

Provides localized strings. You should uses the ContextMessages class if you can provide a request object. AbstractMessagesImpl will do the job as good as possible without to know the session (user) and all the other contextual things. Endusers will use the MessageManager to resolve messages.

Version:
$Id$
Author:
Philipp Bracher

Field Summary
protected  String basename
          The name of the bundle.
protected  ResourceBundle bundle
          The current bundle.
static String JS_OBJECTNAME
          Name of the javascript object used to make the messages public to the javascripts.
protected  Locale locale
          The current locale.
protected  org.slf4j.Logger log
           
 
Constructor Summary
protected AbstractMessagesImpl(String basename, Locale locale)
           
 
Method Summary
 boolean equals(Object arg0)
          True if the basename and the locale are the same.
 String get(String key, Object[] args)
          Replace the {n} parameters in the string.
 String getBasename()
          If no basename is provided this method returns DEFAULT_BASENAME.
 Locale getLocale()
          Returns the current locale.
 String getWithDefault(String key, Object[] args, String defaultMsg)
          With default value and replacement strings.
 String getWithDefault(String key, String defaultMsg)
          You can provide a default value if the key is not found.
 String toString()
          Nice string.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface info.magnolia.cms.i18n.Messages
get, keys, reload
 

Field Detail

log

protected org.slf4j.Logger log

JS_OBJECTNAME

public static final String JS_OBJECTNAME
Name of the javascript object used to make the messages public to the javascripts.

See Also:
Constant Field Values

basename

protected String basename
The name of the bundle.


locale

protected Locale locale
The current locale.


bundle

protected ResourceBundle bundle
The current bundle. Subclasses will overwrite getBundle().

Constructor Detail

AbstractMessagesImpl

protected AbstractMessagesImpl(String basename,
                               Locale locale)
Method Detail

getLocale

public Locale getLocale()
Returns the current locale.

Specified by:
getLocale in interface Messages
Returns:
current locale

getBasename

public String getBasename()
If no basename is provided this method returns DEFAULT_BASENAME.

Specified by:
getBasename in interface Messages
Returns:
current basename

get

public String get(String key,
                  Object[] args)
Replace the {n} parameters in the string.

Specified by:
get in interface Messages
See Also:
MessageFormat.format(String, Object[])

getWithDefault

public String getWithDefault(String key,
                             String defaultMsg)
You can provide a default value if the key is not found.

Specified by:
getWithDefault in interface Messages
Parameters:
key - key
defaultMsg - the default message
Returns:
the message

getWithDefault

public String getWithDefault(String key,
                             Object[] args,
                             String defaultMsg)
With default value and replacement strings.

Specified by:
getWithDefault in interface Messages
Parameters:
key - key
args - replacement strings
defaultMsg - default message
Returns:
message

equals

public boolean equals(Object arg0)
True if the basename and the locale are the same.

Overrides:
equals in class Object

toString

public String toString()
Nice string.

Overrides:
toString in class Object


Copyright © 2003–2014 Magnolia International Ltd.. All rights reserved.