com.opensymphony.xwork2
Class CompositeTextProvider

java.lang.Object
  extended by com.opensymphony.xwork2.CompositeTextProvider
All Implemented Interfaces:
TextProvider

public class CompositeTextProvider
extends Object
implements TextProvider

This is a composite TextProvider that takes in an array or List of TextProviders, it will consult each of them in order to get a composite result. To know how each method behaves, please refer to the javadoc for each methods.

Version:
$Date$ $Id$
Author:
tmjee

Field Summary
private static Logger LOG
           
private  List<TextProvider> textProviders
           
 
Constructor Summary
CompositeTextProvider(List<TextProvider> textProviders)
          Instantiates a CompositeTextProvider with some predefined textProviders.
CompositeTextProvider(TextProvider[] textProviders)
          Instantiates a CompositeTextProvider with some predefined textProviders.
 
Method Summary
 String getText(String key)
          It will consult each TextProviders and return the first valid message for this key
 String getText(String key, List<Object> args)
          It will consult each TextProviders and return the first valid message for this key.
 String getText(String key, String defaultValue)
          It will consult each TextProviders and return the first valid message for this key before returning defaultValue if every else fails.
 String getText(String key, String[] args)
          It will consult each TextProviders and return the first valid message for this key.
 String getText(String key, String defaultValue, List<Object> args)
          It will consult each TextProviders and return the first valid message for this key, before returining defaultValue
 String getText(String key, String defaultValue, List<Object> args, ValueStack stack)
          It will consult each TextProviders and return the first valid message for this key, before returining defaultValue
 String getText(String key, String defaultValue, String obj)
          It will consult each TextProviders and return the first valid message for this key, before returining defaultValue if every else fails.
 String getText(String key, String defaultValue, String[] args)
          It will consult each TextProviders and return the first valid message for this key, before returining defaultValue.
 String getText(String key, String defaultValue, String[] args, ValueStack stack)
          It will consult each TextProviders and return the first valid message for this key, before returining defaultValue
 ResourceBundle getTexts()
          It will consult each TextProviders and return the first non-null ResourceBundle.
 ResourceBundle getTexts(String bundleName)
          It will consult each TextProviders and return the first non-null ResourceBundle.
 boolean hasKey(String key)
          Checks if a message key exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

private static final Logger LOG

textProviders

private List<TextProvider> textProviders
Constructor Detail

CompositeTextProvider

public CompositeTextProvider(List<TextProvider> textProviders)
Instantiates a CompositeTextProvider with some predefined textProviders.

Parameters:
textProviders -

CompositeTextProvider

public CompositeTextProvider(TextProvider[] textProviders)
Instantiates a CompositeTextProvider with some predefined textProviders.

Parameters:
textProviders -
Method Detail

hasKey

public boolean hasKey(String key)
Description copied from interface: TextProvider
Checks if a message key exists.

Specified by:
hasKey in interface TextProvider
Parameters:
key - The key to lookup in ressource bundles.
Returns:
true, if the requested key is found in one of the ressource bundles.
See Also:
com.opensymphony.xwork2.TextProvider#hasKey(String)} It will consult each individual {@link TextProvider}s and return true if either one of the {@link TextProvider} has such a key> else false.

getText

public String getText(String key)
It will consult each TextProviders and return the first valid message for this key

Specified by:
getText in interface TextProvider
Parameters:
key - The key to lookup in ressource bundles.
Returns:
The i18n text for the requested key.
See Also:
com.opensymphony.xwork2.TextProvider#getText(String)}

getText

public String getText(String key,
                      String defaultValue)
It will consult each TextProviders and return the first valid message for this key before returning defaultValue if every else fails.

Specified by:
getText in interface TextProvider
Parameters:
key -
defaultValue -
Returns:
See Also:
com.opensymphony.xwork2.TextProvider#getText(String, String)}

getText

public String getText(String key,
                      String defaultValue,
                      String obj)
It will consult each TextProviders and return the first valid message for this key, before returining defaultValue if every else fails.

Specified by:
getText in interface TextProvider
Parameters:
key -
defaultValue -
obj -
Returns:
See Also:
com.opensymphony.xwork2.TextProvider#getText(String, String, String)}

getText

public String getText(String key,
                      List<Object> args)
It will consult each TextProviders and return the first valid message for this key.

Specified by:
getText in interface TextProvider
Parameters:
key -
args -
Returns:
See Also:
com.opensymphony.xwork2.TextProvider#getText(String, java.util.List)}

getText

public String getText(String key,
                      String[] args)
It will consult each TextProviders and return the first valid message for this key.

Specified by:
getText in interface TextProvider
Parameters:
key -
args -
Returns:
See Also:
com.opensymphony.xwork2.TextProvider#getText(String, String[])}

getText

public String getText(String key,
                      String defaultValue,
                      List<Object> args)
It will consult each TextProviders and return the first valid message for this key, before returining defaultValue

Specified by:
getText in interface TextProvider
Parameters:
key -
defaultValue -
args -
Returns:
See Also:
com.opensymphony.xwork2.TextProvider#getText#getText(String, String, java.util.List)}

getText

public String getText(String key,
                      String defaultValue,
                      String[] args)
It will consult each TextProviders and return the first valid message for this key, before returining defaultValue.

Specified by:
getText in interface TextProvider
Parameters:
key -
defaultValue -
args -
Returns:
See Also:
com.opensymphony.xwork2.TextProvider#getText(String, String, String[])}

getText

public String getText(String key,
                      String defaultValue,
                      List<Object> args,
                      ValueStack stack)
It will consult each TextProviders and return the first valid message for this key, before returining defaultValue

Specified by:
getText in interface TextProvider
Parameters:
key -
defaultValue -
args -
stack -
Returns:
See Also:
com.opensymphony.xwork2.TextProvider#getText(String, String, java.util.List, com.opensymphony.xwork2.util.OgnlValueStack)}

getText

public String getText(String key,
                      String defaultValue,
                      String[] args,
                      ValueStack stack)
It will consult each TextProviders and return the first valid message for this key, before returining defaultValue

Specified by:
getText in interface TextProvider
Parameters:
key -
defaultValue -
args -
stack -
Returns:
See Also:
com.opensymphony.xwork2.TextProvider#getText(String, String, String[], com.opensymphony.xwork2.util.ValueStack)}

getTexts

public ResourceBundle getTexts(String bundleName)
It will consult each TextProviders and return the first non-null ResourceBundle.

Specified by:
getTexts in interface TextProvider
Parameters:
bundleName -
Returns:
See Also:
TextProvider#getTexts(String)}

getTexts

public ResourceBundle getTexts()
It will consult each TextProviders and return the first non-null ResourceBundle.

Specified by:
getTexts in interface TextProvider
Returns:
See Also:
TextProvider#getTexts()}


Copyright © 2000-2009 Apache Software Foundation. All Rights Reserved.