Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
XWork is an command-pattern framework that is used to power WebWork
as well as other applications. XWork provides an Inversion of Control
container, a powerful expression language, data type conversion,
validation, and pluggable configuration.
package com.opensymphony.xwork2;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;
import java.util.*;
/**
* This is a composite {@link TextProvider} that takes in an array or {@link java.util.List} of {@link TextProvider}s, 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.
*
* @author tmjee
* @version $Date$ $Id$
*/
public class CompositeTextProvider implements TextProvider {
private static final Logger LOG = LoggerFactory.getLogger(CompositeTextProvider.class);
private List textProviders = new ArrayList();
/**
* Instantiates a {@link CompositeTextProvider} with some predefined textProviders.
*
* @param textProviders
*/
public CompositeTextProvider(List textProviders) {
this.textProviders.addAll(textProviders);
}
/**
* Instantiates a {@link CompositeTextProvider} with some predefined textProviders.
*
* @param textProviders
*/
public CompositeTextProvider(TextProvider[] textProviders) {
this(Arrays.asList(textProviders));
}
/**
* @param key The key to lookup in ressource bundles.
* @return true, if the requested key is found in one of the ressource bundles.
* @see {@link 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.
*/
public boolean hasKey(String key) {
// if there's a key in either text providers we are ok, else try the next text provider
for (TextProvider tp : textProviders) {
if (tp.hasKey(key)) {
return true;
}
}
return false;
}
/**
* It will consult each {@link TextProvider}s and return the first valid message for this
* key
*
* @param key The key to lookup in ressource bundles.
* @return The i18n text for the requested key.
* @see {@link com.opensymphony.xwork2.TextProvider#getText(String)}
*/
public String getText(String key) {
return getText(key, key, Collections.emptyList());
}
/**
* It will consult each {@link TextProvider}s and return the first valid message for this
* key before returning defaultValue if every else fails.
*
* @param key
* @param defaultValue
* @return
* @see {@link com.opensymphony.xwork2.TextProvider#getText(String, String)}
*/
public String getText(String key, String defaultValue) {
return getText(key, defaultValue, Collections.emptyList());
}
/**
* It will consult each {@link TextProvider}s and return the first valid message for this
* key, before returining defaultValue
* if every else fails.
*
* @param key
* @param defaultValue
* @param obj
* @return
* @see {@link com.opensymphony.xwork2.TextProvider#getText(String, String, String)}
*/
public String getText(String key, String defaultValue, final String obj) {
return getText(key, defaultValue, new ArrayList