WordSearchScreenService

来源:互联网 发布:js分割字符串包含转义 编辑:程序博客网 时间:2024/06/08 20:15
public class WordSearchScreenService {WordDao wordDao = new WordDao();BeanUtil beanUtil = new BeanUtil();public Vector<Vector<Object>> getWordsByCondition(Map<String, Object> conditionMap, WordSearchScreen thisFrame){String[] showColumns = new String[]{"FLDWORDID","FLDWORDEN","FLDWORDCN","FLDPRIORITY","FLDTESTTIMES","FLDLASTTESTDATE","FLDFROM","FLDCREATDATE","FLDERRORFAG","FLDERRORTIMES","FLDFORGETTAG","FLDCHANGETAG"};thisFrame.searchWords = wordDao.getWordsByCondition(conditionMap);Vector<Vector<Object>> dataVector = new Vector<Vector<Object>>();for(Word w:thisFrame.searchWords){Vector<Object> recordVector = new Vector<Object>(beanUtil.toFieldValueList(w,false,showColumns));recordVector.insertElementAt("X", 0);dataVector.add(recordVector);}return dataVector;}public String[] getJtableColumns(){//[FLDWORDID, FLDWORDEN, FLDWORDCN, FLDSYMBOL, FLDATTR, FLDLASTTESTDATE, FLDPRIORITY, FLDTESTTIMES, FLDFROM, FLDERRORFAG, FLDCREATDATE, FLDREMARK, FLDRELEVANCE,FLDERRORTIMES]String[] columnNames = new String[13];columnNames[0] = "";columnNames[1] = "ID";columnNames[2] = "英文";columnNames[3] = "中文";columnNames[4] = "优先级";columnNames[5] = "练习次数";columnNames[6] = "练习日期";columnNames[7] = "来源";columnNames[8] = "创建日期";columnNames[9] = "错误标记";columnNames[10] = "错误次数";columnNames[11] = "易忘";columnNames[12] = "更新";return columnNames;}public Object[][] getJtableTestDatas() {return new Object[][]{{"","1","test","adj. 测试",3,3,"20140501","CB","20140501","adj."},{"","2","test","adj. 测试",3,3,"20140501","CB","20140501","adj."},};}public String exportWords(List<Word> searchWords)  {String errMsg = "";String fileName = ReadConfig.getKey("OUTPUT_PAHT") + "/" + DateUtil.getDetailTimeStamp() + ".txt";try {BufferedWriter bw = new BufferedWriter(new FileWriter(fileName));StringBuffer sb = wordsToStringBuffer(searchWords);StringReader sReader = new StringReader(sb.toString());BufferedReader br = new BufferedReader(sReader);String content = "";while((content = br.readLine()) !=null){bw.write(content);bw.write(Constants.ENTER_SIGN);}br.close();bw.close();} catch (FileNotFoundException e) {e.printStackTrace();errMsg = e.getMessage();} catch (IOException e) {e.printStackTrace();errMsg = e.getMessage();}return errMsg;}private StringBuffer wordsToStringBuffer(List<Word> searchWords){StringBuffer sb = new StringBuffer();int i = 0;for (Word w : searchWords) {sb.append(Constants.ADD_SIGN).append(w.getFldWorden()).append(Constants.ENTER_SIGN);sb.append(wordCNtoMuitlLine(w.getFldWordcn()));if (w.getFldSymbol().length() > 0) {sb.append(Constants.AND_SIGN).append(w.getFldSymbol()).append(Constants.ENTER_SIGN);}sb.append(Constants.DOLLAR_SIGN).append(Constants.END_SIGN).append(Constants.ENTER_SIGN);}return sb;}private String wordCNtoMuitlLine(String wordCN){String[] wordCNs = wordCN.split("\t");StringBuffer sb = new StringBuffer();for(String s:wordCNs){if(s.length()>0){sb.append(Constants.WELL_SIGN).append(s.trim()).append(Constants.ENTER_SIGN);}}return sb.toString();}}

0 0
原创粉丝点击