NIHVIVO-564 Fixes for hash dump

This commit is contained in:
rjy7 2010-09-09 16:18:13 +00:00
parent 3269252aaa
commit ca6d805771
2 changed files with 8 additions and 6 deletions

View file

@ -47,7 +47,7 @@ public class DumpDirective extends BaseTemplateDirectiveModel {
String var = ((SimpleScalar)o).getAsString();
DumpHelper helper = new DumpHelper(env);
Map<String, Object> map = helper.getVariableDumpData(var);
Map<String, Object> map = new HashMap<String, Object>();
map.put("var", helper.getVariableDump(var));
TemplateHashModel dataModel = env.getDataModel();

View file

@ -52,10 +52,7 @@ public class DumpHelper {
map.put("var", varName);
if (tm != null) {
// Just use toString() method for now. Handles nested collections. Could make more sophisticated later.
String type = null;
String value = tm.toString();
Object unwrappedModel = null;
try {
@ -64,6 +61,11 @@ public class DumpHelper {
log.error("Cannot unwrap template model " + varName + ".");
}
// Just use toString() method for now. Handles nested collections. Could make more sophisticated later.
// tm.toString() gives wrong results in the case of, e.g., a boolean value in a hash. tm.toString() may
// return a TemplateBooleanModel object, while unwrappedModel.toString() returns "true" or "false."
String value = unwrappedModel.toString(); // tm.toString();
// This case must precede the TemplateScalarModel case, because
// tm is an instance of StringModel and thus a TemplateScalarModel.
if (unwrappedModel instanceof BaseTemplateModel) {