1package de.gultsch.chat.xmpp;
2
3import de.gultsch.chat.xml.Element;
4
5public class MessagePacket extends Element {
6 public static final int TYPE_CHAT = 0;
7
8 private MessagePacket(String name) {
9 super(name);
10 }
11
12 public MessagePacket() {
13 super("message");
14 }
15
16 public String getTo() {
17 return getAttribute("to");
18 }
19
20 public String getFrom() {
21 return getAttribute("from");
22 }
23
24 public String getBody() {
25 return this.findChild("body").getContent();
26 }
27
28 public void setTo(String to) {
29 setAttribute("to", to);
30 }
31
32 public void setFrom(String from) {
33 setAttribute("from",from);
34 }
35
36 public void setBody(String text) {
37 Element body = new Element("body");
38 body.setContent(text);
39 this.children.add(body);
40 }
41
42 public void setType(int type) {
43 switch (type) {
44 case TYPE_CHAT:
45 this.setAttribute("type","chat");
46 break;
47
48 default:
49 this.setAttribute("type","chat");
50 break;
51 }
52 }
53}