private void i18nCharacters(String textValue) throws SAXException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("i18n message text = '" + textValue + "'");
}
SaxBuffer buffer;
switch (current_state) {
case STATE_INSIDE_TEXT:
buffer = text_recorder;
break;
case STATE_INSIDE_PARAM:
buffer = param_recorder;
break;
case STATE_INSIDE_WHEN:
case STATE_INSIDE_OTHERWISE:
// Previously handeld to avoid the String() conversion.
return;
case STATE_INSIDE_TRANSLATE:
if (tr_text_recorder == null) {
tr_text_recorder = new ParamSaxBuffer();
}
buffer = tr_text_recorder;
break;
case STATE_INSIDE_CHOOSE:
// No characters allowed. Send an exception ?
if (getLogger().isDebugEnabled()) {
textValue = textValue.trim();
if (textValue.length() > 0) {
getLogger().debug("No characters allowed inside <i18n:choose> tag. Received: " + textValue);
}
}
return;
case STATE_INSIDE_DATE:
case STATE_INSIDE_DATE_TIME:
case STATE_INSIDE_TIME:
case STATE_INSIDE_NUMBER:
// Trim text values to avoid parsing errors.
textValue = textValue.trim();
if (textValue.length() > 0) {
if (formattingParams.get(I18N_VALUE_ATTRIBUTE) == null) {
formattingParams.put(I18N_VALUE_ATTRIBUTE, textValue);
} else {
// ignore the text inside of date element
}
}
return;
default:
throw new IllegalStateException(getClass().getName() +
" developer's fault: characters not handled. " +
"Current state: " + current_state);
}
char[] ch = textValue.toCharArray();
buffer.characters(ch, 0, ch.length);
}