Search in sources :

Example 1 with InColList

use of org.knime.base.node.jsnippet.util.JavaFieldList.InColList in project knime-core by knime.

the class InFieldsTable method getInColFields.

/**
 * Get the field definitions representing input columns.
 *
 * @return fields representing input columns.
 */
public InColList getInColFields() {
    InColList inCols = new InColList();
    for (int r = 0; r < m_model.getRowCount(); r++) {
        if (!m_model.validateValues(r)) {
            // there are errors in this row
            continue;
        }
        Object value = m_model.getValueAt(r, Column.COLUMN);
        if (value instanceof DataColumnSpec) {
            DataColumnSpec colSpec = (DataColumnSpec) value;
            InCol inCol = new InCol();
            inCol.setKnimeName(colSpec.getName());
            inCol.setJavaName((String) m_model.getValueAt(r, Column.JAVA_FIELD));
            Object javaTypeObject = m_model.getValueAt(r, Column.JAVA_TYPE);
            if (javaTypeObject instanceof DataCellToJavaConverterFactory) {
                inCol.setConverterFactory(colSpec.getType(), (DataCellToJavaConverterFactory) javaTypeObject);
            } else {
                throw new IllegalStateException("Contents of JavaType column need to be DataCellToJavaConverterFactory instances.");
            }
            inCols.add(inCol);
        }
    }
    return inCols;
}
Also used : DataColumnSpec(org.knime.core.data.DataColumnSpec) InCol(org.knime.base.node.jsnippet.util.field.InCol) InColList(org.knime.base.node.jsnippet.util.JavaFieldList.InColList) DataCellToJavaConverterFactory(org.knime.core.data.convert.java.DataCellToJavaConverterFactory)

Aggregations

InColList (org.knime.base.node.jsnippet.util.JavaFieldList.InColList)1 InCol (org.knime.base.node.jsnippet.util.field.InCol)1 DataColumnSpec (org.knime.core.data.DataColumnSpec)1 DataCellToJavaConverterFactory (org.knime.core.data.convert.java.DataCellToJavaConverterFactory)1