private String extractValue(Object value) {
if (value == null) return "null";
// 1. Handle Bean References (@name)
if (value instanceof BeanReference) {
return "@" + ((BeanReference) value).getBeanName();
}
// 2. Handle TypedStringValue (Fixes the "TypedStringValue: value [01]" issue)
if (value instanceof TypedStringValue) {
String actualValue = ((TypedStringValue) value).getValue();
return xmlEscape(actualValue != null ? actualValue : "null");
}
// 3. Handle Inner Bean Definitions (Shows only the class name)
if (value instanceof BeanDefinition) {
String className = ((BeanDefinition) value).getBeanClassName();
return className != null ? "<i>" + className.substring(className.lastIndexOf('.') + 1) + "</i>" : "InnerBean";
}
// 4. Handle Lists (Spring ManagedList or standard List)
if (value instanceof List) {
List<String> cleaned = new ArrayList<>();
int count = 0;
for (Object item : (List<?>) value) {
if (count++ >= 12) {
cleaned.add("...");
break;
}
cleaned.add(extractValue(item)); // Recursive call to handle TypedStringValues inside lists
}
return String.join("<BR ALIGN=\"LEFT\"/>", cleaned);
}
// 5. Handle Maps (Spring ManagedMap or standard Map)
if (value instanceof Map) {
StringBuilder mapStr = new StringBuilder();
int count = 0;
for (Map.Entry<?, ?> entry : ((Map<?, ?>) value).entrySet()) {
if (count++ >= 10) {
mapStr.append("...more entries...");
break;
}
mapStr.append(extractValue(entry.getKey()))
.append("=")
.append(extractValue(entry.getValue()))
.append("<BR ALIGN=\"LEFT\"/>");
}
return mapStr.toString();
}
// Default fallback for simple primitives/strings
String s = value.toString();
return xmlEscape(s.length() > 60 ? s.substring(0, 57) + "..." : s);
}
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)