Portlet Factory, Version 6.1.2


 

Writing ResultSet Column and Output Parameter Transform methods

This topic describes the parameters that a custom method must take.

If you define a custom transform for a result set column or output parameter of the SQL statement, include in your model a method that will take the value of the column or parameter and transform it into an XML element. Custom methods must take these parameters and return an iXML object.

BuilderName

A string parameter that contains the name of the SQL Statement builder that is calling the method to perform a custom transform on a result set column.

columnNumber

An integer parameter that identifies either the SQL statement's result set column or the output parameter that is to be transformed by the method. You can define one method for each column/output parameter that you will transform manually or you can bundle all of your transforms together and use this input to identify which column/output parameter is being transformed by the builder.

columnValue

This object parameter is the actual result set column value or output parameter that this custom method is to transform into XML.

Note: The value will be null if the column/output parameter contain a null value.

elementName

A string parameter that provides the name of the XML element containing the transformed data.

createVerboseXml

A boolean parameter that tells the method whether or not it s allowed to create XML that includes any special element attributes meaningful to this particular transformation. In most cases this parameter can be safely ignored.

The following Java code sample is the body of a custom transform method. In this example we expect the value to be a string (VARCHAR or equivalent) that is converted to lowercase. Since we do not need to differentiate between SQL Statement builders and result set columns/ output parameters, we ignore the BuilderName and columnNumber inputs. We cast the columnValue parameter into a string and then proceed to transform the value into an XML element with a name provided by the elementName parameter of the method.

String s = (String) columnValue;
IXml element = XmlUtil.create( elementName ); element.setText( s.toLowerCase() ); return element;

Parent topic: SQL Statement builder


Library | Support |