You can navigate through your defined classes along with related code snippets and fields through the Classes and Code Fragments panel. You can right-click on any item in this tree to either Delete, Rename, or Show Sample.
Classes
The Classes folder indicates what classes have corresponding code block tabs in the Class Code panel.
Code Snippits
The Code Snippits folder shows the internal PDI code related to the User Defined Java Class step. These snippits are shown as reference for the code of your class.
Input Fields
RowMetaInterface inputRowMeta = getInputRowMeta();
ValueMetaInterface customer = inputRowMeta.searchValueMeta("year");
if (first) { yearIndex = getInputRowMeta().indexOfValue(getParameter("YEAR")); if (yearIndex<0) { throw new KettleException("Year field not found in the input row, check parameter 'YEAR'\!"); } }
Object[] r = getRow(); ... Long year = inputRowMeta().getInteger(r, yearIndex);
Long year = get(Fields.In, "year").getInteger(r);
Info Fields
The Info fields folder contains any information fields you define in your code. These fields will not appear in the Classes and Code Fragments panel until they are defined in your code. If no information fields are defined in your code, nothing will show in this folder.
Output Fields
You can define all the new fields you want to use as the output of the step in the Fields tab. Setting fields in this tab will automatically calculate the layout of the output row metadata and store it in data.outputRowMeta, which enables you to create the output row.
In cases where the step writes as many (or as few) rows as it reads, you can resize the row you get on input, as shown in the following example code:
Object[] outputRowData = RowDataUtil.resizeArray(r, data.outputRowMeta.size());
or in the following example code:
Object[] outputRowData = createOutputRow(r, data.outputRowMeta.size());
If you are copying the rows, create separate copies to prevent subsequent steps from modifying the same Object[] copy many times at once, as shown in the following example:
Object[] outputRowData = RowDataUtil.createResizedCopy(r, data.outputRowMeta.size());
As with accessing input fields, output fields can be addressed through the index in the output row, as shown in the following example:
outputRowData[getInputRowMeta().size()] = easterDate(year.intValue());
or using the shortcut that is shown in the following example:
get(Fields.Out, "easter").setValue(r, easterDate(year.intValue());
The Java data types that you pass to subsequent steps always need to correspond to the PDI data type as described on the PDI Rows Of Data page.