Search in sources :

Example 11 with DataCellToJavaConverterFactory

use of org.knime.core.data.convert.java.DataCellToJavaConverterFactory 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

DataCellToJavaConverterFactory (org.knime.core.data.convert.java.DataCellToJavaConverterFactory)11 DataColumnSpec (org.knime.core.data.DataColumnSpec)4 JavaToDataCellConverterFactory (org.knime.core.data.convert.datacell.JavaToDataCellConverterFactory)4 DataType (org.knime.core.data.DataType)3 FlowVariable (org.knime.core.node.workflow.FlowVariable)3 Component (java.awt.Component)2 ArrayList (java.util.ArrayList)2 Optional (java.util.Optional)2 Test (org.junit.Test)2 TypeConverter (org.knime.base.node.jsnippet.type.flowvar.TypeConverter)2 InCol (org.knime.base.node.jsnippet.util.field.InCol)2 SimpleDataCellToJavaConverterFactory (org.knime.core.data.convert.java.SimpleDataCellToJavaConverterFactory)2 NodeSettings (org.knime.core.node.NodeSettings)2 Closeable (java.io.Closeable)1 Field (java.lang.reflect.Field)1 URLClassLoader (java.net.URLClassLoader)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1