1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 17:19:39 +02:00

Merge branch '4.0'

Conflicts:
	build.gradle
	documentation/connections.html
	documentation/gettingstarted.html
	smack-core/src/main/java/org/jivesoftware/smack/SmackException.java
	smack-core/src/test/java/org/jivesoftware/smack/parsing/ParsingExceptionTest.java
	smack-core/src/test/java/org/jivesoftware/smack/test/util/TestUtils.java
	smack-core/src/test/java/org/jivesoftware/smack/util/PacketParserUtilsTest.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/caps/cache/SimpleDirectoryPersistentCache.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/ping/PingManager.java
	smack-tcp/src/main/java/org/jivesoftware/smack/tcp/PacketReader.java
This commit is contained in:
Florian Schmaus 2014-07-05 14:37:22 +02:00
commit 94a16ba41e
61 changed files with 806 additions and 300 deletions

View file

@ -24,7 +24,7 @@ import org.jivesoftware.smack.test.SmackTestCase;
import org.jivesoftware.smackx.packet.Version;
/**
* Ensure that stream compression (JEP-138) is correctly supported by Smack.
* Ensure that stream compression (XEP-138) is correctly supported by Smack.
*
* @author Gaston Dombiak
*/

View file

@ -30,7 +30,7 @@ import java.util.Arrays;
import java.util.List;
/**
* Tests that JEP-33 support in Smack is correct.
* Tests that XEP-33 support in Smack is correct.
*
* @author Gaston Dombiak
*/

View file

@ -32,7 +32,7 @@ import java.util.List;
/**
* Tests handling of offline messaging using OfflineMessageManager. This server requires the
* server to support JEP-0013: Flexible Offline Message Retrieval.
* server to support XEP-0013: Flexible Offline Message Retrieval.
*
* @author Gaston Dombiak
*/
@ -44,7 +44,7 @@ public class OfflineMessageManagerTest extends SmackTestCase {
public void testDiscoverFlexibleRetrievalSupport() throws XMPPException {
OfflineMessageManager offlineManager = new OfflineMessageManager(getConnection(1));
assertTrue("Server does not support JEP-13", offlineManager.supportsFlexibleRetrieval());
assertTrue("Server does not support XEP-13", offlineManager.supportsFlexibleRetrieval());
}
/**

View file

@ -40,7 +40,7 @@ import java.util.logging.Logger;
/**
* A MultipleRecipientManager allows to send packets to multiple recipients by making use of
* <a href="http://www.jabber.org/jeps/jep-0033.html">JEP-33: Extended Stanza Addressing</a>.
* <a href="http://www.xmpp.org/extensions/jep-0033.html">XEP-33: Extended Stanza Addressing</a>.
* It also allows to send replies to packets that were sent to multiple recipients.
*
* @author Gaston Dombiak
@ -57,9 +57,9 @@ public class MultipleRecipientManager {
/**
* Sends the specified packet to the list of specified recipients using the
* specified connection. If the server has support for JEP-33 then only one
* specified connection. If the server has support for XEP-33 then only one
* packet is going to be sent to the server with the multiple recipient instructions.
* However, if JEP-33 is not supported by the server then the client is going to send
* However, if XEP-33 is not supported by the server then the client is going to send
* the packet to each recipient.
*
* @param connection the connection to use to send the packet.
@ -72,8 +72,8 @@ public class MultipleRecipientManager {
* list exists.
* @throws FeatureNotSupportedException if special XEP-33 features where requested, but the
* server does not support them.
* @throws XMPPErrorException if server does not support JEP-33: Extended Stanza Addressing and
* some JEP-33 specific features were requested.
* @throws XMPPErrorException if server does not support XEP-33: Extended Stanza Addressing and
* some XEP-33 specific features were requested.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
@ -84,8 +84,8 @@ public class MultipleRecipientManager {
/**
* Sends the specified packet to the list of specified recipients using the specified
* connection. If the server has support for JEP-33 then only one packet is going to be sent to
* the server with the multiple recipient instructions. However, if JEP-33 is not supported by
* connection. If the server has support for XEP-33 then only one packet is going to be sent to
* the server with the multiple recipient instructions. However, if XEP-33 is not supported by
* the server then the client is going to send the packet to each recipient.
*
* @param connection the connection to use to send the packet.
@ -99,8 +99,8 @@ public class MultipleRecipientManager {
* @param replyRoom JID of a MUC room to which responses should be sent or <tt>null</tt>
* indicating that they can reply to any address.
* @param noReply true means that receivers should not reply to the message.
* @throws XMPPErrorException if server does not support JEP-33: Extended Stanza Addressing and
* some JEP-33 specific features were requested.
* @throws XMPPErrorException if server does not support XEP-33: Extended Stanza Addressing and
* some XEP-33 specific features were requested.
* @throws NoResponseException if there was no response from the server.
* @throws FeatureNotSupportedException if special XEP-33 features where requested, but the
* server does not support them.
@ -115,10 +115,10 @@ public class MultipleRecipientManager {
serviceAddress);
}
else {
// Server does not support JEP-33 so try to send the packet to each recipient
// Server does not support XEP-33 so try to send the packet to each recipient
if (noReply || (replyTo != null && replyTo.trim().length() > 0) ||
(replyRoom != null && replyRoom.trim().length() > 0)) {
// Some specified JEP-33 features were requested so throw an exception alerting
// Some specified XEP-33 features were requested so throw an exception alerting
// the user that this features are not available
throw new FeatureNotSupportedException("Extended Stanza Addressing");
}
@ -191,7 +191,7 @@ public class MultipleRecipientManager {
serviceAddress);
}
else {
// Server does not support JEP-33 so try to send the packet to each recipient
// Server does not support XEP-33 so try to send the packet to each recipient
sendToIndividualRecipients(connection, reply, to, cc, null);
}
}

View file

@ -34,10 +34,10 @@ import org.jivesoftware.smackx.iqprivate.PrivateDataManager;
/**
* Provides methods to manage bookmarks in accordance with JEP-0048. Methods for managing URLs and
* Provides methods to manage bookmarks in accordance with XEP-0048. Methods for managing URLs and
* Conferences are provided.
* </p>
* It should be noted that some extensions have been made to the JEP. There is an attribute on URLs
* It should be noted that some extensions have been made to the XEP. There is an attribute on URLs
* that marks a url as a news feed and also a sub-element can be added to either a URL or conference
* indicated that it is shared amongst all users on a server.
*

View file

@ -18,7 +18,7 @@
package org.jivesoftware.smackx.bookmarks;
/**
* Respresents a Conference Room bookmarked on the server using JEP-0048 Bookmark Storage JEP.
* Respresents a Conference Room bookmarked on the server using XEP-0048 Bookmark Storage XEP.
*
* @author Derek DeMoro
*/

View file

@ -18,7 +18,7 @@
package org.jivesoftware.smackx.bookmarks;
/**
* Respresents one instance of a URL defined using JEP-0048 Bookmark Storage JEP.
* Respresents one instance of a URL defined using XEP-0048 Bookmark Storage XEP.
*
* @author Derek DeMoro
*/

View file

@ -16,6 +16,7 @@
*/
package org.jivesoftware.smackx.bookmarks;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smackx.iqprivate.packet.PrivateData;
import org.jivesoftware.smackx.iqprivate.provider.PrivateDataProvider;
import org.xmlpull.v1.XmlPullParser;
@ -27,7 +28,7 @@ import java.util.List;
/**
* Bookmarks is used for storing and retrieving URLS and Conference rooms.
* Bookmark Storage (JEP-0048) defined a protocol for the storage of bookmarks to conference rooms and other entities
* Bookmark Storage (XEP-0048) defined a protocol for the storage of bookmarks to conference rooms and other entities
* in a Jabber user's account.
* See the following code sample for saving Bookmarks:
* <p/>
@ -59,6 +60,9 @@ import java.util.List;
*/
public class Bookmarks implements PrivateData {
public static final String NAMESPACE = "storage:bookmarks";
public static final String ELEMENT = "storage";
private List<BookmarkedURL> bookmarkedURLS;
private List<BookmarkedConference> bookmarkedConferences;
@ -145,7 +149,7 @@ public class Bookmarks implements PrivateData {
* @return the element name.
*/
public String getElementName() {
return "storage";
return ELEMENT;
}
/**
@ -154,28 +158,26 @@ public class Bookmarks implements PrivateData {
* @return the namespace.
*/
public String getNamespace() {
return "storage:bookmarks";
return NAMESPACE;
}
/**
* Returns the XML reppresentation of the PrivateData.
* Returns the XML representation of the PrivateData.
*
* @return the private data as XML.
*/
public String toXML() {
StringBuilder buf = new StringBuilder();
buf.append("<storage xmlns=\"storage:bookmarks\">");
@Override
public XmlStringBuilder toXML() {
XmlStringBuilder buf = new XmlStringBuilder();
buf.openElement(ELEMENT).xmlnsAttribute(NAMESPACE);
for (BookmarkedURL urlStorage : getBookmarkedURLS()) {
if(urlStorage.isShared()) {
continue;
}
buf.append("<url name=\"").append(urlStorage.getName()).
append("\" url=\"").append(urlStorage.getURL()).append("\"");
if(urlStorage.isRss()) {
buf.append(" rss=\"").append(true).append("\"");
}
buf.append(" />");
buf.openElement("url").attribute("name", urlStorage.getName()).attribute("url", urlStorage.getURL());
buf.condAttribute(urlStorage.isRss(), "rss", "true");
buf.closeEmptyElement();
}
// Add Conference additions
@ -183,26 +185,20 @@ public class Bookmarks implements PrivateData {
if(conference.isShared()) {
continue;
}
buf.append("<conference ");
buf.append("name=\"").append(conference.getName()).append("\" ");
buf.append("autojoin=\"").append(conference.isAutoJoin()).append("\" ");
buf.append("jid=\"").append(conference.getJid()).append("\" ");
buf.append(">");
buf.openElement("conference");
buf.attribute("name", conference.getName());
buf.attribute("autojoin", Boolean.toString(conference.isAutoJoin()));
buf.attribute("jid", conference.getJid());
buf.rightAngelBracket();
if (conference.getNickname() != null) {
buf.append("<nick>").append(conference.getNickname()).append("</nick>");
}
buf.optElement("nick", conference.getNickname());
buf.optElement("password", conference.getPassword());
if (conference.getPassword() != null) {
buf.append("<password>").append(conference.getPassword()).append("</password>");
}
buf.append("</conference>");
buf.closeElement("conference");
}
buf.append("</storage>");
return buf.toString();
buf.closeElement(ELEMENT);
return buf;
}
/**

View file

@ -45,7 +45,6 @@ import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo.Feature;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo.Identity;
import org.jivesoftware.smackx.disco.packet.DiscoverItems.Item;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.packet.DataForm;
@ -536,7 +535,7 @@ public class EntityCapsManager extends Manager {
protected static boolean verifyPacketExtensions(DiscoverInfo info) {
List<FormField> foundFormTypes = new LinkedList<FormField>();
for (PacketExtension pe : info.getExtensions()) {
if (pe.getNamespace().equals(Form.NAMESPACE)) {
if (pe.getNamespace().equals(DataForm.NAMESPACE)) {
DataForm df = (DataForm) pe;
for (FormField f : df.getFields()) {
if (f.getVariable().equals("FORM_TYPE")) {
@ -569,7 +568,7 @@ public class EntityCapsManager extends Manager {
if (md == null)
return null;
DataForm extendedInfo = (DataForm) discoverInfo.getExtension(Form.ELEMENT, Form.NAMESPACE);
DataForm extendedInfo = (DataForm) discoverInfo.getExtension(DataForm.ELEMENT, DataForm.NAMESPACE);
// 1. Initialize an empty string S ('sb' in this method).
StringBuilder sb = new StringBuilder(); // Use StringBuilder as we don't

View file

@ -43,7 +43,7 @@ import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.packet.DataForm;
/**
* Manages the negotiation of file transfers according to JEP-0096. If a file is
* Manages the negotiation of file transfers according to XEP-0096. If a file is
* being sent the remote user chooses the type of stream under which the file
* will be sent.
*
@ -287,13 +287,13 @@ public class FileTransferNegotiator extends Manager {
* If they accept, the packet will contain the other user's chosen stream
* type to send the file across. The two choices this implementation
* provides to the other user for file transfer are <a
* href="http://www.jabber.org/jeps/jep-0065.html">SOCKS5 Bytestreams</a>,
* href="http://www.xmpp.org/extensions/jep-0065.html">SOCKS5 Bytestreams</a>,
* which is the preferred method of transfer, and <a
* href="http://www.jabber.org/jeps/jep-0047.html">In-Band Bytestreams</a>,
* href="http://www.xmpp.org/extensions/jep-0047.html">In-Band Bytestreams</a>,
* which is the fallback mechanism.
* <p/>
* The other user may choose to decline the file request if they do not
* desire the file, their client does not support JEP-0096, or if there are
* desire the file, their client does not support XEP-0096, or if there are
* no acceptable means to transfer the file.
* <p/>
* Finally, if the other user does not respond this method will return null

View file

@ -36,7 +36,7 @@ import java.io.OutputStream;
/**
* After the file transfer negotiation process is completed according to
* JEP-0096, the negotiation process is passed off to a particular stream
* XEP-0096, the negotiation process is passed off to a particular stream
* negotiator. The stream negotiator will then negotiate the chosen stream and
* return the stream to transfer the file.
*

View file

@ -50,7 +50,7 @@ import java.util.WeakHashMap;
* a {@link DefaultPrivateData} instance will be returned.<p>
*
* Warning: this is an non-standard protocol documented by
* <a href="http://www.jabber.org/jeps/jep-0049.html">JEP-49</a>. Because this is a
* <a href="http://www.xmpp.org/extensions/jep-0049.html">XEP-49</a>. Because this is a
* non-standard protocol, it is subject to change.
*
* @author Matt Tucker
@ -285,7 +285,7 @@ public class PrivateDataManager extends Manager {
StringBuilder buf = new StringBuilder();
buf.append("<query xmlns=\"jabber:iq:private\">");
if (privateData != null) {
privateData.toXML();
buf.append(privateData.toXML());
}
buf.append("</query>");
return buf.toString();

View file

@ -45,5 +45,5 @@ public interface PrivateData {
*
* @return the private data as XML.
*/
public String toXML();
public CharSequence toXML();
}

View file

@ -43,8 +43,8 @@ import org.xmlpull.v1.XmlPullParser;
* // Create a packet collector or packet listeners using the filter...
* </pre>
*
* <b>Note</b>: this protocol is outdated now that the Multi-User Chat (MUC) JEP is available
* (<a href="http://www.jabber.org/jeps/jep-0045.html">JEP-45</a>). However, most
* <b>Note</b>: this protocol is outdated now that the Multi-User Chat (MUC) XEP is available
* (<a href="http://www.xmpp.org/extensions/jep-0045.html">XEP-45</a>). However, most
* existing clients still use this older protocol. Once MUC support becomes more
* widespread, this API may be deprecated.
*

View file

@ -520,7 +520,7 @@ public class MUCUser implements PacketExtension {
/**
* Status code assists in presenting notification messages. The following link provides the
* list of existing error codes (@link http://www.jabber.org/jeps/jep-0045.html#errorstatus).
* list of existing error codes (@link http://www.xmpp.org/extensions/jep-0045.html#errorstatus).
*
* @author Gaston Dombiak
*/

View file

@ -20,7 +20,6 @@ import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.provider.PacketExtensionProvider;
import org.jivesoftware.smack.provider.ProviderManager;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.pubsub.Item;
import org.jivesoftware.smackx.pubsub.PayloadItem;
import org.jivesoftware.smackx.pubsub.SimplePayload;
@ -41,7 +40,6 @@ public class ItemProvider implements PacketExtensionProvider
{
String id = parser.getAttributeValue(null, "id");
String node = parser.getAttributeValue(null, "node");
String elem = parser.getName();
int tag = parser.next();
@ -56,57 +54,8 @@ public class ItemProvider implements PacketExtensionProvider
if (ProviderManager.getExtensionProvider(payloadElemName, payloadNS) == null)
{
boolean done = false;
boolean isEmptyElement = false;
StringBuilder payloadText = new StringBuilder();
while (!done)
{
if (tag == XmlPullParser.END_TAG && parser.getName().equals(elem))
{
done = true;
continue;
}
else if (parser.getEventType() == XmlPullParser.START_TAG)
{
payloadText.append("<").append(parser.getName());
if (parser.getName().equals(payloadElemName) && (payloadNS.length() > 0))
payloadText.append(" xmlns=\"").append(payloadNS).append("\"");
int n = parser.getAttributeCount();
for (int i = 0; i < n; i++)
payloadText.append(" ").append(parser.getAttributeName(i)).append("=\"")
.append(parser.getAttributeValue(i)).append("\"");
if (parser.isEmptyElementTag())
{
payloadText.append("/>");
isEmptyElement = true;
}
else
{
payloadText.append(">");
}
}
else if (parser.getEventType() == XmlPullParser.END_TAG)
{
if (isEmptyElement)
{
isEmptyElement = false;
}
else
{
payloadText.append("</").append(parser.getName()).append(">");
}
}
else if (parser.getEventType() == XmlPullParser.TEXT)
{
payloadText.append(StringUtils.escapeForXML(parser.getText()));
}
tag = parser.next();
}
return new PayloadItem<SimplePayload>(id, node, new SimplePayload(payloadElemName, payloadNS, payloadText.toString()));
String payloadText = PacketParserUtils.parseElement(parser);
return new PayloadItem<SimplePayload>(id, node, new SimplePayload(payloadElemName, payloadNS, payloadText));
}
else
{

View file

@ -25,7 +25,7 @@ import java.util.ArrayList;
import java.util.List;
/**
* SimpleUserSearch is used to support the non-dataform type of JEP 55. This provides
* SimpleUserSearch is used to support the non-dataform type of XEP 55. This provides
* the mechanism for allowing always type ReportedData to be returned by any search result,
* regardless of the form of the data returned from the server.
*

View file

@ -31,7 +31,7 @@ import java.util.Collection;
import java.util.List;
/**
* The UserSearchManager is a facade built upon Jabber Search Services (JEP-055) to allow for searching
* The UserSearchManager is a facade built upon Jabber Search Services (XEP-055) to allow for searching
* repositories on a Jabber Server. This implementation allows for transparency of implementation of
* searching (DataForms or No DataForms), but allows the user to simply use the DataForm model for both
* types of support.

View file

@ -45,7 +45,7 @@ import org.jivesoftware.smackx.vcardtemp.VCardManager;
* <a href="http://www.jivesoftware.org/smack/" target="_blank">SMACK jabber library</a>.<p>
* <p/>
* You should refer to the
* <a href="http://www.jabber.org/jeps/jep-0054.html" target="_blank">JEP-54 documentation</a>.<p>
* <a href="http://www.xmpp.org/extensions/jep-0054.html" target="_blank">XEP-54 documentation</a>.<p>
* <p/>
* Please note that this class is incomplete but it does provide the most commonly found
* information in vCards. Also remember that VCard transfer is not a standard, and the protocol
@ -114,7 +114,7 @@ public class VCard extends IQ {
private String photoBinval;
/**
* Such as DESC ROLE GEO etc.. see JEP-0054
* Such as DESC ROLE GEO etc.. see XEP-0054
*/
private Map<String, String> otherSimpleFields = new HashMap<String, String>();

View file

@ -49,9 +49,6 @@ public class Form {
public static final String TYPE_CANCEL = "cancel";
public static final String TYPE_RESULT = "result";
public static final String NAMESPACE = "jabber:x:data";
public static final String ELEMENT = "x";
private DataForm dataForm;
/**

View file

@ -17,7 +17,6 @@
package org.jivesoftware.smackx.xdata;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.XmlStringBuilder;
import java.util.ArrayList;
@ -33,6 +32,8 @@ import java.util.List;
*/
public class FormField {
public static final String ELEMENT = "field";
public static final String TYPE_BOOLEAN = "boolean";
public static final String TYPE_FIXED = "fixed";
public static final String TYPE_HIDDEN = "hidden";
@ -263,25 +264,17 @@ public class FormField {
}
}
public String toXML() {
public XmlStringBuilder toXML() {
XmlStringBuilder buf = new XmlStringBuilder();
buf.append("<field");
buf.halfOpenElement(ELEMENT);
// Add attributes
if (getLabel() != null) {
buf.append(" label=\"").append(getLabel()).append("\"");
}
buf.attribute("var", getVariable());
if (getType() != null) {
buf.append(" type=\"").append(getType()).append("\"");
}
buf.append(">");
buf.optAttribute("label", getLabel());
buf.optAttribute("var", getVariable());
buf.optAttribute("type", getType());
buf.rightAngelBracket();
// Add elements
if (getDescription() != null) {
buf.append("<desc>").append(getDescription()).append("</desc>");
}
if (isRequired()) {
buf.append("<required/>");
}
buf.optElement("desc", getDescription());
buf.condEmptyElement(isRequired(), "required");
// Loop through all the values and append them to the string buffer
for (String value : getValues()) {
buf.element("value", value);
@ -290,8 +283,8 @@ public class FormField {
for (Option option : getOptions()) {
buf.append(option.toXML());
}
buf.append("</field>");
return buf.toString();
buf.closeElement(ELEMENT);
return buf;
}
@Override
@ -320,8 +313,10 @@ public class FormField {
*/
public static class Option {
public static final String ELEMNT = "option";
private final String value;
private String label;
private String value;
public Option(String value) {
this.value = value;
@ -355,19 +350,18 @@ public class FormField {
return getLabel();
}
public String toXML() {
StringBuilder buf = new StringBuilder();
buf.append("<option");
public XmlStringBuilder toXML() {
XmlStringBuilder xml = new XmlStringBuilder();
xml.halfOpenElement(ELEMNT);
// Add attribute
if (getLabel() != null) {
buf.append(" label=\"").append(getLabel()).append("\"");
}
buf.append(">");
// Add element
buf.append("<value>").append(StringUtils.escapeForXML(getValue())).append("</value>");
xml.optAttribute("label", getLabel());
xml.rightAngelBracket();
buf.append("</option>");
return buf.toString();
// Add element
xml.element("value", getValue());
xml.closeElement(ELEMENT);
return xml;
}
@Override

View file

@ -18,7 +18,7 @@
package org.jivesoftware.smackx.xdata.packet;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smackx.xdata.FormField;
import java.util.ArrayList;
@ -33,6 +33,9 @@ import java.util.List;
*/
public class DataForm implements PacketExtension {
public static final String NAMESPACE = "jabber:x:data";
public static final String ELEMENT = "x";
private String type;
private String title;
private List<String> instructions = new ArrayList<String>();
@ -120,11 +123,11 @@ public class DataForm implements PacketExtension {
}
public String getElementName() {
return Form.ELEMENT;
return ELEMENT;
}
public String getNamespace() {
return Form.NAMESPACE;
return NAMESPACE;
}
/**
@ -207,15 +210,15 @@ public class DataForm implements PacketExtension {
return found;
}
public String toXML() {
StringBuilder buf = new StringBuilder();
buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append(
"\" type=\"" + getType() +"\">");
if (getTitle() != null) {
buf.append("<title>").append(getTitle()).append("</title>");
}
@Override
public XmlStringBuilder toXML() {
XmlStringBuilder buf = new XmlStringBuilder(this);
buf.attribute("type", getType());
buf.rightAngelBracket();
buf.optElement("title", getTitle());
for (String instruction : getInstructions()) {
buf.append("<instructions>").append(instruction).append("</instructions>");
buf.element("instructions", instruction);
}
// Append the list of fields returned from a search
if (getReportedData() != null) {
@ -229,8 +232,8 @@ public class DataForm implements PacketExtension {
for (FormField field : getFields()) {
buf.append(field.toXML());
}
buf.append("</").append(getElementName()).append(">");
return buf.toString();
buf.closeElement(this);
return buf;
}
/**
@ -241,6 +244,8 @@ public class DataForm implements PacketExtension {
* @author Gaston Dombiak
*/
public static class ReportedData {
public static final String ELEMENT = "reported";
private List<FormField> fields = new ArrayList<FormField>();
public ReportedData(List<FormField> fields) {
@ -256,15 +261,15 @@ public class DataForm implements PacketExtension {
return Collections.unmodifiableList(new ArrayList<FormField>(fields));
}
public String toXML() {
StringBuilder buf = new StringBuilder();
buf.append("<reported>");
public CharSequence toXML() {
XmlStringBuilder buf = new XmlStringBuilder();
buf.openElement(ELEMENT);
// Loop through all the form items and append them to the string buffer
for (FormField field : getFields()) {
buf.append(field.toXML());
}
buf.append("</reported>");
return buf.toString();
buf.closeElement(ELEMENT);
return buf;
}
}
@ -275,6 +280,8 @@ public class DataForm implements PacketExtension {
* @author Gaston Dombiak
*/
public static class Item {
public static final String ELEMENT = "item";
private List<FormField> fields = new ArrayList<FormField>();
public Item(List<FormField> fields) {
@ -290,15 +297,15 @@ public class DataForm implements PacketExtension {
return Collections.unmodifiableList(new ArrayList<FormField>(fields));
}
public String toXML() {
StringBuilder buf = new StringBuilder();
buf.append("<item>");
public CharSequence toXML() {
XmlStringBuilder buf = new XmlStringBuilder();
buf.openElement(ELEMENT);
// Loop through all the form items and append them to the string buffer
for (FormField field : getFields()) {
buf.append(field.toXML());
}
buf.append("</item>");
return buf.toString();
buf.closeElement(ELEMENT);
return buf;
}
}
}

View file

@ -29,10 +29,10 @@ import java.util.List;
* extension is only a subset of XHTML 1.0.<p>
*
* The following link summarizes the requirements of XHTML IM:
* <a href="http://www.jabber.org/jeps/jep-0071.html#sect-id2598018">Valid tags</a>.<p>
* <a href="http://www.xmpp.org/extensions/jep-0071.html#sect-id2598018">Valid tags</a>.<p>
*
* Warning: this is an non-standard protocol documented by
* <a href="http://www.jabber.org/jeps/jep-0071.html">JEP-71</a>. Because this is a
* <a href="http://www.xmpp.org/extensions/jep-0071.html">XEP-71</a>. Because this is a
* non-standard protocol, it is subject to change.
*
* @author Gaston Dombiak

View file

@ -172,7 +172,7 @@
<className>org.jivesoftware.smackx.sharedgroups.packet.SharedGroupsInfo$Provider</className>
</iqProvider>
<!-- JEP-33: Extended Stanza Addressing -->
<!-- XEP-33: Extended Stanza Addressing -->
<extensionProvider>
<elementName>addresses</elementName>
<namespace>http://jabber.org/protocol/address</namespace>

View file

@ -51,6 +51,6 @@ public class FileTransferNegotiatorTest {
fileNeg.negotiateOutgoingTransfer("me", "streamid", "file", 1024, null, 10);
Packet packet = connection.getSentPacket();
String xml = packet.toXML().toString();
assertTrue(xml.indexOf("var='stream-method' type=\"list-single\"") != -1);
assertTrue(xml.indexOf("var='stream-method' type='list-single'") != -1);
}
}