/** * Generate the display of the results of the Match command * * @param data the result of the Match command * @param word the queried word * @return the formatted result */ private String retrieveMatch(List<MatchWord> data, String word) { StringBuffer result = new StringBuffer(); boolean isStart = true; result.append( DictActivator.getResources() .getI18NString("plugin.dictaccregwizz.MATCH_RESULT", new String[] {word})); for (int i = 0; i < data.size(); i++) { if (isStart) isStart = false; else result.append(", "); result.append(data.get(i).getWord()); } return result.toString(); }
/** * Generate the display of the results of the Define command * * @param data the result of the Define command * @param word the queried word * @return the formatted result */ private String retrieveDefine(List<Definition> data, String word) { StringBuffer res = new StringBuffer(); Definition def; for (int i = 0; i < data.size(); i++) { def = data.get(i); if (i != 0 && data.size() > 0) { res.append("<hr>"); } res.append(def.getDefinition().replaceAll("\n", "<br>")) .append("<div align=\"right\"><font size=\"-2\">-- From ") .append(def.getDictionary()) .append("</font></div>"); } String result = res.toString(); result = formatResult(result, "\\\\", "<em>", "</em>"); result = formatResult(result, "[\\[\\]]", "<cite>", "</cite>"); result = formatResult(result, "[\\{\\}]", "<strong>", "</strong>"); result = formatWordDefined(result, word); return result; }