Exemplo n.º 1
0
 /**
  * 将正则表达式中代表的group匹配项和meta中的属性对应赋值
  *
  * @param metaList
  * @param content
  * @param pattern
  * @param map
  */
 private Meta patternToMeta(
     Date smsDate, int bank, String content, Pattern pattern, Map<Integer, String> map) {
   Matcher matcher = pattern.matcher(content);
   if (matcher.matches()) {
     Meta meta = new Meta();
     meta.setSmsDate(smsDate);
     meta.setBank(bank);
     for (int i = 1; i <= matcher.groupCount(); i++) {
       String propName = map.get(i);
       String propVal = matcher.group(i);
       setVal(meta, propName, propVal);
     }
     return meta;
   }
   return null;
 }
Exemplo n.º 2
0
 private Record changeToRecord(Meta meta) {
   Record record = new Record();
   record.setBank(meta.getBank());
   // TODO:要增加一个帐号管理,这里只是帐号的尾号
   record.setAccount(meta.getAccount());
   smsDateCalendar.setTime(meta.getSmsDate());
   record.setDateTime(
       dateAdapter.analysis(smsDateCalendar.get(Calendar.YEAR), meta.getDatetime()));
   String content = meta.getType();
   record.setDetail(content);
   BigDecimal money = new BigDecimal(meta.getSum());
   record.setMoney(money);
   record.setMoneyType(contentAdapter.analysis(content));
   return record;
 }