Often, I don’t know what fields are available for an object, nor what methods are possible to use on it. So, I wrote a couple macros to help me figure this all out:
## macro to list the available java methods for an object
## Sam Rushing, Sept 28, 2009
#macro(inspect_methods $obj)##
#set($methods = $obj.getClass().getDeclaredMethods() )##
#foreach($m in $methods)##
$m.toGenericString()
#end##
#end
## macro to list the available fields for an object
## Sam Rushing, Sept 28, 2009
#macro(inspect_fields $obj)##
#set($fields = $obj.getClass().getDeclaredFields() )##
#foreach($f in $fields)##
$f.toGenericString()
#end##
#end
## macro to display the class and all fields and methods of an object
## Sam Rushing, Sept 28, 2009
#macro(inspect $obj)##
$obj.getClass().getName()
#inspect_fields($obj)
#inspect_methods($obj)
#end