@Override
public void process(int rownum, String[] values) throws Exception {
if(rownum == 1){
String[] cols = data.cols();
if(null == cols){
data.setCols(values);
}else if(!Arrays2.equals(cols, values, true)){
throw new IllegalStateException("Headers in resource '" + resource.getClasspath() + "' should be '" + Strings.join(cols,","));
}
return;
}
String[] cols = data.cols();
if(values.length > cols.length){
throw new IllegalStateException("Column size '" + values.length +
"' exceed the header size '" + cols.length +
" in row " + rownum + " : " + Strings.join(values,",") +
", check the source : " + resource.getClasspath());
}
if(values.length < cols.length){
values = Arrays.copyOf(values, cols.length);
}
data.addRow(locale,values);
}
});