TDIing out loud

Ramblings on the paradigm-shift that is TDI.

Wednesday, August 29, 2007

What's in a name?

Ok, so it's not immediately obvious that the pre-defined script variable system is actually detailed in the TDI JavaDocs under the com.ibm.di.function.UserFunctions class. Or that main goes by the whimsical class name com.ibm.di.server.RS and task is com.ibm.di.server.AssemblyLine.

But this is no problem when all you have to do is ask:

task.logmsg(" system: " + system.getClass());
task.logmsg(" task: " + task.getClass());
task.logmsg(" main: " + main.getClass());

The getClass() method is available for all Java objects and so will work for any variables that reference one; However, it will not work for JavaScript types (e.g. Number, String of Boolean).

To get around this limitation we can make our own getClass() function:

function getClass( v ) {
if (typeof(v) == "object")
return v.getClass()
else
typeof(v);
}

Then you'll be on speaking terms with variables from both worlds.

No comments: