use of org.knime.core.data.convert.java.DataCellToJavaConverter in project knime-core by knime.
the class DefaultKnimeToExternalMapper method map.
@Override
public void map(final DataRow row, final D destination, @SuppressWarnings("unchecked") final P... parameters) throws MappingException {
requireNonNull(row, "row");
requireNonNull(destination, "destination");
if (requireNonNull(parameters, "parameters").length != m_cellCount) {
throw new IllegalArgumentException("The number of consumer parameters is not equal to the number of cells (" + m_cellCount + "): " + parameters.length);
}
try {
final ListIterator<Pair<DataCellToJavaConverter<?, ?>, CellValueConsumer<D, Object, P>>> // Forced line break.
converterConsumerPairIterator = m_converterConsumerPairs.listIterator();
for (final DataCell cell : row) {
final Pair<DataCellToJavaConverter<?, ?>, CellValueConsumer<D, Object, P>> converterConsumerPair = converterConsumerPairIterator.next();
converterConsumerPair.getSecond().consumeCellValue(destination, cell.isMissing() ? null : converterConsumerPair.getFirst().convertUnsafe(cell), parameters[converterConsumerPairIterator.previousIndex()]);
}
} catch (final Exception exception) {
// always unwrap the exception and return a new MappingException with the cause message
final Throwable cause = exception.getCause();
final String message;
if (cause != null) {
message = cause.getMessage();
} else {
message = "Data type mapping exception";
}
throw new MappingException(message, cause);
}
}
Aggregations