1 package chat.business; 2 3 import java.util.Vector ; 4 import com.lutris.util.HtmlEncoder; 5 import chat.spec.*; 6 7 13 public class MessageImpl implements Message{ 14 15 18 public String name; 19 20 24 public String htmlName; 25 26 31 public String text; 32 33 37 public Vector htmlChunks = new Vector (); 38 39 43 private long when; 44 45 50 public MessageImpl(String name, String text) { 51 when = System.currentTimeMillis(); 52 this.name = name; 53 this.htmlName = HtmlEncoder.encode(name); 54 this.text = text; 55 58 if (text.length() == 0) 59 htmlChunks.addElement(""); 60 while (text.length() != 0) { 61 int end = text.indexOf("\n"); 62 if (end != -1) { 63 htmlChunks.addElement(HtmlEncoder.encode(text.substring(0,end))); 64 text = text.substring(end+1); 65 } else { 66 htmlChunks.addElement(HtmlEncoder.encode(text)); 67 text = ""; 68 } 69 } 70 } 71 72 73 77 public long getWhen() { 78 return when; 79 } 80 public String getHtmlName(){ 81 return htmlName; 82 } 83 public Vector getHtmlChunks(){ 84 return htmlChunks; 85 } 86 87 } 88 89 | Popular Tags |