use of org.asqatasun.referential.creator.exception.I18NLanguageNotFoundException in project Asqatasun by Asqatasun.
the class CodeGeneratorMojo method getCsv.
/**
*
* @return
*/
private Iterable<CSVRecord> getCsv() {
// we parse the csv file to extract the first line and get the headers
LineIterator lineIterator;
try {
lineIterator = FileUtils.lineIterator(dataFile, Charset.defaultCharset().name());
} catch (IOException ex) {
Logger.getLogger(CodeGeneratorMojo.class.getName()).log(Level.SEVERE, null, ex);
lineIterator = null;
}
String[] csvHeaders = lineIterator != null ? lineIterator.next().split(String.valueOf(delimiter)) : new String[0];
isCriterionPresent = extractCriterionFromCsvHeader(csvHeaders);
try {
extractAvailableLangsFromCsvHeader(csvHeaders);
} catch (I18NLanguageNotFoundException ex) {
Logger.getLogger(CodeGeneratorMojo.class.getName()).log(Level.SEVERE, null, ex);
return null;
}
// from here we just add each line to a build to re-create the csv content
// without the first line.
StringBuilder strb = new StringBuilder();
while (lineIterator.hasNext()) {
strb.append(lineIterator.next());
strb.append("\n");
}
Reader in;
try {
in = new StringReader(strb.toString());
CSVFormat csvf = CSVFormat.newFormat(delimiter).withHeader(csvHeaders);
return csvf.parse(in);
} catch (FileNotFoundException ex) {
Logger.getLogger(CodeGeneratorMojo.class.getName()).log(Level.SEVERE, null, ex);
return null;
} catch (IOException ex) {
Logger.getLogger(CodeGeneratorMojo.class.getName()).log(Level.SEVERE, null, ex);
return null;
}
}
Aggregations