Search in sources :

Example 1 with DataTableSpecExtractor

use of org.knime.core.data.util.DataTableSpecExtractor in project knime-core by knime.

the class ExtractTableSpecNodeModel method getExtractedDataTable.

/**
 * Creates a data table with the meta information extracted from the given
 * spec as data rows/cols.
 *
 * @param spec The table spec to extract the meta information from.
 * @return The data table containing the meta information from the given
 * spec.
 */
private DataTable getExtractedDataTable(final DataTableSpec spec) {
    DataTableSpecExtractor extractor = new DataTableSpecExtractor();
    extractor.setPossibleValueOutputFormat(m_possibleValuesAsCollection.getBooleanValue() ? PossibleValueOutputFormat.Collection : PossibleValueOutputFormat.Hide);
    extractor.setPropertyHandlerOutputFormat(m_extractPropertyHandlersModel.getBooleanValue() ? PropertyHandlerOutputFormat.Boolean : PropertyHandlerOutputFormat.Hide);
    return extractor.extract(spec);
}
Also used : DataTableSpecExtractor(org.knime.core.data.util.DataTableSpecExtractor)

Example 2 with DataTableSpecExtractor

use of org.knime.core.data.util.DataTableSpecExtractor in project knime-core by knime.

the class DataTableSpecView method createTableSpecTable.

private DataTable createTableSpecTable(final DataTableSpec spec) {
    if (spec != null) {
        DataTableSpecExtractor e = new DataTableSpecExtractor();
        e.setExtractColumnNameAsColumn(false);
        e.setPossibleValueOutputFormat(PossibleValueOutputFormat.Columns);
        e.setPropertyHandlerOutputFormat(PropertyHandlerOutputFormat.ToString);
        return e.extract(spec);
    } else {
        String[] names = new String[] { "No outgoing table spec" };
        DataType[] types = new DataType[] { StringCell.TYPE };
        DataContainer result = new DataContainer(new DataTableSpec(names, types));
        result.close();
        return result.getTable();
    }
}
Also used : DataTableSpecExtractor(org.knime.core.data.util.DataTableSpecExtractor) DataContainer(org.knime.core.data.container.DataContainer) DataTableSpec(org.knime.core.data.DataTableSpec) DataType(org.knime.core.data.DataType)

Aggregations

DataTableSpecExtractor (org.knime.core.data.util.DataTableSpecExtractor)2 DataTableSpec (org.knime.core.data.DataTableSpec)1 DataType (org.knime.core.data.DataType)1 DataContainer (org.knime.core.data.container.DataContainer)1