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

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

package org.sfm.csv.impl;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

import org.sfm.csv.CellValueReader;

public class ConstructorOnReader implements CellValueReader {
	private final Constructor constructor;
	private final CellValueReader innerReader;

	public ConstructorOnReader(Constructor constructor,
			CellValueReader innerReader) {
		this.constructor = constructor;
		this.innerReader = innerReader;
	}

	@Override
	public T read(char[] chars, int offset, int length,
			ParsingContext parsingContext) {
		try {
			return constructor.newInstance(innerReader.read(chars, offset, length, parsingContext));
		} catch (Exception e) {
			throw new ParsingException(e);
		}
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy