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

org.sfm.csv.impl.DelegateCellSetter 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 DelegateCellSetter implements CellSetter {

	private final DelegateMarkerSetter marker;
	private final CsvMapperCellConsumer

handler; private final Setter setter; private final int cellIndex; @SuppressWarnings("unchecked") public DelegateCellSetter(DelegateMarkerSetter marker, int cellIndex, BreakDetector parentBreakDetector) { if (marker== null) throw new NullPointerException("marker is null"); this.marker = marker; this.handler = marker.getMapper().newCellConsumer(null, parentBreakDetector); this.setter = marker.getSetter(); this.cellIndex = cellIndex; } public DelegateCellSetter(DelegateMarkerSetter marker, CsvMapperCellConsumer

handler, int cellIndex) { if (handler== null) throw new NullPointerException("handler is null"); if (marker== null) throw new NullPointerException("marker is null"); this.marker = marker; this.handler = handler; this.cellIndex = cellIndex; this.setter = null; } @Override public void set(T target, char[] chars, int offset, int length, ParsingContext context) throws Exception { this.handler.newCell(chars, offset, length, cellIndex); final BreakDetector breakDetector = handler.getBreakDetector(); if (setter != null && (breakDetector == null || (breakDetector.broken()&& breakDetector.isNotNull()))) { setter.set(target, this.handler.getCurrentInstance()); } } public CsvMapperCellConsumer getCellConsumer() { return handler; } @Override public String toString() { return "DelegateCellSetter{" + "marker=" + marker + ", handler=" + handler + ", cellIndex=" + cellIndex + '}'; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy