Regain 2.1.0-STABLE API

net.sf.regain.util.io
Class Localizer

java.lang.Object
  extended by net.sf.regain.util.io.Localizer

public class Localizer
extends Object

Author:
Til Schneider, www.murfman.de

Field Summary
private  ResourceBundle mBundle
          The ResourceBundle to get the messages from.
private static HashMap mFileClassLoaderHash
          Holds for a directory (File) an URLClassLoader that loads ressources from that directory (URLClassLoader).
private  String mKeyPrefix
          The prefix to put before every key.
private static org.apache.log4j.Logger mLog
          The logger for this class.
 
Constructor Summary
Localizer(Class clazz)
          Creates a new instance of Localizer.
Localizer(Class clazz, Locale locale)
          Creates a new instance of Localizer.
Localizer(URL baseurl, String basename, Locale locale)
          Creates a new instance of Localizer.
 
Method Summary
private static URLClassLoader getClassLoader(URL baseurl)
          Gets a class loader that loads ressources from a directory.
 String msg(String key, String defaultMsg)
          Gets a localized message.
 String msg(String key, String defaultMsg, Object arg1)
          Gets a localized message.
 String msg(String key, String defaultMsg, Object[] args)
          Gets a localized message.
 String msg(String key, String defaultMsg, Object arg1, Object arg2)
          Gets a localized message.
 String msg(String key, String defaultMsg, Object arg1, Object arg2, Object arg3)
          Gets a localized message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mLog

private static org.apache.log4j.Logger mLog
The logger for this class.


mBundle

private ResourceBundle mBundle
The ResourceBundle to get the messages from.


mKeyPrefix

private String mKeyPrefix
The prefix to put before every key.


mFileClassLoaderHash

private static HashMap mFileClassLoaderHash
Holds for a directory (File) an URLClassLoader that loads ressources from that directory (URLClassLoader).

Constructor Detail

Localizer

public Localizer(URL baseurl,
                 String basename,
                 Locale locale)
Creates a new instance of Localizer.

Parameters:
baseurl - The URL to load the resource bundle from.
basename - The basename of the resource bundle to load.
locale - the locale to create the localizer for.

Localizer

public Localizer(Class clazz)
Creates a new instance of Localizer.

Parameters:
clazz - The class to create the Localizer for.

Localizer

public Localizer(Class clazz,
                 Locale locale)
Creates a new instance of Localizer.

Parameters:
clazz - The class to create the Localizer for.
locale - the locale to create the localizer for.
Method Detail

getClassLoader

private static URLClassLoader getClassLoader(URL baseurl)
                                      throws MalformedURLException
Gets a class loader that loads ressources from a directory.

Parameters:
baseurl - The URL to load the ressources from.
Returns:
The class loader
Throws:
MalformedURLException - If the file could not be converted to an URL.

msg

public String msg(String key,
                  String defaultMsg,
                  Object arg1)
Gets a localized message.

Parameters:
key - The key of the message.
defaultMsg - The default message. (english)
arg1 - The argument that should replace {0}.
Returns:
a localized message.

msg

public String msg(String key,
                  String defaultMsg,
                  Object arg1,
                  Object arg2)
Gets a localized message.

Parameters:
key - The key of the message.
defaultMsg - The default message. (english)
arg1 - The argument that should replace {0}.
arg2 - The argument that should replace {1}.
Returns:
a localized message.

msg

public String msg(String key,
                  String defaultMsg,
                  Object arg1,
                  Object arg2,
                  Object arg3)
Gets a localized message.

Parameters:
key - The key of the message.
defaultMsg - The default message. (english)
arg1 - The argument that should replace {0}.
arg2 - The argument that should replace {1}.
arg3 - The argument that should replace {2}.
Returns:
a localized message.

msg

public String msg(String key,
                  String defaultMsg,
                  Object[] args)
Gets a localized message.

Parameters:
key - The key of the message.
defaultMsg - The default message. (english)
args - The arguments that should replace the appropriate place holder. See MessageFormat for details.
Returns:
a localized message.

msg

public String msg(String key,
                  String defaultMsg)
Gets a localized message.

Parameters:
key - The key of the message.
defaultMsg - The default message. (english)
Returns:
a localized message.

Regain 2.1.0-STABLE API

Regain 2.1.0-STABLE, Copyright (C) 2004-2010 Til Schneider, www.murfman.de, Thomas Tesche, www.clustersystems.info