1 20 21 package org.jivesoftware.smackx.packet; 22 23 import java.util.*; 24 25 import org.jivesoftware.smack.packet.PacketExtension; 26 27 40 public class XHTMLExtension implements PacketExtension { 41 42 private List bodies = new ArrayList(); 43 44 50 public String getElementName() { 51 return "html"; 52 } 53 54 60 public String getNamespace() { 61 return "http://jabber.org/protocol/xhtml-im"; 62 } 63 64 80 public String toXML() { 81 StringBuffer buf = new StringBuffer (); 82 buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append( 83 "\">"); 84 for (Iterator i = getBodies(); i.hasNext();) { 86 buf.append((String ) i.next()); 87 } 88 buf.append("</").append(getElementName()).append(">"); 89 return buf.toString(); 90 } 91 92 97 public Iterator getBodies() { 98 synchronized (bodies) { 99 return Collections.unmodifiableList(new ArrayList(bodies)).iterator(); 100 } 101 } 102 103 108 public void addBody(String body) { 109 synchronized (bodies) { 110 bodies.add(body); 111 } 112 } 113 114 119 public int getBodiesCount() { 120 return bodies.size(); 121 } 122 123 } 124 | Popular Tags |