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

org.simpleflatmapper.csv.impl.ColumnsMapperKeyBuilderCellConsumer Maven / Gradle / Ivy

Go to download

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

The newest version!
package org.simpleflatmapper.csv.impl;

import org.simpleflatmapper.csv.CsvColumnKey;
import org.simpleflatmapper.lightningcsv.parser.CellConsumer;
import org.simpleflatmapper.map.mapper.MapperKey;

import java.util.ArrayList;
import java.util.List;

public final class ColumnsMapperKeyBuilderCellConsumer implements CellConsumer {
	/**
	 * 
	 */
	private final List columns = new ArrayList();

	private int index = 0;
	private boolean hasNoData = true;

	public ColumnsMapperKeyBuilderCellConsumer() {
	}

	@Override
	public boolean endOfRow() {
		hasNoData = false;
		return true;
	}

	@Override
	public void newCell(char[] chars, int offset, int length) {
		if (!hasNoData) throw new IllegalArgumentException("Already consume the headers");
		columns.add(new CsvColumnKey(new String(chars, offset, length), index));
		index++;
	}

	@Override
	public void end() {
	}

	public MapperKey getKey() {
		return new MapperKey(columns.toArray(new CsvColumnKey[0]));
	}

	public boolean hasNoData() {
		return hasNoData;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy