Fixes to dump

This commit is contained in:
ryounes 2011-08-10 16:46:08 +00:00
parent e202a31d62
commit 80234688a6
2 changed files with 22 additions and 8 deletions

View file

@ -422,7 +422,7 @@ public abstract class BaseDumpDirective implements TemplateDirectiveModel {
} }
// Else display method name, parameter types, and return type // Else display method name, parameter types, and return type
} else { } else {
String returnTypeName = getTypeName(method.getReturnType()); String returnTypeName = getReturnTypeName(method);
Map<String, String> methodValue = new HashMap<String, String>(); Map<String, String> methodValue = new HashMap<String, String>();
if ( ! returnTypeName.equals("void") ) { if ( ! returnTypeName.equals("void") ) {
methodValue.put(Key.TYPE.toString(), returnTypeName); methodValue.put(Key.TYPE.toString(), returnTypeName);
@ -460,14 +460,26 @@ public abstract class BaseDumpDirective implements TemplateDirectiveModel {
List<String> paramTypeList = new ArrayList<String>(paramTypes.length); List<String> paramTypeList = new ArrayList<String>(paramTypes.length);
if (paramTypes.length > 0) { if (paramTypes.length > 0) {
for (Class<?> cls : paramTypes) { for (Class<?> cls : paramTypes) {
paramTypeList.add(getTypeName(cls)); paramTypeList.add(getSimpleTypeName(cls));
} }
} }
methodName += "(" + StringUtils.join(paramTypeList, ", ") + ")"; methodName += "(" + StringUtils.join(paramTypeList, ", ") + ")";
return methodName; return methodName;
} }
private String getTypeName(Class<?> cls) { private String getReturnTypeName(Method method) {
Class<?> cls = method.getReturnType();
Package pkg = cls.getPackage();
if (pkg != null) { // void return type has null package
String packageName = pkg.getName();
if (packageName.startsWith("java")) {
return getSimpleTypeName(cls);
}
}
return cls.getName();
}
private String getSimpleTypeName(Class<?> cls) {
return cls.getSimpleName().replace("[]", "s"); return cls.getSimpleName().replace("[]", "s");
} }

View file

@ -63,7 +63,7 @@ div.dump {
</#if> </#if>
</#macro> </#macro>
<#macro doTypeAndValue map> <#macro doTypeAndValue map isMethod=false>
<#local type = map.type!> <#local type = map.type!>
<#if type?has_content> <#if type?has_content>
<p><strong>Type:</strong> ${type}</p> <p><strong>Type:</strong> ${type}</p>
@ -75,8 +75,9 @@ div.dump {
<#local value = map.value!> <#local value = map.value!>
<#-- Not value?has_content: we want to print [empty] for empty strings. <#-- Not value?has_content: we want to print [empty] for empty strings.
See doScalarValue macro. --> See doScalarValue macro. For methods, we don't show a list of values
<#if value??> unless there is a value. -->
<#if value?? && (value?has_content || ! isMethod)>
<div class="values"> <div class="values">
<#if type?contains(".")><@doObjectValue value /> <#if type?contains(".")><@doObjectValue value />
<#elseif value?is_sequence><@doSequenceValue value type /> <#elseif value?is_sequence><@doSequenceValue value type />
@ -110,7 +111,8 @@ div.dump {
<#elseif value?is_string> <#-- value is return type --> <#elseif value?is_string> <#-- value is return type -->
${method} => ${value} ${method} => ${value}
<#else> <#-- no-arg method: value is result of method invocation --> <#else> <#-- no-arg method: value is result of method invocation -->
${method} => <@divValue><@doTypeAndValue value /></@divValue> <#local isMethod = true>
${method} => <@divValue><@doTypeAndValue value isMethod /></@divValue>
</#if> </#if>
</@liItem> </@liItem>
</#list> </#list>