Java Snippet
0 ×

StreamableKNIME Java Snippet Nodes version 3.5.0.v201711081409 by KNIME AG, Zurich, Switzerland

This node allows you to execute arbitrary java code to create a new columns or to replace an existing ones. Enter the java code in the text area.

An output columns is defined by creating a java field bound to this column. The value assigned to this field will be written to the output.

Note, that this node allows to add or modify flow variables in the same manner.

It is also possible to use external java libraries (that is, libraries that are not part of java boot classpath). In order to include such external jar or zip files, add their location in the "Additional Libraries" tab using the control buttons.

You can define reusable templates with the "Create templates..." button. Templates are stored in the users workspace by default and can be accessed via the "Templates" tab.


Column List
The list contains the columns that are available in the input table. Double click any of the column names to insert the respective field in the expression editor. It will replace your current selection or simply insert at the current caret position.
Flow Variable List
The list contains the flow variables that are currently available at the node input. Double clicking any of the entries will insert the respective identifier at the current cursor position (replacing the selection, if any).
Snippet text area
Enter your java code here. You can access input columns or flow variables by defining them in the Input table. A second way is to use the methods getCell(name, type) or getFlowVariable(name, type) where name is the name of the input column or the flow variable, respectively. You can use the following values for the type parameter.
tString : String (f)
tInt : Integer (f)
tDouble : Double (f)
tLong : Long
tBoolean : Boolean
tDate : java.util.Date
tCalendar : java.util.Calendar
tXML : org.w3c.document
(f) These Types can be used for flow variables.

Java Snippet Methods:
getCell(name, type)* : Get value of a cell by column name
isType(name, type)* : Test for type by column name
isMissing(name)* : Check if missing by column name
columnExists(name)* : Check if column with given name exists
getColumnCount(index, type) : Number of columns in the input table
getColumnName(index) : Retrieve column name at index

getFlowVariable(name, type) : Get value of a flow variable by name
getFlowVariables(type) : Get all flow variables by type. A name to value map is returned.
flowVariableExists(name) : Check if a flow variable with given name exists
isFlowVariableOfType(name, type) : Check if a flow variable is of type
* Methods exist in a variant that takes the column index instead of its name.

You can hit ctrl+space to get an auto completion box with all available classes, methods and fields. When you select a class and hit enter a import statement will be generated if missing.

Note, that the snippet allows to define custom global variables and custom imports.

Exceptions in the snippet are caught by the framework and will result in missing values for all output columns for the row being processed unless there are flow variables defined by the snippet (in which case the execution will always fail). You can force the node to fail execution by throwing an exception of class Abort.

Define system input fields for the snippet text area. Every field will be populated with the data of the defined input during execution.
To define output columns and flow variables by adding columns to this table. Every row in the Output table defines a java field bound to a column. Values assigned to this field in the snippet will show up at the output.

Input Ports

Input table.

Output Ports

Input table with additional or replaced columns.

Best Friends (Incoming)

Best Friends (Outgoing)


Update Site

To use this node in KNIME, install KNIME Java Snippet Nodes from the following update site:

Wait a sec! You want to explore and install nodes even faster? We highly recommend our NodePit for KNIME extension for your KNIME Analytics Platform.