0)
{
res.append("
");
}
res.append(def.getDefinition().replaceAll("\n", "
"))
.append("-- From ")
.append(def.getDictionary())
.append("
");
}
String result = res.toString();
result = formatResult(result, "\\\\", "", "");
result = formatResult(result, "[\\[\\]]", "", "");
result = formatResult(result, "[\\{\\}]", "", "");
result = formatWordDefined(result, word);
return result;
}
/**
* Makes a stronger emphasis for the word defined.
* @param result The text containing the definition of the word.
* @param word The word defined to display with bold font. For this we
* had the strong HTML tag.
* @return Returns the result text with an strong emphasis of all
* the occurences of the word defined.
*/
private String formatWordDefined(String result, String word)
{
String tmpWord;
tmpWord = word.toUpperCase();
result = result.replaceAll("\\b" + tmpWord + "\\b", "" + tmpWord + "");
tmpWord = word.toLowerCase();
result = result.replaceAll("\\b" + tmpWord + "\\b", "" + tmpWord + "");
if(tmpWord.length() > 1)
{
tmpWord = tmpWord.substring(0, 1).toUpperCase() + tmpWord.substring(1);
result = result.replaceAll("\\b" + tmpWord + "\\b", "" + tmpWord + "");
}
return result;
}
/**
* Remplaces special characters into HTML tags to make some emphasis.
* @param result The text containing the definition of the word.
* @param regex The special character to replace with HTML tags.
* @param startTag The start HTML tag to use.
* @param endTag The end HTML tag to use.
* @return The result with all special characters replaced by HTML
* tags.
*/
private String formatResult(String result, String regex, String startTag, String endTag)
{
String[] tmp = result.split(regex);
String res = "";
for(int i = 0; i < (tmp.length - 1); i += 2)
{
res += tmp[i] + startTag + tmp[i+1] + endTag;
}
if((tmp.length % 2) != 0)
{
res += tmp[tmp.length - 1];
}
return res;
}
/**
* 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 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; imessage to the destination indicated by the
* to. Resources are not supported by this operation set
* implementation.
*
* @param to the Contact to send message to
* @param toResource the resource to which the message should be send
* @param message the Message to send.
* @throws java.lang.IllegalStateException if the underlying ICQ stack is
* not registered and initialized.
* @throws java.lang.IllegalArgumentException if to is not an
* instance belonging to the underlying implementation.
*/
@Override
public void sendInstantMessage( Contact to,
ContactResource toResource,
Message message)
throws IllegalStateException,
IllegalArgumentException
{
sendInstantMessage(to, message);
}
}