Since ColdFusion is so loosely typed, it is almost impossible
to deterministically identify a datatype for a given variable.
Like you forshadowed in your original post, you can tunnel
down into the Java layer and use the ".GetClass().GetName()"
method, but more often than not you'll find that many variables are
stored as string objects under the hood.
You can force a datatype on a variable using the JavaCast()
function, but short of that, there's no easy way to determine the
datatype of a variable that was initialized without JavaCast().
I think you'll find the following blog article fairly
relevant:
http://www.bennadel.com/blog/380-ColdFusion-Data-Types-From-Different-Sources-And-How-ColdFusion-See...
In any event, I think the best you can do is write a UDF that
leverages the isArray, isQuery, isNumeric, isXML (etc etc) methods
to determine a type. Of course, you'll have to be careful in how
you order your tests.