result = null;
}
else if (aObject instanceof SafeText){
//it is odd to extract an identical object like this,
//but it safely avoids double escaping at the end of this method
SafeText text = (SafeText) aObject;
result = text.getRawString();
}
else if (aObject instanceof Id){
Id id = (Id) aObject;
result = id.getRawString();
}
else if (aObject instanceof Code){
Code code = (Code) aObject;
result = code.getText().getRawString();
}
else if (aObject instanceof String) {
result = aObject.toString();
}
else if ( aObject instanceof DateTime ){
DateTime dateTime = (DateTime)aObject;
result = fDateConverter.formatEyeFriendlyDateTime(dateTime, fLocale);
}
else if ( aObject instanceof Date ){
Date date = (Date)aObject;
result = fDateConverter.formatEyeFriendly(date, fLocale, fTimeZone);
}
else if ( aObject instanceof BigDecimal ){
BigDecimal amount = (BigDecimal)aObject;
result = getBigDecimalDisplayFormat().format(amount.doubleValue());
}
else if ( aObject instanceof Decimal ){
Decimal money = (Decimal)aObject;
result = getBigDecimalDisplayFormat().format(money.getAmount().doubleValue());
}
else if ( aObject instanceof Boolean ){
Boolean value = (Boolean)aObject;
result = getBooleanDisplayText(value);
}
else if ( aObject instanceof Integer ) {
Integer value = (Integer)aObject;
result = getIntegerReportDisplayFormat().format(value);
}
else if ( aObject instanceof Long ) {
Long value = (Long)aObject;
result = getIntegerReportDisplayFormat().format(value.longValue());
}
else if ( aObject instanceof Locale ) {
Locale locale = (Locale)aObject;
result = locale.getDisplayName(fLocale);
}
else if ( aObject instanceof TimeZone ) {
TimeZone timeZone = (TimeZone)aObject;
result = timeZone.getDisplayName(false, TimeZone.SHORT, fLocale);
}
else {
result = aObject.toString();
}
//ensure that all empty results have configured content
if ( ! Util.textHasContent(result) ) {
result = fEmptyOrNullText;
}
return new SafeText(result);
}