public void formatAndSaveScoreById(String semesterName, String scoreStr, int accountId) { // 2012-07-10 basilwang delete the related scores of the seleced // semester value if (scoreStr == null) { return; } delete(accountId, semesterName); ScoreConfig scoreConfig = getScoreConfig(); Pattern trPattern = Pattern.compile(scoreConfig.getTr()); Matcher matcher; matcher = trPattern.matcher(scoreStr); Matcher tdMatcher = null; matcher.find(); while (matcher.find()) { String tr = matcher.group(); Pattern tdPattern = Pattern.compile(scoreConfig.getTd()); tdMatcher = tdPattern.matcher(tr); Score score = new Score(semesterName); score.setMyid(accountId); List<ScoreConfigInTD> scoreConfigIntds = scoreConfig.getScoreConfigintds(); for (ScoreConfigInTD scoreConfigIntd : scoreConfigIntds) { tdMatcher.find(); if (scoreConfigIntd.getDbfield() == null) { continue; } score.setter(scoreConfigIntd.getDbfield(), tdMatcher.group(1)); } save(score); } }
public List<Score> getScores(String semesterName, int myid) { String sql = constructSQL(); String[] bindArgs = {String.valueOf(myid), getSemesterId(semesterName)}; Cursor result = daoHelper.query(sql, bindArgs); List<Score> list = new ArrayList<Score>(); while (result.moveToNext()) { Score score = new Score(); for (int i = 1; i < indexs.length; i++) { String value = result.getString(i); score.setter(indexs[i], value); } list.add(score); } daoHelper.closeDB(); return list; }