Finding Available Java Constructors / Methods For ColdFusion Objects

<cffunction 
	name="GetJavaClassMethods" 
	access="public" 
	returntype="query" 
	output="false"
	hint="This takes a ColdFusion object and returns a query of all the available Java methods including constructors.">
	 
	<!--- Define argument. --->
	<cfargument name="CFObject" type="any" required="yes" />
	 
	<!--- Define the local scope. --->
	<cfset var LOCAL = StructNew() />
	 
	<!--- Create a query for the methods. --->
	<cfset LOCAL.MethodQuery = QueryNew( 
		"name, return_type, parameters, is_constructor"
		) />
	 
	<!--- Get an array of all constructors of the class object. --->
	<cfset LOCAL.ClassConstructors = ARGUMENTS.CFObject.GetClass().GetConstructors() />
	 
	<!--- Get an array of all PUBLIC methods of the class object. --->
	<cfset LOCAL.ClassMethods = ARGUMENTS.CFObject.GetClass().GetMethods() />
	 
	<!--- Add enough rows to the query for each method. --->
	<cfset QueryAddRow( 
		LOCAL.MethodQuery, 
		(
			ArrayLen( LOCAL.ClassConstructors ) + 
			ArrayLen( LOCAL.ClassMethods )
		)) />
	 
	<!--- Loop over constructors. --->
	<cfloop 
		index="LOCAL.ConstructorIndex" 
		from="1" 
		to="#ArrayLen( LOCAL.ClassConstructors )#" 
		step="1">
		 
		<!--- Set the name of the method. --->
		<cfset LOCAL.MethodQuery[ "name" ][ LOCAL.ConstructorIndex ] = LOCAL.ClassConstructors[ LOCAL.ConstructorIndex ].GetName() />
		 
		<!--- Set the return type. --->
		<cfset LOCAL.MethodQuery[ "return_type" ][ LOCAL.ConstructorIndex ] = ARGUMENTS.CFObject.GetClass().GetName() />
		 
		<!--- Set the parameters. --->
		<cfset LOCAL.MethodQuery[ "parameters" ][ LOCAL.ConstructorIndex ] = GetJavaClassMethodParameters( LOCAL.ClassConstructors[ LOCAL.ConstructorIndex ] ) />
		 
		<!--- Set this as being a constructor. --->
		<cfset LOCAL.MethodQuery[ "is_constructor" ][ LOCAL.ConstructorIndex ] = 1 />
	 
	</cfloop>
	 
	 
	<!--- Set offset for record count. --->
	<cfset LOCAL.Offset = (LOCAL.ConstructorIndex - 1) />
	 
	<!--- Loop over methods. --->
	<cfloop 
		index="LOCAL.MethodIndex" 
		from="1" 
		to="#ArrayLen( LOCAL.ClassMethods )#" 
		step="1">
		 
		<!--- Set the name of the method. --->
		<cfset LOCAL.MethodQuery[ "name" ][ LOCAL.Offset + LOCAL.MethodIndex ] = LOCAL.ClassMethods[ LOCAL.MethodIndex ].GetName() />
		 
		<!--- Set the return type. --->
		<cfset LOCAL.MethodQuery[ "return_type" ][ LOCAL.Offset + LOCAL.MethodIndex ] = LOCAL.ClassMethods[ LOCAL.MethodIndex ].GetReturnType().GetName() />
		 
		<!--- Set the parameters. --->
		<cfset LOCAL.MethodQuery[ "parameters" ][ LOCAL.Offset + LOCAL.MethodIndex ] = GetJavaClassMethodParameters( LOCAL.ClassMethods[ LOCAL.MethodIndex ] ) />
		 
		<!--- Set this as not being a constructor. --->
		<cfset LOCAL.MethodQuery[ "is_constructor" ][ LOCAL.Offset + LOCAL.MethodIndex ] = 0 />
	 
	</cfloop>
	 
	<!--- Perform a query of queries to get proper sorting. --->
	<cfquery name="LOCAL.SortedMethodQuery" dbtype="query">
		SELECT
			name, 
			return_type,
			parameters,
			is_constructor
		FROM
			[LOCAL].MethodQuery
		ORDER BY
			is_constructor DESC,
			name ASC,
			parameters ASC,
			return_type ASC
	</cfquery>
	 
	<!--- Return the full sorted method query. --->
	<cfreturn LOCAL.SortedMethodQuery />
</cffunction>

For Cut-and-Paste