org.sfm.csv.ConstructorOnReader Maven / Gradle / Ivy
package org.sfm.csv;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import org.sfm.csv.cell.ParsingException;
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 (IllegalArgumentException e) {
throw new ParsingException(e);
} catch (InstantiationException e) {
throw new ParsingException(e);
} catch (IllegalAccessException e) {
throw new ParsingException(e);
} catch (InvocationTargetException e) {
throw new ParsingException(e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy