All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sfm.csv.impl.DelegateDelayedCellSetter Maven / Gradle / Ivy

Go to download

Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.

There is a newer version: 1.10.3
Show newest version
package org.sfm.csv.impl;

import org.sfm.reflect.Setter;

public class DelegateDelayedCellSetter implements DelayedCellSetter {

	private final CsvMapperCellConsumer

cellConsumer; private final int cellIndex; private final BreakDetector breakDetector; private final Setter setter; public DelegateDelayedCellSetter(DelegateMarkerDelayedCellSetterFactory marker, int cellIndex, BreakDetector breakDetector) { this.cellConsumer = ((CsvMapperImpl

)marker.getMapper()).newCellConsumer(null, breakDetector); this.cellIndex = cellIndex; this.setter = marker.getSetter(); this.breakDetector = cellConsumer.getBreakDetector(); } public DelegateDelayedCellSetter(CsvMapperCellConsumer

handler, int cellIndex) { this.cellConsumer = handler; this.cellIndex = cellIndex; this.setter = null; this.breakDetector = null; } public CsvMapperCellConsumer getCellHandler() { return cellConsumer; } @Override public String toString() { return "DelegateDelayedCellSetterFactory{" + "cellIndex=" + cellIndex + ", handler=" + cellConsumer + '}'; } public P getValue() { return cellConsumer.getCurrentInstance(); } @Override public void set(T t) throws Exception { if (breakDetector == null || (breakDetector.broken() && breakDetector.isNotNull())) { setter.set(t, getValue()); } } @Override public boolean isSettable() { return setter != null; } public void set(char[] chars, int offset, int length, ParsingContext parsingContext) throws Exception { cellConsumer.newCell(chars, offset, length, cellIndex); } @Override public P consumeValue() { return getValue(); } @Override public P peekValue() { return getValue(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy