uk.ac.essex.common.lang
Class LanguageServiceImpl

java.lang.Object
  extended by uk.ac.essex.common.lang.LanguageServiceImpl
All Implemented Interfaces:
LanguageService, Service

public class LanguageServiceImpl
extends java.lang.Object
implements LanguageService

A useful implmentation of LanguageService that loads its configuration from two XML files called 'availableLocales.xml' and 'availableResources.xml'. These are searched for on the classpath and once loaded this class attempts to load each of the available resource base names for all the given locales.
Date: 15-Jul-2002


Field Summary
protected  java.util.prefs.Preferences preferences
           
 
Fields inherited from interface uk.ac.essex.common.lang.LanguageService
DEFAULT_LANGUAGE
 
Constructor Summary
LanguageServiceImpl()
           
 
Method Summary
 void add(ResourceConfigXML resourceConfig)
           
 void addResourceConfig(java.lang.String fileName)
          Add a resource config that gives the application localization resources to configure for this service
 void destroy()
          Destroy the service
 java.util.Locale getCurrentLocale()
           
 void initialise()
          Initialise the service, here we load the config file for the commons package
static void main(java.lang.String[] argStrings)
           
 void registerInternationlisedAction(javax.swing.Action action, java.lang.String nameKey)
          Just calls registerInternationlisedAction(javax.swing.Action, java.lang.String, java.lang.String, java.lang.String) passing in null for long and short descriptions
 void registerInternationlisedAction(javax.swing.Action action, java.lang.String nameKey, java.lang.String shortDescriptionKey, java.lang.String longDescriptionKey)
          Registers and sets the text of the action using the LanguageService.DEFAULT_LANGUAGE
 void registerInternationlisedComponent(javax.swing.JButton button, java.lang.String key)
          Registers and sets the text of the component using the LanguageService.DEFAULT_LANGUAGE
 void registerInternationlisedComponent(javax.swing.JCheckBox box, java.lang.String key)
          Registers and sets text of checkbox
 void registerInternationlisedComponent(javax.swing.JLabel label, java.lang.String key)
          Registers and sets the text of the component using the LanguageService.DEFAULT_LANGUAGE
 void registerInternationlisedComponent(javax.swing.JMenu menu, java.lang.String key)
          Registers and sets the text of the component using the LanguageService.DEFAULT_LANGUAGE
 void registerInternationlisedComponent(javax.swing.JRadioButton radioButton, java.lang.String key)
          Registers and sets the text of the component using the LanguageService.DEFAULT_LANGUAGE
 void registerInternationlisedComponent(javax.swing.border.TitledBorder border, java.lang.String key)
           
 void setCurrentLocale(java.util.Locale locale)
           
 java.lang.String translate(java.util.Locale locale, java.lang.String key)
           
 java.lang.String translate(java.lang.String key)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

preferences

protected java.util.prefs.Preferences preferences
Constructor Detail

LanguageServiceImpl

public LanguageServiceImpl()
Method Detail

registerInternationlisedAction

public void registerInternationlisedAction(javax.swing.Action action,
                                           java.lang.String nameKey)
Just calls registerInternationlisedAction(javax.swing.Action, java.lang.String, java.lang.String, java.lang.String) passing in null for long and short descriptions

Parameters:
action -
nameKey -

registerInternationlisedAction

public void registerInternationlisedAction(javax.swing.Action action,
                                           java.lang.String nameKey,
                                           java.lang.String shortDescriptionKey,
                                           java.lang.String longDescriptionKey)
Registers and sets the text of the action using the LanguageService.DEFAULT_LANGUAGE

Parameters:
action -
nameKey -
shortDescriptionKey - - Can be null
longDescriptionKey - - Can be null

registerInternationlisedComponent

public void registerInternationlisedComponent(javax.swing.JCheckBox box,
                                              java.lang.String key)
Registers and sets text of checkbox

Parameters:
box -
key -

registerInternationlisedComponent

public void registerInternationlisedComponent(javax.swing.JButton button,
                                              java.lang.String key)
Registers and sets the text of the component using the LanguageService.DEFAULT_LANGUAGE

Parameters:
button -
key -

registerInternationlisedComponent

public void registerInternationlisedComponent(javax.swing.JLabel label,
                                              java.lang.String key)
Registers and sets the text of the component using the LanguageService.DEFAULT_LANGUAGE

Parameters:
label -
key -

registerInternationlisedComponent

public void registerInternationlisedComponent(javax.swing.border.TitledBorder border,
                                              java.lang.String key)

registerInternationlisedComponent

public void registerInternationlisedComponent(javax.swing.JMenu menu,
                                              java.lang.String key)
Registers and sets the text of the component using the LanguageService.DEFAULT_LANGUAGE

Parameters:
menu -
key -

registerInternationlisedComponent

public void registerInternationlisedComponent(javax.swing.JRadioButton radioButton,
                                              java.lang.String key)
Registers and sets the text of the component using the LanguageService.DEFAULT_LANGUAGE

Parameters:
radioButton -
key -

add

public void add(ResourceConfigXML resourceConfig)
Specified by:
add in interface LanguageService
Parameters:
resourceConfig -

addResourceConfig

public void addResourceConfig(java.lang.String fileName)
                       throws InitialisationException
Add a resource config that gives the application localization resources to configure for this service

Specified by:
addResourceConfig in interface LanguageService
Parameters:
fileName - - The file name, will be loaded from the classpath
Throws:
InitialisationException

translate

public java.lang.String translate(java.lang.String key)
Specified by:
translate in interface LanguageService
Parameters:
key -
Returns:

translate

public java.lang.String translate(java.util.Locale locale,
                                  java.lang.String key)
Specified by:
translate in interface LanguageService
Parameters:
key -
Returns:

setCurrentLocale

public void setCurrentLocale(java.util.Locale locale)
Specified by:
setCurrentLocale in interface LanguageService
Parameters:
locale -

getCurrentLocale

public java.util.Locale getCurrentLocale()
Specified by:
getCurrentLocale in interface LanguageService
Returns:

initialise

public void initialise()
                throws InitialisationException
Initialise the service, here we load the config file for the commons package

Specified by:
initialise in interface Service
Throws:
InitialisationException

destroy

public void destroy()
             throws DestructionException,
                    ShutdownCancelledException
Destroy the service

Specified by:
destroy in interface Service
Throws:
DestructionException
ShutdownCancelledException

main

public static void main(java.lang.String[] argStrings)
Parameters:
argStrings -