org.yasl.arch.impl.resources
Class YASLResourceManagerImpl

java.lang.Object
  extended byorg.yasl.arch.impl.resources.YASLResourceManagerImpl
All Implemented Interfaces:
YASLResourceManager

public class YASLResourceManagerImpl
extends Object
implements YASLResourceManager

Implements the YASLResourceManager interface.


Constructor Summary
YASLResourceManagerImpl()
          Sets locale to default locale (whatever the JVM is using).
YASLResourceManagerImpl(String defaultBundle)
           
 
Method Summary
 String getDefaultBundle()
          Returns the default bundle for the application's resource manager.
 Locale getLocale()
          Returns the current Locale being used by this resource manager.
 String getString(String bundle, String key)
          Loads a String associated with the passed key from the named resource bundle.
 String getString(String bundle, String key, Locale locale)
          Loads a String associated with the passed key from the named resource bundle based on the passed Locale.
 String getString(String bundle, String key, Locale locale, ClassLoader classLoader)
          Loads a String associated with the passed key from the named resource bundle based on the passed Locale.
 ImageIcon loadImageIcon(String iconName)
          Loads an image as an ImageIcon.
 ImageIcon loadImageIcon(String iconName, ClassLoader classLoader)
          Loads an image as an ImageIcon.
 ImageIcon loadImageIcon(String bundle, String key)
          Loads an image as an ImageIcon after getting the fully qualified package name from a resource bundle.
 ImageIcon loadImageIcon(String bundle, String key, Locale locale)
          Loads an image as an ImageIcon after getting the fully qualified package name from a resource bundle based on the passed Locale.
 void setLocale(Locale locale)
          Sets the Locale to be used by this resource manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

YASLResourceManagerImpl

public YASLResourceManagerImpl()
Sets locale to default locale (whatever the JVM is using).


YASLResourceManagerImpl

public YASLResourceManagerImpl(String defaultBundle)
Method Detail

getDefaultBundle

public String getDefaultBundle()
Returns the default bundle for the application's resource manager.

Specified by:
getDefaultBundle in interface YASLResourceManager
Returns:
String

getLocale

public Locale getLocale()
Returns the current Locale being used by this resource manager.

Specified by:
getLocale in interface YASLResourceManager
Returns:
Locale

getString

public String getString(String bundle,
                        String key,
                        Locale locale)
Loads a String associated with the passed key from the named resource bundle based on the passed Locale.

If the resource bundle or the key is not found, this method returns ???bundle??? or ???key???.

Specified by:
getString in interface YASLResourceManager
Parameters:
bundle - String
key - String
locale - Locale
Returns:
String

getString

public String getString(String bundle,
                        String key,
                        Locale locale,
                        ClassLoader classLoader)
Loads a String associated with the passed key from the named resource bundle based on the passed Locale.

This method also takes a ClassLoader. If you are trying to load strings from a properties file in a jar that was not on the initial classpath, you must pass in the classloader for the jar file.

Specified by:
getString in interface YASLResourceManager
Parameters:
bundle - String
key - String
locale - Locale
classLoader - ClassLoader
Returns:
String

getString

public String getString(String bundle,
                        String key)
Loads a String associated with the passed key from the named resource bundle.

If the resource bundle or the key is not found, this method returns ???bundle??? or ???key???.

Specified by:
getString in interface YASLResourceManager
Parameters:
bundle - String
key - String
Returns:
String

loadImageIcon

public ImageIcon loadImageIcon(String bundle,
                               String key)
Loads an image as an ImageIcon after getting the fully qualified package name from a resource bundle.

Will return null if the image cannot be loaded.

Specified by:
loadImageIcon in interface YASLResourceManager
Parameters:
bundle - String
key - String
Returns:
ImageIcon

loadImageIcon

public ImageIcon loadImageIcon(String bundle,
                               String key,
                               Locale locale)
Loads an image as an ImageIcon after getting the fully qualified package name from a resource bundle based on the passed Locale.

Will return null if the image cannot be loaded.

Specified by:
loadImageIcon in interface YASLResourceManager
Parameters:
bundle - String
key - String
locale - Locale
Returns:
ImageIcon

loadImageIcon

public ImageIcon loadImageIcon(String iconName)
Loads an image as an ImageIcon. Pass in image name with fully qualified package name. For example, /org/myapp/images/someicon.gif

Will return null when there are problems loading the image.

Specified by:
loadImageIcon in interface YASLResourceManager
Parameters:
iconName - String
Returns:
ImageIcon

loadImageIcon

public ImageIcon loadImageIcon(String iconName,
                               ClassLoader classLoader)
Loads an image as an ImageIcon. Pass in image name with fully qualified package name. For example, /org/myapp/images/someicon.gif

This method also takes a ClassLoader. If you are trying to load images from a jar that was not on the initial classpath, you must pass in the classloader for the jar file that was loaded at runtime.

Will return null when there are problems loading the image.

Specified by:
loadImageIcon in interface YASLResourceManager
Parameters:
iconName - String
classLoader - ClassLoader
Returns:
ImageIcon

setLocale

public void setLocale(Locale locale)
Sets the Locale to be used by this resource manager.

Specified by:
setLocale in interface YASLResourceManager
Parameters:
locale - Locale