use of org.knime.core.node.util.dialog.field.FieldList.OutFlowVariableList in project knime-core by knime.
the class OutFieldsTable method getOutVarFields.
/**
* Get the field definitions representing output flow variables.
*
* @return fields representing output flow variables
*/
public OutFlowVariableList getOutVarFields() {
OutFlowVariableList outVars = new OutFlowVariableList(m_defineDefaultValues);
for (int r = 0; r < m_model.getRowCount(); r++) {
if (!m_model.validateValues(r)) {
// there are errors in this row
continue;
}
Object fieldTypeValue = getFieldType(r);
if (null == fieldTypeValue) {
continue;
}
boolean isFlowVar = fieldTypeValue.equals(FieldType.FlowVariable);
if (isFlowVar) {
OutFlowVariableField outVar = m_defineDefaultValues ? new DefaultOutFlowVariableField() : new OutFlowVariableField();
outVar.setReplaceExisting((Boolean) m_model.getValueAt(r, Column.REPLACE_EXISTING));
Object colColValue = m_model.getValueAt(r, Column.COLUMN);
if (colColValue instanceof FlowVariable) {
FlowVariable flowVar = (FlowVariable) colColValue;
outVar.setKnimeName(flowVar.getName());
} else if (colColValue instanceof String) {
outVar.setKnimeName(colColValue.toString());
} else {
continue;
}
Object dataTypeValue = m_model.getValueAt(r, Column.DATA_TYPE);
if (dataTypeValue instanceof Type) {
Type type = (Type) dataTypeValue;
outVar.setKnimeType(type);
} else {
continue;
}
if (m_defineDefaultValues) {
DefaultOutFlowVariableField dOVar = (DefaultOutFlowVariableField) outVar;
Object defaultValue = m_model.getValueAt(r, Column.DEFAULT_VALUE);
switch((Type) dataTypeValue) {
case INTEGER:
int defInt = defaultValue instanceof String ? Integer.parseInt((String) defaultValue) : (Integer) defaultValue;
dOVar.setDefaultValue(defInt);
break;
case DOUBLE:
double defDouble = defaultValue instanceof String ? Double.parseDouble((String) defaultValue) : (Double) defaultValue;
dOVar.setDefaultValue(defDouble);
break;
default:
dOVar.setDefaultValue((String) defaultValue);
}
}
outVars.add(outVar);
}
}
return outVars;
}
Aggregations