1 20 21 package org.jivesoftware.smackx.packet; 22 import java.util.*; 23 24 import org.jivesoftware.smack.packet.IQ; 25 26 33 public class MUCOwner extends IQ { 34 35 private List items = new ArrayList(); 36 private Destroy destroy; 37 38 45 public Iterator getItems() { 46 synchronized (items) { 47 return Collections.unmodifiableList(new ArrayList(items)).iterator(); 48 } 49 } 50 51 58 public Destroy getDestroy() { 59 return destroy; 60 } 61 62 69 public void setDestroy(Destroy destroy) { 70 this.destroy = destroy; 71 } 72 73 78 public void addItem(Item item) { 79 synchronized (items) { 80 items.add(item); 81 } 82 } 83 84 public String getChildElementXML() { 85 StringBuffer buf = new StringBuffer (); 86 buf.append("<query xmlns=\"http://jabber.org/protocol/muc#owner\">"); 87 synchronized (items) { 88 for (int i = 0; i < items.size(); i++) { 89 Item item = (Item) items.get(i); 90 buf.append(item.toXML()); 91 } 92 } 93 if (getDestroy() != null) { 94 buf.append(getDestroy().toXML()); 95 } 96 buf.append(getExtensionsXML()); 98 buf.append("</query>"); 99 return buf.toString(); 100 } 101 102 107 public static class Item { 108 109 private String actor; 110 private String reason; 111 private String affiliation; 112 private String jid; 113 private String nick; 114 private String role; 115 116 121 public Item(String affiliation) { 122 this.affiliation = affiliation; 123 } 124 125 130 public String getActor() { 131 return actor; 132 } 133 134 140 public String getReason() { 141 return reason; 142 } 143 144 152 public String getAffiliation() { 153 return affiliation; 154 } 155 156 162 public String getJid() { 163 return jid; 164 } 165 166 172 public String getNick() { 173 return nick; 174 } 175 176 184 public String getRole() { 185 return role; 186 } 187 188 193 public void setActor(String actor) { 194 this.actor = actor; 195 } 196 197 203 public void setReason(String reason) { 204 this.reason = reason; 205 } 206 207 213 public void setJid(String jid) { 214 this.jid = jid; 215 } 216 217 223 public void setNick(String nick) { 224 this.nick = nick; 225 } 226 227 235 public void setRole(String role) { 236 this.role = role; 237 } 238 239 public String toXML() { 240 StringBuffer buf = new StringBuffer (); 241 buf.append("<item"); 242 if (getAffiliation() != null) { 243 buf.append(" affiliation=\"").append(getAffiliation()).append("\""); 244 } 245 if (getJid() != null) { 246 buf.append(" jid=\"").append(getJid()).append("\""); 247 } 248 if (getNick() != null) { 249 buf.append(" nick=\"").append(getNick()).append("\""); 250 } 251 if (getRole() != null) { 252 buf.append(" role=\"").append(getRole()).append("\""); 253 } 254 if (getReason() == null && getActor() == null) { 255 buf.append("/>"); 256 } 257 else { 258 buf.append(">"); 259 if (getReason() != null) { 260 buf.append("<reason>").append(getReason()).append("</reason>"); 261 } 262 if (getActor() != null) { 263 buf.append("<actor jid=\"").append(getActor()).append("\"/>"); 264 } 265 buf.append("</item>"); 266 } 267 return buf.toString(); 268 } 269 }; 270 271 278 public static class Destroy { 279 private String reason; 280 private String jid; 281 282 283 288 public String getJid() { 289 return jid; 290 } 291 292 297 public String getReason() { 298 return reason; 299 } 300 301 306 public void setJid(String jid) { 307 this.jid = jid; 308 } 309 310 315 public void setReason(String reason) { 316 this.reason = reason; 317 } 318 319 public String toXML() { 320 StringBuffer buf = new StringBuffer (); 321 buf.append("<destroy"); 322 if (getJid() != null) { 323 buf.append(" jid=\"").append(getJid()).append("\""); 324 } 325 if (getReason() == null) { 326 buf.append("/>"); 327 } 328 else { 329 buf.append(">"); 330 if (getReason() != null) { 331 buf.append("<reason>").append(getReason()).append("</reason>"); 332 } 333 buf.append("</destroy>"); 334 } 335 return buf.toString(); 336 } 337 338 } 339 } 340 | Popular Tags |