com.opensymphony.xwork2.DefaultTextProvider Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2002-2006 by OpenSymphony
* All rights reserved.
*/
package com.opensymphony.xwork2;
import com.opensymphony.xwork2.util.LocalizedTextUtil;
import com.opensymphony.xwork2.util.ValueStack;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.ResourceBundle;
/**
* DefaultTextProvider gets texts from only the default resource bundles associated with the
* LocalizedTextUtil.
*
* @author Jason Carreira
* @author Rainer Hermanns
* @see LocalizedTextUtil#addDefaultResourceBundle(String)
*/
public class DefaultTextProvider implements TextProvider, Serializable, Unchainable {
private static final Object[] EMPTY_ARGS = new Object[0];
public DefaultTextProvider() {
}
public boolean hasKey(String key) {
return getText(key) != null;
}
public String getText(String key) {
return LocalizedTextUtil.findDefaultText(key, ActionContext.getContext().getLocale());
}
public String getText(String key, String defaultValue) {
String text = getText(key);
if (text == null) {
return defaultValue;
}
return text;
}
public String getText(String key, List