diff options
Diffstat (limited to '')
-rw-r--r-- | src/de/gultsch/chat/xmpp/MessagePacket.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/de/gultsch/chat/xmpp/MessagePacket.java b/src/de/gultsch/chat/xmpp/MessagePacket.java index 313fb355..de486a5d 100644 --- a/src/de/gultsch/chat/xmpp/MessagePacket.java +++ b/src/de/gultsch/chat/xmpp/MessagePacket.java @@ -3,6 +3,8 @@ package de.gultsch.chat.xmpp; import de.gultsch.chat.xml.Element; public class MessagePacket extends Element { + public static final int TYPE_CHAT = 0; + private MessagePacket(String name) { super(name); } @@ -10,6 +12,10 @@ public class MessagePacket extends Element { public MessagePacket() { super("message"); } + + public String getTo() { + return getAttribute("to"); + } public String getFrom() { return getAttribute("from"); @@ -18,4 +24,30 @@ public class MessagePacket extends Element { public String getBody() { return this.findChild("body").getContent(); } + + public void setTo(String to) { + setAttribute("to", to); + } + + public void setFrom(String from) { + setAttribute("from",from); + } + + public void setBody(String text) { + Element body = new Element("body"); + body.setContent(text); + this.children.add(body); + } + + public void setType(int type) { + switch (type) { + case TYPE_CHAT: + this.setAttribute("type","chat"); + break; + + default: + this.setAttribute("type","chat"); + break; + } + } } |