KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Convert


1
2 /** Parses a text message to html for display in EditorPane.*/
3 public final class Convert{
4     
5     
6     public static String JavaDoc text(String JavaDoc text){
7         text=text.replaceAll("<","&lt;");
8         text=text.replaceAll(">","&gt;");
9         text=text.replaceAll("\n","<br>");
10         if(WhisperIM.UserPref.getProperty("emoticons").equals("true")){
11             text=text.replaceAll(":-\\)","<img SRC=emoticons/smile.png>");
12             text=text.replaceAll(":\\)","<img SRC=emoticons/smile.png>");
13             text=text.replaceAll(":-\\(","<img SRC=emoticons/sad.png>");
14             text=text.replaceAll(":\\(","<img SRC=emoticons/sad.png>");
15             text=text.replaceAll(";-\\)","<img SRC=emoticons/wink.png>");
16             text=text.replaceAll(";\\)","<img SRC=emoticons/wink.png>");
17             text=text.replaceAll(":-D","<img SRC=emoticons/grin.png>");
18             text=text.replaceAll(":D","<img SRC=emoticons/grin.png>");
19             text=text.replaceAll("B-\\)","<img SRC=emoticons/cool.png>");
20             text=text.replaceAll("B\\)","<img SRC=emoticons/cool.png>");
21             text=text.replaceAll(":P","<img SRC=emoticons/tongue.png>");
22             text=text.replaceAll(":-P","<img SRC=emoticons/tongue.png>");
23             text=text.replaceAll(":-\\|","<img SRC=emoticons/stare.png>");
24             text=text.replaceAll(":\\|","<img SRC=emoticons/stare.png>");
25             text=text.replaceAll(":-o","<img SRC=emoticons/oh.png>");
26             text=text.replaceAll(":o","<img SRC=emoticons/oh.png>");
27             text=text.replaceAll(":-O","<img SRC=emoticons/oh.png>");
28             text=text.replaceAll(":O","<img SRC=emoticons/oh.png>");
29             text=text.replaceAll(":-@","<img SRC=emoticons/angry.png>");
30             text=text.replaceAll(":@","<img SRC=emoticons/angry.png>");
31             text=text.replaceAll(":-\\$","<img SRC=emoticons/blush.png>");
32             text=text.replaceAll(":\\$","<img SRC=emoticons/blush.png>");
33             text=text.replaceAll(":-S","<img SRC=emoticons/frowning.png>");
34             text=text.replaceAll(":S","<img SRC=emoticons/frowning.png>");
35             text=text.replaceAll(":'-\\(","<img SRC=emoticons/cry.png>");
36             text=text.replaceAll(":'\\(","<img SRC=emoticons/cry.png>");
37             text=text.replaceAll("\\(6\\)","<img SRC=emoticons/devil.png>");
38         }
39         return text;
40     }
41 }
Popular Tags