com.github.mygreen.supercsv.exception.SuperCsvRowException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of super-csv-annotation Show documentation
Show all versions of super-csv-annotation Show documentation
CSVのJavaライブラリであるSuperCSVに、アノテーション機能を追加したライブラリです。
package com.github.mygreen.supercsv.exception;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import org.supercsv.exception.SuperCsvCellProcessorException;
import org.supercsv.exception.SuperCsvException;
import org.supercsv.util.CsvContext;
/**
* 行のエラーをまとめた例外。
*
* @author T.TSUCHIE
*
*/
public class SuperCsvRowException extends SuperCsvException {
/** serialVersionUID */
private static final long serialVersionUID = 1L;
private final List columnErrors = new ArrayList<>();
public SuperCsvRowException(final String msg, final CsvContext context) {
super(msg, context);
}
public void addError(final SuperCsvException error) {
this.columnErrors.add(error);
}
public void addError(final SuperCsvCellProcessorException error) {
final SuperCsvCellProcessorException cloned;
if(error instanceof SuperCsvValidationException) {
cloned = ((SuperCsvValidationException)error).clone();
} else {
cloned = new SuperCsvCellProcessorException(error.getMessage(),
cloneCsvContext(error.getCsvContext()),
error.getProcessor());
}
this.columnErrors.add(cloned);
}
private CsvContext cloneCsvContext(final CsvContext context) {
CsvContext cloned = new CsvContext(
context.getLineNumber(),
context.getRowNumber(),
context.getColumnNumber());
// shallow copy
List