IBM Rational Software Modeler
Release 6.0

com.ibm.xtools.patterns.framework.l10n
Class AbstractResourceManager

java.lang.Object
  extended bycom.ibm.xtools.patterns.framework.l10n.AbstractResourceManager
Direct Known Subclasses:
ResourceManager

public abstract class AbstractResourceManager
extends Object

AbstractResourceManager is a minimal copy of the abstract class com.ibm.xtools.common.core.internal.l10n.AbstractResourceManager needed to implement the resource requirements of the patterns framework without using any non-public classes.

The code here is plagerized.


Nested Class Summary
 class AbstractResourceManager.EmptyResourceBundle
          The EmptyResourceBundle represents a resource bundle object that is always empty.
 
Constructor Summary
protected AbstractResourceManager()
          Create a resource manager instance and initialize resources it will manage.
 
Method Summary
protected  ResourceBundle createMessagesBundle()
          Load messages resource bundle.
protected  ResourceBundle getMessagesBundle()
          Returns the messageBundle.
protected  String getMessagesBundleDefaultName()
          Returns default name for the messages bundle.
protected  String getMessagesBundleName()
          Returns the name of the messages bundle, including the package path.
protected  String getPackageName()
          Returns a package name of the class of this object
protected abstract  Plugin getPlugin()
          Returns the plugin that hosts the resource manager
 String getString(String key)
          Returns the string from the plugin's resource bundle, or 'key' if not found.
 String getString(String key, String defaultValue)
          Returns the string from the plugin's resource bundle, or the defaultValue if not found.
protected  void initializeMessageResources()
          Populate messageBundle with text related resources from the MessageBundle properties file.
protected abstract  void initializeResources()
          Load various resources - text, images, fonts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractResourceManager

protected AbstractResourceManager()
Create a resource manager instance and initialize resources it will manage. Subclasses should be declared final and have a singleton instance. If names of the messages bundle is different from the default the subclasses should override: getMessagesBundleDefaultName()

Method Detail

getMessagesBundle

protected ResourceBundle getMessagesBundle()
Returns the messageBundle. Resource bundles contain locale-specific objects - text, numbers, etc.

Returns:
the message bundle

getPackageName

protected String getPackageName()
Returns a package name of the class of this object

Returns:
- the full name if the client resource package

getMessagesBundleName

protected String getMessagesBundleName()
Returns the name of the messages bundle, including the package path. E.g. for messages.properties file located at com.ibm.xtools.patterns.framework.l10n the name returned will be com.ibm.xtools.patterns.framework.l10n.messages

Returns:
- messages bundle name

getPlugin

protected abstract Plugin getPlugin()
Returns the plugin that hosts the resource manager

Returns:
Plugin the plugin that hosts the resource manager

initializeResources

protected abstract void initializeResources()
Load various resources - text, images, fonts. Do nothing by default. Subclasses should override this method to include initialization of the particular resource types.

See Also:
initializeMessageResources()

initializeMessageResources

protected void initializeMessageResources()
Populate messageBundle with text related resources from the MessageBundle properties file. This method provides single assignment point to the private variable messagesBundle. To override default initialization subclasses should override createMessagesBundle()

See Also:
createMessagesBundle()

createMessagesBundle

protected ResourceBundle createMessagesBundle()
Load messages resource bundle. If resource bundle is missing, this method creates an instance of EmptyResourceBundle and returns that as a default value.

Returns:
- messages resource bundle

getString

public String getString(String key)
Returns the string from the plugin's resource bundle, or 'key' if not found.

Parameters:
key - - the key for the value to be retrieved
Returns:
- value for the given key or the key if value

getString

public String getString(String key,
                        String defaultValue)
Returns the string from the plugin's resource bundle, or the defaultValue if not found.

Parameters:
key - - the key to retrieve the value
defaultValue - - the default value to return if no value by the given key was found
Returns:
- value for the given key or the suuplied default if value was not found

getMessagesBundleDefaultName

protected String getMessagesBundleDefaultName()
Returns default name for the messages bundle. Subclasses should override if the messages bundle name differs from the default

Returns:
- default name for the messages bundle

IBM Rational Software Modeler
Release 6.0


Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2004. All rights reserved.