BRules is a collection of validation, formatting, and logic Routines for use in Talend Open Studio. The 1.4.0 release (scheduled for Feb 2, 2014) introduces several pad() methods for padding strings and other datatypes. The implementation delegates to the popular Commons Lang StringUtils class.
While the pad() methods of StringUtils can be used in a Talend Open Studio job by loading the Commons Lang JAR with a tLibraryLoad, BRules' pad() methods reduce the amount of variable setup you might need when making the call.
For example, take the following snippet of Java code that might appear in a tMap cell
(row1.field1!=null)?StringUtils.leftPad(String.valueOf( row1.field1 ), 6, '0'):null
With BRules, this is reduced to
BRules.pad(row1.field1, 6, '0')
This is possible because BRules overloads the pad, avoiding the need for beforehand conversions. Java's Auto Boxing support also let's the same code handle primitive types. The != null check would not be allowed for "int" or "long" calls.
This Talend Open Studio Job shows a tMap with three variations of the pad(string,int,char) method for three different data types: String, Integer, and Long.
|Talend Open Studio Job Showing pad() Calls from BRules|