2014-01-30 23:33:01 +00:00
|
|
|
package de.gultsch.chat.xmpp;
|
|
|
|
|
|
|
|
import de.gultsch.chat.xml.Element;
|
|
|
|
|
|
|
|
public class MessagePacket extends Element {
|
2014-02-02 15:05:15 +00:00
|
|
|
public static final int TYPE_CHAT = 0;
|
|
|
|
|
2014-01-30 23:33:01 +00:00
|
|
|
private MessagePacket(String name) {
|
|
|
|
super(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
public MessagePacket() {
|
|
|
|
super("message");
|
|
|
|
}
|
2014-02-02 15:05:15 +00:00
|
|
|
|
|
|
|
public String getTo() {
|
|
|
|
return getAttribute("to");
|
|
|
|
}
|
2014-02-01 14:07:20 +00:00
|
|
|
|
|
|
|
public String getFrom() {
|
|
|
|
return getAttribute("from");
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getBody() {
|
|
|
|
return this.findChild("body").getContent();
|
|
|
|
}
|
2014-02-02 15:05:15 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2014-01-30 23:33:01 +00:00
|
|
|
}
|