if (contents == null) {
return null;
}
String[] lines = StringUtil.parse(contents, format.getEndOfLineSymbols());
if (lines == null) {
throw new AppException("Record not found.", "[CategoryDA::readDataSet]", null);
} else {
if (lines.length < 1) {
throw new AppException("Record not found.", "[CategoryDA::readDataSet]", null);
}
dataObjectSet = new ArrayList<Tuple2<NameValue<String>, NameValue<String>>>();
for (int i = 0; i < lines.length; i++) {
String record = lines[i];
String[] fields = StringUtil.parse(record, String.valueOf((char) format.getDelimiterChar()));
if (fields == null) {
throw new AppException("Unable to read record no " + (String.valueOf(i + 1)), "[CategoryDA::readDataSet]", null);
} else {
if (fields.length != 2) {
Logger.getLogger(CategoryDA.class.getName()).log(Level.SEVERE, "[CategoryDA::readData]Record no " + (String.valueOf(i + 1)) + " is corrupted");
} else {
//get the value from file and verify it
String catCode = fields[0];
String catName = fields[1];
if (catCode == null) {
catCode = "";
}
if (catName == null) {
catName = "";
}
//valid row
if (!"".equalsIgnoreCase(catCode) && !"".equalsIgnoreCase(catName)) {
NameValue<String> categoryCode = new NameValue<String>("CategoryCode", catCode);
NameValue<String> categoryName = new NameValue<String>("CategoryName", catName);
dataObjectSet.add(new Tuple2<NameValue<String>, NameValue<String>>(categoryCode, categoryName));
}
}
}
}
}
} else {
throw new AppException("File not found.", "[CategoryDA::readDataSet]", null);
}
} catch (IOException ex) {
throw new AppException(ex.getMessage(), "[CategoryDA::readDataSet]", ex);
} finally {
if (br != null) {
try {
br.close();
} catch (IOException ex) {