/** * Manages the return exception of a dict query. * * @param dix The exception returned by the adapter * @param database The dictionary used * @return Exception message */ private String manageException(DictException dix, String database) { int errorCode = dix.getErrorCode(); // We change the text only for exception 550 (invalid dictionary) and 551 (invalid strategy) if (errorCode == DictReturnCode.INVALID_DATABASE) { return DictActivator.getResources() .getI18NString("plugin.dictaccregwizz.INVALID_DATABASE", new String[] {database}); } else if (errorCode == DictReturnCode.INVALID_STRATEGY) { return DictActivator.getResources().getI18NString("plugin.dictaccregwizz.INVALID_STRATEGY"); } else if (errorCode == DictReturnCode.NO_MATCH) { return DictActivator.getResources().getI18NString("plugin.dictaccregwizz.NO_MATCH"); } return dix.getMessage(); }
/** * 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(); }