[1001] | 1 | package nu.fw.jeti.jabber.elements; |
---|
| 2 | |
---|
| 3 | import nu.fw.jeti.jabber.*; |
---|
| 4 | |
---|
| 5 | /** |
---|
| 6 | * <p>Title: im</p> |
---|
| 7 | * <p>Description: </p> |
---|
| 8 | * <p>Copyright: Copyright (c) 2001</p> |
---|
| 9 | * <p>Company: </p> |
---|
| 10 | * @author E.S. de Boer |
---|
| 11 | * @version 1.0 |
---|
| 12 | */ |
---|
| 13 | |
---|
| 14 | public class Message extends Packet |
---|
| 15 | { |
---|
| 16 | private String body; |
---|
| 17 | private String thread; |
---|
| 18 | private String subject; |
---|
| 19 | private String type; |
---|
| 20 | |
---|
| 21 | public Message(MessageBuilder mb) |
---|
| 22 | { |
---|
| 23 | super(mb); |
---|
| 24 | body = mb.body; |
---|
| 25 | thread = mb.thread; |
---|
| 26 | subject = mb.subject; |
---|
| 27 | type = mb.type; |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | /** |
---|
| 31 | * normal message |
---|
| 32 | * @param body |
---|
| 33 | * @param to |
---|
| 34 | */ |
---|
| 35 | public Message(String body,String subject, JID to) |
---|
| 36 | { |
---|
| 37 | super(to); |
---|
| 38 | type = "normal"; |
---|
| 39 | this.body = body; |
---|
| 40 | this.subject = subject; |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | /** |
---|
| 44 | * normal message |
---|
| 45 | * @param body |
---|
| 46 | * @param to |
---|
| 47 | */ |
---|
| 48 | public Message(String body, JID to,XExtension extension) |
---|
| 49 | { |
---|
| 50 | super(to, (Extension) extension); |
---|
| 51 | type = "normal"; |
---|
| 52 | this.body = body; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | /** |
---|
| 57 | * groupchat message |
---|
| 58 | * @param to |
---|
| 59 | * @param body |
---|
| 60 | */ |
---|
| 61 | public Message(JID to,String body,XExtension extension) |
---|
| 62 | { |
---|
| 63 | super(to, (Extension) extension); |
---|
| 64 | type = "groupchat"; |
---|
| 65 | this.body = body; |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | /** |
---|
| 69 | * groupchat message |
---|
| 70 | * @param to |
---|
| 71 | * @param body |
---|
| 72 | */ |
---|
| 73 | public Message(JID to,String body) |
---|
| 74 | { |
---|
| 75 | super(to); |
---|
| 76 | type = "groupchat"; |
---|
| 77 | this.body = body; |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | public Message(String body, JID to, String thread) |
---|
| 81 | { |
---|
| 82 | super(to); |
---|
| 83 | type = "chat"; |
---|
| 84 | this.body = body; |
---|
| 85 | this.thread = thread; |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | public Message(String body, JID to, String id, String thread, XExtension extension) |
---|
| 89 | { |
---|
| 90 | super(to, id, (Extension) extension); |
---|
| 91 | type = "chat"; |
---|
| 92 | this.body = body; |
---|
| 93 | this.thread = thread; |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | public Message(String body, JID to, String id,XExtension extension) |
---|
| 97 | { |
---|
| 98 | super(to, id, (Extension) extension); |
---|
| 99 | type = "chat"; |
---|
| 100 | this.body = body; |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | public String getSubject() |
---|
| 104 | { |
---|
| 105 | return subject; |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | public String getThread() |
---|
| 109 | { |
---|
| 110 | return thread; |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | public String getBody() |
---|
| 114 | { |
---|
| 115 | return body; |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | public String getType() |
---|
| 119 | { |
---|
| 120 | return type; |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | public void appendToXML(StringBuffer xml) |
---|
| 124 | { |
---|
| 125 | //make short cut? |
---|
| 126 | xml.append("<message"); |
---|
| 127 | appendBaseAttributes(xml); |
---|
| 128 | if (!type.equals("normal")) |
---|
| 129 | appendAttribute(xml, "type", type); |
---|
| 130 | xml.append(">"); |
---|
| 131 | appendElement(xml, "thread", thread); |
---|
| 132 | appendElement(xml, "subject", subject); |
---|
| 133 | appendElement(xml, "body", body); |
---|
| 134 | if ("error".equals(type)) |
---|
| 135 | appendError(xml); |
---|
| 136 | appendExtensions(xml); |
---|
| 137 | xml.append("</message>"); |
---|
| 138 | } |
---|
| 139 | } |
---|
| 140 | /* |
---|
| 141 | * Overrides for emacs |
---|
| 142 | * Local variables: |
---|
| 143 | * tab-width: 4 |
---|
| 144 | * End: |
---|
| 145 | */ |
---|