if (contents == null) {
return null;
}
String[] lines = StringUtil.parse(contents, format.getEndOfLineSymbols());
if (lines == null) {
throw new DataAccessException("[ProductDA::readData]Record not found.");
} else {
if (lines.length < 1) {
throw new DataAccessException("[ProductDA::readData]Record not found.");
}
dataObjectSet = new ArrayList<Tuple8<NameValue<String>, NameValue<String>, NameValue<String>, NameValue<Integer>, NameValue<Float>, NameValue<String>, NameValue<Integer>, NameValue<Integer>>>();
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 DataAccessException("[ProductDA::readData]Unable to read record no " + (String.valueOf(i + 1)));
} else {
if (fields.length != 8) {
Logger.getLogger(ProductDA.class.getName()).log(Level.SEVERE, "[ProductDA::readData]Record no " + (String.valueOf(i + 1)) + " is corrupted");
} else {
String id = fields[0];
String name = fields[1];
String desc = fields[2];
int qty = -1;
try {
qty = Integer.parseInt(fields[3]);
} catch (NumberFormatException nfx) {
throw new DataAccessException(nfx.getMessage(), nfx);
}
float price = 0f;
try {
price = Float.parseFloat(fields[4]);
} catch (NumberFormatException nfx) {
throw new DataAccessException(nfx.getMessage(), nfx);
}
String barcode = fields[5];
int reorderQty = -1;
try {
reorderQty = Integer.parseInt(fields[6]);
} catch (NumberFormatException nfx) {
throw new DataAccessException(nfx.getMessage(), nfx);
}
int orderQty = -1;
try {
orderQty = Integer.parseInt(fields[7]);
} catch (NumberFormatException nfx) {
throw new DataAccessException(nfx.getMessage(), nfx);
}
NameValue<String> pCode = new NameValue<String>("ProductCode", id);
NameValue<String> pName = new NameValue<String>("ProductName", name);
NameValue<String> pDescription = new NameValue<String>("ProductDescription", desc);
NameValue<Integer> pAvailableQty = new NameValue<Integer>("ProductAvailableQty", qty);
NameValue<Float> pPrice = new NameValue<Float>("ProductPrice", price);
NameValue<String> pBarcodeNumber = new NameValue<String>("ProductBarcodeNumber", barcode);
NameValue<Integer> pReOrderQty = new NameValue<Integer>("ProductReOrderQty", reorderQty);
NameValue<Integer> pOrderQty = new NameValue<Integer>("ProductOrderQty", orderQty);
dataObjectSet.add(new Tuple8<NameValue<String>, NameValue<String>, NameValue<String>, NameValue<Integer>, NameValue<Float>, NameValue<String>, NameValue<Integer>, NameValue<Integer>>(pCode, pName, pDescription, pAvailableQty, pPrice, pBarcodeNumber, pReOrderQty, pOrderQty));
}
}
}
}
} else {
throw new DataAccessException("[ProductDA::readData]File not found.");
}
} catch (IOException ex) {
throw new DataAccessException(ex.getMessage(), ex);
} finally {
if (br != null) {
try {
br.close();
} catch (IOException ex) {