org.moremotion.resource
Class ResourceManager

java.lang.Object
  extended by org.moremotion.resource.ResourceManager
All Implemented Interfaces:
FileChangeNotification

public class ResourceManager
extends java.lang.Object
implements FileChangeNotification

Responsible for accessing resources available in the current moremotion installation.

Version:
$Id: ResourceManager.java 51 2008-03-10 11:46:54Z erkan $

Method Summary
 void doChange(java.io.File f)
           
 void doDelete(java.io.File f)
           
static ResourceBundle getResourceBundle(java.lang.String bundleName, java.lang.String language)
          Returns a ResourceBundle object by the given resource identifier and language code.
static ResourceBundle getSystemResourceBundle(java.lang.String language)
          Returns the ResourceBundle object of MoreMotion.
static java.lang.String replaceResDefinitions(java.lang.String inBuffer, java.lang.String language)
          Resolves the preformatted $res() definitions existing in the given string using the given language.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

doChange

public void doChange(java.io.File f)
Specified by:
doChange in interface FileChangeNotification

doDelete

public void doDelete(java.io.File f)
Specified by:
doDelete in interface FileChangeNotification

getResourceBundle

public static ResourceBundle getResourceBundle(java.lang.String bundleName,
                                               java.lang.String language)
                                        throws ResourceException
Returns a ResourceBundle object by the given resource identifier and language code. If the specified bundle is not in cache or the resource file newer than the cached bundle, this methos (re)loads it from the resource file located under "/WEB-INF/MM-INF/resources" folder.

If a resource file, i.e. "myres" is multi-lingual it should exists in "WEB-INF/MM-INF/resources/myres.res" file in the following format:

 <root>
   <item id="RES1">
     <en>English Text</en>
     <de>Deutscher Text</de>
   </item>
   <item id="RES2">
     ...
 </root> 
 
It is also possible to provide a separate resource file per language as follows.
 English resource file "WEB-INF/MM-INF/resources/en/myres.res"
 <root>
   <item id="RES1">English Text</item>
   <item id="RES2"> ...
 </root> 

 German resource file "WEB-INF/MM-INF/resources/de/myres.res"
 <root>
   <item id="RES1">Deutscher Text</item>
   <item id="RES2"> ...
 </root> 
 

Parameters:
bundleName - The name of the resource bundle
language - Language code as: tr, en, de, fr, etc..
Returns:
ResourceBundle object.
Throws:
ResourceException - if resource file is not found or is invalid.

getSystemResourceBundle

public static ResourceBundle getSystemResourceBundle(java.lang.String language)
                                              throws ResourceException
Returns the ResourceBundle object of MoreMotion.

Parameters:
language - Language code as: tr, en, de, fr, etc..
Returns:
ResourceBundle object.
Throws:
ResourceException

replaceResDefinitions

public static java.lang.String replaceResDefinitions(java.lang.String inBuffer,
                                                     java.lang.String language)
                                              throws ResourceException
Resolves the preformatted $res() definitions existing in the given string using the given language.

Parameters:
inBuffer - The input string that contains preformatted $res() definitions.
language - The language code to use in resolving the $res() definitions.
Throws:
ResourceException


Copyright © 2002-2008 MOR YAZILIM. All Rights Reserved.