public abstract class LocalizedString extends Object implements TemplateScalarModel
TemplateScalarModel localizedYes = new LocalizedString() {
public String getLocalizedString(java.util.Locale locale) {
String lang = locale.getLanguage();
if "fr".equals(lang)
return "oui";
else if "de".equals(lang)
return "sĂ";
else
return "yes";
}
};
EMPTY_STRING
NOTHING
Constructor and Description |
---|
LocalizedString() |
Modifier and Type | Method and Description |
---|---|
String |
getAsString()
Returns the string representation of this model.
|
abstract String |
getLocalizedString(Locale locale) |
public String getAsString() throws TemplateModelException
TemplateScalarModel
null
, as that will cause exception. (In
classic-compatible mode the engine will convert null
into empty string, though.)
Objects of this type should be immutable, that is, calling TemplateScalarModel.getAsString()
should always return the same
value as for the first time.
getAsString
in interface TemplateScalarModel
TemplateModelException
public abstract String getLocalizedString(Locale locale) throws TemplateModelException
TemplateModelException