public void doTag() throws IOException {
if (this.value == null) {
return;
}
StringFormat format = null;
if (ConditionUtils.isNotEmpty(this.template)) {
format = StringFormatTemplate.getInstance().getFormat(this.template);
if (format == null) {
throw new IllegalStateException("Template not found");
}
} else if (ConditionUtils.isNotEmpty(this.format)) {
format = new StringFormat(this.format, this.character);
} else {
throw new IllegalStateException("Pattern or template must be defined");
}
String value = this.value.toString();
Writer writer = this.getJspContext().getOut();
String formated = "";
try {
formated = format.format(value);
formated = StringUtils.escapeHTML(formated);
} catch (ArrayIndexOutOfBoundsException e) {
WebLog.getInstance().getLogger().warn("Error formating '" + value + "' with mask '" + this.format + "'");
formated = FormatTag.ERROR_VALUE;
}