if (contents == null) {
return null;
}
String[] lines = StringUtil.parse(contents, format.getEndOfLineSymbols());
if (lines == null) {
throw new AppException("[MemberDA::readData]Record not found.", "[MemberDA::readDataSet]", null);
} else {
if (lines.length < 1) {
throw new AppException("[MemberDA::readData]Record not found.", "[MemberDA::readDataSet]", null);
}
dataObjectSet = new ArrayList<Tuple3<NameValue<String>, NameValue<String>, 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 AppException("[MemberDA::readDataSet]Unable to read record no " + (String.valueOf(i + 1)), "[MemberDA::readDataSet]", null);
} else {
if (fields.length != 3) {
Logger.getLogger(MemberDA.class.getName()).log(Level.SEVERE, "[MemberDA::readDataSet]Record no " + (String.valueOf(i + 1)) + " is corrupted");
} else {
boolean recordValid = true;
//get all member value
String name = fields[0];
if (name == null) {
name = "";
}
String code = fields[1];
if (code == null) {
code = "";
}
int point = -1;
try {
point = Integer.parseInt(fields[2]);
} catch (NumberFormatException nfx) {
//cannot read point --> assume new member, point = -1
point = -1;
recordValid = false;
Logger.getLogger(MemberDA.class.getName()).log(Level.SEVERE, "" +
"[MemberDA::readDataSet]Record no " + (String.valueOf(i + 1)) + "is corrupted.\n" +
"Field: MemberPoint\n" +
"Value: " + String.valueOf(point),
nfx);
//throw new AppException(nfx.getMessage(), nfx);
}
if (!recordValid) {
Logger.getLogger(MemberDA.class.getName()).log(Level.WARNING, "Some records are found invalid. Default value are assigned.");
}
if (!"".equalsIgnoreCase(code) && !"".equalsIgnoreCase(name)) {
NameValue<String> memberName = new NameValue<String>("MemberName", name);
NameValue<String> memberID = new NameValue<String>("MemberID", code);
NameValue<Integer> memberPoint = new NameValue<Integer>("MemberPoint", point);
dataObjectSet.add(new Tuple3<NameValue<String>, NameValue<String>, NameValue<Integer>>( memberName, memberID, memberPoint));
}
}
}
}
}
} else {
throw new AppException("[MemberDA::readData]File not found.", "[MemberDA::readDataSet]", null);
}
} catch (IOException ex) {
throw new AppException(ex.getMessage(), "[MemberDA::readDataSet]", ex);
} finally {
if (br != null) {
try {
br.close();
} catch (IOException ex) {