mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 03:52:06 +01:00
Introduce XmlEnvironment
This commit is contained in:
parent
dc780ffd6c
commit
fee3ed81ca
229 changed files with 715 additions and 526 deletions
|
@ -45,7 +45,7 @@ public class Compress implements Nonza {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
xml.rightAngleBracket();
|
||||
xml.element("method", method);
|
||||
|
@ -77,7 +77,7 @@ public class Compress implements Nonza {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.rightAngleBracket();
|
||||
for (String method : methods) {
|
||||
|
|
|
@ -39,7 +39,7 @@ public final class Compressed implements Nonza {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toXML(String enclosingNamespace) {
|
||||
public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
return '<' + ELEMENT + " xmlns='" + NAMESPACE + "'/>";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ public class Failure implements Nonza {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
xml.rightAngleBracket();
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ public abstract class AbstractDebugger extends SmackDebugger {
|
|||
@Override
|
||||
public void onIncomingStreamElement(TopLevelStreamElement streamElement) {
|
||||
if (printInterpreted) {
|
||||
log("RCV PKT (" + connection.getConnectionCounter() + "): " + streamElement.toXML(null));
|
||||
log("RCV PKT (" + connection.getConnectionCounter() + "): " + streamElement.toXML());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ public class AbstractError {
|
|||
xml.closeElement("text");
|
||||
}
|
||||
for (ExtensionElement packetExtension : extensions) {
|
||||
xml.append(packetExtension.toXML(null));
|
||||
xml.append(packetExtension.toXML());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public abstract class AbstractTextElement implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.optXmlLangAttribute(lang);
|
||||
xml.rightAngleBracket();
|
||||
|
|
|
@ -89,7 +89,7 @@ public final class Bind extends IQ {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toXML(String enclosingNamespace) {
|
||||
public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
return '<' + ELEMENT + " xmlns='" + NAMESPACE + "'/>";
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ public class DefaultExtensionElement implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder buf = new XmlStringBuilder();
|
||||
buf.halfOpenElement(elementName).xmlnsAttribute(namespace).rightAngleBracket();
|
||||
for (String name : getNames()) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2014-2018 Florian Schmaus
|
||||
* Copyright © 2014-2019 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -23,7 +23,7 @@ package org.jivesoftware.smack.packet;
|
|||
*/
|
||||
public interface Element {
|
||||
|
||||
// TODO: Add a toXML() non-parameter default method once Smack supports Java 8.
|
||||
CharSequence toXML(XmlEnvironment xmlEnvironment);
|
||||
|
||||
/**
|
||||
* Returns the XML representation of this Element. This method takes an optional argument for the enclosing
|
||||
|
@ -32,5 +32,12 @@ public interface Element {
|
|||
* @param enclosingNamespace the enclosing namespace or {@code null}.
|
||||
* @return the stanza extension as XML.
|
||||
*/
|
||||
CharSequence toXML(String enclosingNamespace);
|
||||
default CharSequence toXML(String enclosingNamespace) {
|
||||
XmlEnvironment xmlEnvironment = new XmlEnvironment(enclosingNamespace);
|
||||
return toXML(xmlEnvironment);
|
||||
}
|
||||
|
||||
default CharSequence toXML() {
|
||||
return toXML(XmlEnvironment.EMPTY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,10 +126,10 @@ public abstract class IQ extends Stanza {
|
|||
}
|
||||
|
||||
@Override
|
||||
public final XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
XmlStringBuilder buf = new XmlStringBuilder(enclosingNamespace);
|
||||
public final XmlStringBuilder toXML(XmlEnvironment enclosingXmlEnvironment) {
|
||||
XmlStringBuilder buf = new XmlStringBuilder(enclosingXmlEnvironment);
|
||||
buf.halfOpenElement(IQ_ELEMENT);
|
||||
addCommonAttributes(buf, enclosingNamespace);
|
||||
addCommonAttributes(buf, enclosingXmlEnvironment);
|
||||
if (type == null) {
|
||||
buf.attribute("type", "get");
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ public abstract class IQ extends Stanza {
|
|||
buf.attribute("type", type.toString());
|
||||
}
|
||||
buf.rightAngleBracket();
|
||||
buf.append(getChildElementXML(enclosingNamespace));
|
||||
buf.append(getChildElementXML(enclosingXmlEnvironment));
|
||||
buf.closeElement(IQ_ELEMENT);
|
||||
return buf;
|
||||
}
|
||||
|
@ -156,15 +156,15 @@ public abstract class IQ extends Stanza {
|
|||
* Returns the sub-element XML section of the IQ packet, or the empty String if there
|
||||
* isn't one.
|
||||
*
|
||||
* @param enclosingNamespace the enclosing XML namespace.
|
||||
* @param enclosingXmlEnvironment the enclosing XML namespace.
|
||||
* @return the child element section of the IQ XML.
|
||||
* @since 4.3.0
|
||||
*/
|
||||
public final XmlStringBuilder getChildElementXML(String enclosingNamespace) {
|
||||
public final XmlStringBuilder getChildElementXML(XmlEnvironment enclosingXmlEnvironment) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
if (type == Type.error) {
|
||||
// Add the error sub-packet, if there is one.
|
||||
appendErrorIfExists(xml, enclosingNamespace);
|
||||
appendErrorIfExists(xml, enclosingXmlEnvironment);
|
||||
}
|
||||
else if (childElementName != null) {
|
||||
// Add the query section if there is one.
|
||||
|
@ -240,7 +240,7 @@ public abstract class IQ extends Stanza {
|
|||
protected final void initializeAsResultFor(IQ request) {
|
||||
if (!(request.getType() == Type.get || request.getType() == Type.set)) {
|
||||
throw new IllegalArgumentException(
|
||||
"IQ must be of type 'set' or 'get'. Original IQ: " + request.toXML(null));
|
||||
"IQ must be of type 'set' or 'get'. Original IQ: " + request.toXML());
|
||||
}
|
||||
setStanzaId(request.getStanzaId());
|
||||
setFrom(request.getTo());
|
||||
|
@ -289,7 +289,7 @@ public abstract class IQ extends Stanza {
|
|||
public static ErrorIQ createErrorResponse(final IQ request, final StanzaError.Builder error) {
|
||||
if (!(request.getType() == Type.get || request.getType() == Type.set)) {
|
||||
throw new IllegalArgumentException(
|
||||
"IQ must be of type 'set' or 'get'. Original IQ: " + request.toXML(null));
|
||||
"IQ must be of type 'set' or 'get'. Original IQ: " + request.toXML());
|
||||
}
|
||||
final ErrorIQ result = new ErrorIQ(error);
|
||||
result.setStanzaId(request.getStanzaId());
|
||||
|
@ -381,7 +381,6 @@ public abstract class IQ extends Stanza {
|
|||
}
|
||||
|
||||
private IQChildElementXmlStringBuilder(String element, String namespace) {
|
||||
super("");
|
||||
prelude(element, namespace);
|
||||
this.element = element;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class Mechanisms implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.rightAngleBracket();
|
||||
for (String mechanism : mechanisms) {
|
||||
|
|
|
@ -479,10 +479,10 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
XmlStringBuilder buf = new XmlStringBuilder(enclosingNamespace);
|
||||
public XmlStringBuilder toXML(XmlEnvironment enclosingXmlEnvironment) {
|
||||
XmlStringBuilder buf = new XmlStringBuilder(enclosingXmlEnvironment);
|
||||
buf.halfOpenElement(ELEMENT);
|
||||
enclosingNamespace = addCommonAttributes(buf, enclosingNamespace);
|
||||
enclosingXmlEnvironment = addCommonAttributes(buf, enclosingXmlEnvironment);
|
||||
buf.optAttribute("type", type);
|
||||
buf.rightAngleBracket();
|
||||
|
||||
|
@ -496,16 +496,16 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
|||
// Skip the default language
|
||||
if (subject.equals(defaultSubject))
|
||||
continue;
|
||||
buf.append(subject.toXML(null));
|
||||
buf.append(subject.toXML());
|
||||
}
|
||||
buf.optElement("thread", thread);
|
||||
// Append the error subpacket if the message type is an error.
|
||||
if (type == Type.error) {
|
||||
appendErrorIfExists(buf, enclosingNamespace);
|
||||
appendErrorIfExists(buf, enclosingXmlEnvironment);
|
||||
}
|
||||
|
||||
// Add extension elements, if any are defined.
|
||||
buf.append(getExtensions(), enclosingNamespace);
|
||||
buf.append(getExtensions(), enclosingXmlEnvironment);
|
||||
|
||||
buf.closeElement(ELEMENT);
|
||||
return buf;
|
||||
|
@ -600,7 +600,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.halfOpenElement(getElementName()).optXmlLangAttribute(getLanguage()).rightAngleBracket();
|
||||
xml.escape(subject);
|
||||
|
@ -708,8 +708,8 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
public XmlStringBuilder toXML(XmlEnvironment enclosingXmlEnvironment) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingXmlEnvironment);
|
||||
xml.optXmlLangAttribute(getLanguage()).rightAngleBracket();
|
||||
xml.escape(message);
|
||||
xml.closeElement(getElementName());
|
||||
|
|
|
@ -272,7 +272,7 @@ public final class Presence extends Stanza implements TypedCloneable<Presence> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder buf = new XmlStringBuilder(enclosingNamespace);
|
||||
buf.halfOpenElement(ELEMENT);
|
||||
addCommonAttributes(buf, enclosingNamespace);
|
||||
|
|
|
@ -67,7 +67,7 @@ public class Session extends SimpleIQ {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
if (optional) {
|
||||
xml.rightAngleBracket();
|
||||
|
|
|
@ -132,7 +132,7 @@ public final class StandardExtensionElement implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
if (xmlCache != null) {
|
||||
return xmlCache;
|
||||
}
|
||||
|
|
|
@ -503,25 +503,30 @@ public abstract class Stanza implements TopLevelStreamElement {
|
|||
* Add to, from, id and 'xml:lang' attributes
|
||||
*
|
||||
* @param xml the {@link XmlStringBuilder}.
|
||||
* @param enclosingNamespace the enclosing XML namespace.
|
||||
* @return the set namespace for this stanza.
|
||||
* @param enclosingXmlEnvironment the enclosing XML namespace.
|
||||
* @return the XML environment for this stanza.
|
||||
*/
|
||||
protected String addCommonAttributes(XmlStringBuilder xml, String enclosingNamespace) {
|
||||
String namespace;
|
||||
if (enclosingNamespace == null || !enclosingNamespace.equals(StreamOpen.CLIENT_NAMESPACE)
|
||||
|| !enclosingNamespace.equals(StreamOpen.SERVER_NAMESPACE)) {
|
||||
namespace = StreamOpen.CLIENT_NAMESPACE;
|
||||
} else {
|
||||
namespace = enclosingNamespace;
|
||||
protected XmlEnvironment addCommonAttributes(XmlStringBuilder xml, XmlEnvironment enclosingXmlEnvironment) {
|
||||
String language = getLanguage();
|
||||
String namespace = StreamOpen.CLIENT_NAMESPACE;
|
||||
if (enclosingXmlEnvironment != null) {
|
||||
String effectiveEnclosingNamespace = enclosingXmlEnvironment.getEffectiveNamespaceOrUse(namespace);
|
||||
switch (effectiveEnclosingNamespace) {
|
||||
case StreamOpen.CLIENT_NAMESPACE:
|
||||
case StreamOpen.SERVER_NAMESPACE:
|
||||
break;
|
||||
default:
|
||||
namespace = effectiveEnclosingNamespace;
|
||||
}
|
||||
}
|
||||
|
||||
xml.xmlnsAttribute(namespace);
|
||||
xml.optAttribute("to", getTo());
|
||||
xml.optAttribute("from", getFrom());
|
||||
xml.optAttribute("id", getStanzaId());
|
||||
xml.xmllangAttribute(getLanguage());
|
||||
xml.xmllangAttribute(language);
|
||||
|
||||
return namespace;
|
||||
return new XmlEnvironment(namespace, language);
|
||||
}
|
||||
|
||||
protected void logCommonAttributes(StringBuilder sb) {
|
||||
|
@ -541,10 +546,10 @@ public abstract class Stanza implements TopLevelStreamElement {
|
|||
*
|
||||
* @param xml the XmlStringBuilder to append the error to.
|
||||
*/
|
||||
protected void appendErrorIfExists(XmlStringBuilder xml, String enclosingNamespace) {
|
||||
protected void appendErrorIfExists(XmlStringBuilder xml, XmlEnvironment enclosingXmlEnvironment) {
|
||||
StanzaError error = getError();
|
||||
if (error != null) {
|
||||
xml.append(error.toXML(enclosingNamespace));
|
||||
xml.append(error.toXML(enclosingXmlEnvironment));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software, 2015-2018 Florian Schmaus
|
||||
* Copyright 2003-2007 Jive Software, 2015-2019 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -214,17 +214,8 @@ public class StanzaError extends AbstractError implements ExtensionElement {
|
|||
return StreamOpen.CLIENT_NAMESPACE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the error as XML.
|
||||
*
|
||||
* @return the error as XML.
|
||||
*/
|
||||
public XmlStringBuilder toXML() {
|
||||
return toXML(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
xml.attribute("type", type.toString());
|
||||
xml.optAttribute("by", errorGenerator);
|
||||
|
|
|
@ -50,7 +50,7 @@ public class StartTls implements Nonza {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this, enclosingNamespace);
|
||||
xml.rightAngleBracket();
|
||||
xml.condEmptyElement(required, "required");
|
||||
|
|
|
@ -24,7 +24,7 @@ public final class StreamClose implements Nonza {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toXML(String enclosingNamespace) {
|
||||
public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
return "</" + getElementName() + '>';
|
||||
}
|
||||
|
||||
|
|
|
@ -136,11 +136,11 @@ public class StreamError extends AbstractError implements Nonza {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toXML(null).toString();
|
||||
return toXML().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.openElement(ELEMENT);
|
||||
xml.halfOpenElement(condition.toString()).xmlnsAttribute(NAMESPACE).closeEmptyElement();
|
||||
|
|
|
@ -96,14 +96,16 @@ public class StreamOpen implements Nonza {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(XmlEnvironment enclosingXmlEnvironment) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.halfOpenElement(getElementName());
|
||||
|
||||
String namespace = CLIENT_NAMESPACE;
|
||||
// We always want to state 'xmlns' for stream open tags.
|
||||
if (enclosingNamespace == null) {
|
||||
enclosingNamespace = CLIENT_NAMESPACE;
|
||||
if (enclosingXmlEnvironment != null) {
|
||||
namespace = enclosingXmlEnvironment.getEffectiveNamespaceOrUse(CLIENT_NAMESPACE);
|
||||
}
|
||||
xml.attribute("xmlns", enclosingNamespace);
|
||||
xml.attribute("xmlns", namespace);
|
||||
|
||||
xml.attribute("to", to);
|
||||
xml.attribute("xmlns:stream", "http://etherx.jabber.org/streams");
|
||||
|
|
|
@ -37,7 +37,7 @@ public final class TlsFailure implements Nonza {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toXML(String enclosingNamespace) {
|
||||
public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
return '<' + ELEMENT + " xmlns='" + NAMESPACE + "'/>";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public final class TlsProceed implements Nonza {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toXML(String enclosingNamespace) {
|
||||
public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
return '<' + ELEMENT + " xmlns='" + NAMESPACE + "'/>";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,134 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2019 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jivesoftware.smack.packet;
|
||||
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
public class XmlEnvironment {
|
||||
|
||||
public static final XmlEnvironment EMPTY = new XmlEnvironment((String) null);
|
||||
|
||||
private final String namespace;
|
||||
private final String language;
|
||||
private final XmlEnvironment next;
|
||||
|
||||
private transient boolean effectiveNamespaceDetermined;
|
||||
private transient boolean effectiveLanguageDetermined;
|
||||
private transient String effectiveNamespace;
|
||||
private transient String effectiveLanguage;
|
||||
|
||||
public XmlEnvironment(String namespace) {
|
||||
this(namespace, null);
|
||||
}
|
||||
|
||||
public XmlEnvironment(String namespace, String language) {
|
||||
this(namespace, language, null);
|
||||
}
|
||||
|
||||
private XmlEnvironment(Builder builder) {
|
||||
this(builder.namespace, builder.language, builder.next);
|
||||
}
|
||||
|
||||
private XmlEnvironment(String namespace, String language, XmlEnvironment next) {
|
||||
this.namespace = namespace;
|
||||
this.language = language;
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
public String getNamespace() {
|
||||
return namespace;
|
||||
}
|
||||
|
||||
public String getEffectiveNamespace() {
|
||||
if (effectiveNamespaceDetermined) {
|
||||
return effectiveNamespace;
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(namespace)) {
|
||||
effectiveNamespace = namespace;
|
||||
} else if (next != null) {
|
||||
effectiveNamespace = next.getEffectiveNamespace();
|
||||
}
|
||||
|
||||
effectiveNamespaceDetermined = true;
|
||||
return effectiveNamespace;
|
||||
}
|
||||
|
||||
public String getEffectiveNamespaceOrUse(String namespace) {
|
||||
String effectiveNamespace = getEffectiveLanguage();
|
||||
if (StringUtils.isNullOrEmpty(effectiveNamespace)) {
|
||||
return namespace;
|
||||
}
|
||||
return effectiveNamespace;
|
||||
}
|
||||
|
||||
public boolean effectiveNamespaceEquals(String namespace) {
|
||||
String effectiveNamespace = getEffectiveNamespace();
|
||||
if (effectiveNamespace == null) {
|
||||
return false;
|
||||
}
|
||||
return effectiveNamespace.equals(namespace);
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public String getEffectiveLanguage() {
|
||||
if (effectiveLanguageDetermined) {
|
||||
return effectiveLanguage;
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(language)) {
|
||||
effectiveLanguage = language;
|
||||
} else if (next != null) {
|
||||
effectiveLanguage = next.getEffectiveLanguage();
|
||||
}
|
||||
|
||||
effectiveLanguageDetermined = true;
|
||||
return effectiveLanguage;
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String namespace;
|
||||
private String language;
|
||||
private XmlEnvironment next;
|
||||
|
||||
public Builder withNamespace(String namespace) {
|
||||
this.namespace = namespace;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder withLanguage(String language) {
|
||||
this.language = language;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder withNext(XmlEnvironment next) {
|
||||
this.next = next;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XmlEnvironment build() {
|
||||
return new XmlEnvironment(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -44,7 +44,7 @@ public class SaslStreamElements {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.halfOpenElement(ELEMENT).xmlnsAttribute(NAMESPACE).attribute("mechanism", mechanism).rightAngleBracket();
|
||||
xml.optAppend(authenticationText);
|
||||
|
@ -84,7 +84,7 @@ public class SaslStreamElements {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder().halfOpenElement(ELEMENT).xmlnsAttribute(
|
||||
NAMESPACE).rightAngleBracket();
|
||||
xml.optAppend(data);
|
||||
|
@ -120,7 +120,7 @@ public class SaslStreamElements {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.halfOpenElement(ELEMENT).xmlnsAttribute(NAMESPACE).rightAngleBracket();
|
||||
xml.optAppend(authenticationText);
|
||||
|
@ -171,7 +171,7 @@ public class SaslStreamElements {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.halfOpenElement(ELEMENT).xmlnsAttribute(NAMESPACE).rightAngleBracket();
|
||||
xml.optAppend(data);
|
||||
|
@ -236,7 +236,7 @@ public class SaslStreamElements {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.halfOpenElement(ELEMENT).xmlnsAttribute(NAMESPACE).rightAngleBracket();
|
||||
xml.emptyElement(saslErrorString);
|
||||
|
@ -247,7 +247,7 @@ public class SaslStreamElements {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toXML(null).toString();
|
||||
return toXML().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2014-2018 Florian Schmaus
|
||||
* Copyright 2014-2019 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -26,6 +26,7 @@ import org.jivesoftware.smack.packet.Element;
|
|||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.FullyQualifiedElement;
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
|
||||
import org.jxmpp.util.XmppDateTime;
|
||||
|
||||
|
@ -34,15 +35,15 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
|||
|
||||
private final LazyStringBuilder sb;
|
||||
|
||||
private final String enclosingNamespace;
|
||||
private final XmlEnvironment effectiveXmlEnvironment;
|
||||
|
||||
public XmlStringBuilder() {
|
||||
this("");
|
||||
this((XmlEnvironment) null);
|
||||
}
|
||||
|
||||
public XmlStringBuilder(String enclosingNamespace) {
|
||||
public XmlStringBuilder(XmlEnvironment effectiveXmlEnvironment) {
|
||||
sb = new LazyStringBuilder();
|
||||
this.enclosingNamespace = enclosingNamespace != null ? enclosingNamespace : "";
|
||||
this.effectiveXmlEnvironment = effectiveXmlEnvironment;
|
||||
}
|
||||
|
||||
public XmlStringBuilder(ExtensionElement pe) {
|
||||
|
@ -55,8 +56,8 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
|||
halfOpenElement(e.getElementName());
|
||||
}
|
||||
|
||||
public XmlStringBuilder(FullyQualifiedElement ee, String enclosingNamespace) {
|
||||
this(enclosingNamespace);
|
||||
public XmlStringBuilder(FullyQualifiedElement ee, XmlEnvironment enclosingXmlEnvironment) {
|
||||
this(enclosingXmlEnvironment);
|
||||
prelude(ee);
|
||||
}
|
||||
|
||||
|
@ -117,7 +118,7 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
|||
|
||||
public XmlStringBuilder element(Element element) {
|
||||
assert element != null;
|
||||
return append(element.toXML(null));
|
||||
return append(element.toXML());
|
||||
}
|
||||
|
||||
public XmlStringBuilder optElement(String name, String content) {
|
||||
|
@ -152,7 +153,7 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
|||
|
||||
public XmlStringBuilder optElement(Element element) {
|
||||
if (element != null) {
|
||||
append(element.toXML(null));
|
||||
append(element.toXML());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -399,10 +400,12 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
|||
}
|
||||
|
||||
public XmlStringBuilder xmlnsAttribute(String value) {
|
||||
if (value != null && !enclosingNamespace.equals(value)) {
|
||||
if (value == null || (effectiveXmlEnvironment != null
|
||||
&& effectiveXmlEnvironment.effectiveNamespaceEquals(value))) {
|
||||
return this;
|
||||
}
|
||||
XmlNsAttribute xmlNsAttribute = new XmlNsAttribute(value);
|
||||
append(xmlNsAttribute);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -460,7 +463,7 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
|||
|
||||
public XmlStringBuilder optAppend(Element element) {
|
||||
if (element != null) {
|
||||
append(element.toXML(enclosingNamespace));
|
||||
append(element.toXML(effectiveXmlEnvironment));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -475,9 +478,9 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
|||
return append(elements, null);
|
||||
}
|
||||
|
||||
public XmlStringBuilder append(Collection<? extends Element> elements, String enclosingNamespace) {
|
||||
public XmlStringBuilder append(Collection<? extends Element> elements, XmlEnvironment enclosingXmlEnvironment) {
|
||||
for (Element element : elements) {
|
||||
append(element.toXML(enclosingNamespace));
|
||||
append(element.toXML(enclosingXmlEnvironment));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -592,22 +595,22 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(XmlEnvironment enclosingXmlEnvironment) {
|
||||
StringBuilder res = new StringBuilder();
|
||||
appendXmlTo(res, enclosingNamespace);
|
||||
appendXmlTo(res, enclosingXmlEnvironment);
|
||||
return res;
|
||||
}
|
||||
|
||||
private void appendXmlTo(StringBuilder res, String enclosingNamespace) {
|
||||
private void appendXmlTo(StringBuilder res, XmlEnvironment enclosingXmlEnvironment) {
|
||||
for (CharSequence csq : sb.getAsList()) {
|
||||
if (csq instanceof XmlStringBuilder) {
|
||||
((XmlStringBuilder) csq).appendXmlTo(res, enclosingNamespace);
|
||||
((XmlStringBuilder) csq).appendXmlTo(res, enclosingXmlEnvironment);
|
||||
}
|
||||
else if (csq instanceof XmlNsAttribute) {
|
||||
XmlNsAttribute xmlNsAttribute = (XmlNsAttribute) csq;
|
||||
if (!xmlNsAttribute.value.equals(enclosingNamespace)) {
|
||||
if (!xmlNsAttribute.value.equals(enclosingXmlEnvironment.getEffectiveNamespace())) {
|
||||
sb.append(xmlNsAttribute);
|
||||
enclosingNamespace = xmlNsAttribute.value;
|
||||
enclosingXmlEnvironment = new XmlEnvironment(xmlNsAttribute.value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -182,13 +182,13 @@ public class StanzaCollectorTest {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toXML(String enclosingNamespace) {
|
||||
public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
return "<packetId>" + getStanzaId() + "</packetId>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toXML(null);
|
||||
return toXML().toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public class FailureTest {
|
|||
@Test
|
||||
public void simpleFailureTest() throws SAXException, IOException {
|
||||
Failure failure = new Failure(Failure.CompressFailureError.processing_failed);
|
||||
CharSequence xml = failure.toXML(null);
|
||||
CharSequence xml = failure.toXML();
|
||||
|
||||
final String expectedXml = "<failure xmlns='http://jabber.org/protocol/compress'><processing-failed/></failure>";
|
||||
|
||||
|
@ -44,7 +44,7 @@ public class FailureTest {
|
|||
.setCondition(Condition.bad_request)
|
||||
.build();
|
||||
Failure failure = new Failure(Failure.CompressFailureError.setup_failed, stanzaError);
|
||||
CharSequence xml = failure.toXML(null);
|
||||
CharSequence xml = failure.toXML();
|
||||
|
||||
final String expectedXml = "<failure xmlns='http://jabber.org/protocol/compress'>"
|
||||
+ "<setup-failed/>"
|
||||
|
|
|
@ -75,7 +75,7 @@ public class IQResponseTest {
|
|||
assertNotNull(result.getStanzaId());
|
||||
assertEquals(request.getStanzaId(), result.getStanzaId());
|
||||
assertEquals(request.getFrom(), result.getTo());
|
||||
assertEquals(error.build().toXML(), result.getError().toXML());
|
||||
assertEquals(error.build().toXML().toString(), result.getError().toXML().toString());
|
||||
// TODO this test was never valid
|
||||
// assertEquals(CHILD_ELEMENT, result.getChildElementXML());
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2019 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jivesoftware.smack.packet;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class XmlEnvironmentTest {
|
||||
|
||||
@Test
|
||||
public void testNamespaceScope() {
|
||||
final String outerNamespace = "outerNamespace";
|
||||
|
||||
XmlEnvironment outer = XmlEnvironment.builder().withNamespace(outerNamespace).build();
|
||||
XmlEnvironment inner = XmlEnvironment.builder().withNext(outer).build();
|
||||
|
||||
assertEquals(outerNamespace, inner.getEffectiveNamespace());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLanguageScope() {
|
||||
final String outerLanguage = "outerLanguage";
|
||||
|
||||
XmlEnvironment outer = XmlEnvironment.builder().withLanguage(outerLanguage).build();
|
||||
XmlEnvironment inner = XmlEnvironment.builder().withNext(outer).build();
|
||||
|
||||
assertEquals(outerLanguage, inner.getEffectiveLanguage());
|
||||
}
|
||||
}
|
|
@ -31,7 +31,7 @@ public class StandardExtensionElementParserTest {
|
|||
builder.addAttribute("attr1", "attr1-value");
|
||||
builder.addElement(StandardExtensionElement.builder("bar", "ns2").addAttribute("attr2", "attr2-value").build());
|
||||
builder.addElement("another-element", "another-element-text");
|
||||
final String elementString = builder.build().toXML(null).toString();
|
||||
final String elementString = builder.build().toXML().toString();
|
||||
|
||||
StandardExtensionElement parsedElement = StandardExtensionElementProvider.INSTANCE.parse(getParserFor(elementString));
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class StandardExtensionElementParserTest {
|
|||
|
||||
assertEquals("another-element-text", parsedElement.getFirstElement("another-element").getText());
|
||||
|
||||
String parsedElementString = parsedElement.toXML(null).toString();
|
||||
String parsedElementString = parsedElement.toXML().toString();
|
||||
assertEquals(elementString, parsedElementString);
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class StandardExtensionElementParserTest {
|
|||
StandardExtensionElement.Builder builder = StandardExtensionElement.builder("foo", "ns1-value");
|
||||
builder.addAttribute("xmlns:ns2", "ns2-value");
|
||||
builder.addAttribute("ns2:bar", "bar-ns2-value");
|
||||
final String elementString = builder.build().toXML(null).toString();
|
||||
final String elementString = builder.build().toXML().toString();
|
||||
|
||||
StandardExtensionElement parsedElement = StandardExtensionElementProvider.INSTANCE.parse(getParserFor(elementString));
|
||||
assertEquals("foo", parsedElement.getElementName());
|
||||
|
|
|
@ -85,7 +85,7 @@ public class PacketParserUtilsTest {
|
|||
assertTrue(message.getBodyLanguages().isEmpty());
|
||||
assertEquals(defaultLanguage, message.getBody(defaultLanguage));
|
||||
assertNull(message.getBody(otherLanguage));
|
||||
assertXMLEqual(control, message.toXML(null).toString());
|
||||
assertXMLEqual(control, message.toXML().toString());
|
||||
|
||||
// message has non-default language, body has no language
|
||||
control = XMLBuilder.create("message")
|
||||
|
@ -105,7 +105,7 @@ public class PacketParserUtilsTest {
|
|||
assertTrue(message.getBodyLanguages().isEmpty());
|
||||
assertEquals(otherLanguage, message.getBody(otherLanguage));
|
||||
assertNull(message.getBody(defaultLanguage));
|
||||
assertXMLEqual(control, message.toXML(null).toString());
|
||||
assertXMLEqual(control, message.toXML().toString());
|
||||
|
||||
// message has no language, body has no language
|
||||
control = XMLBuilder.create("message")
|
||||
|
@ -124,7 +124,7 @@ public class PacketParserUtilsTest {
|
|||
assertTrue(message.getBodyLanguages().isEmpty());
|
||||
assertEquals(defaultLanguage, message.getBody(null));
|
||||
assertNull(message.getBody(otherLanguage));
|
||||
assertXMLEqual(control, message.toXML(null).toString());
|
||||
assertXMLEqual(control, message.toXML().toString());
|
||||
|
||||
// message has no language, body has default language
|
||||
control = XMLBuilder.create("message")
|
||||
|
@ -145,7 +145,7 @@ public class PacketParserUtilsTest {
|
|||
assertEquals(defaultLanguage, message.getBody(defaultLanguage));
|
||||
assertNull(message.getBody(otherLanguage));
|
||||
|
||||
assertXMLEqual(control, message.toXML(null).toString());
|
||||
assertXMLEqual(control, message.toXML().toString());
|
||||
|
||||
// message has no language, body has non-default language
|
||||
control = XMLBuilder.create("message")
|
||||
|
@ -166,7 +166,7 @@ public class PacketParserUtilsTest {
|
|||
assertTrue(message.getBodyLanguages().contains(otherLanguage));
|
||||
assertEquals(otherLanguage, message.getBody(otherLanguage));
|
||||
assertNull(message.getBody(defaultLanguage));
|
||||
assertXMLEqual(control, message.toXML(null).toString());
|
||||
assertXMLEqual(control, message.toXML().toString());
|
||||
|
||||
// message has default language, body has non-default language
|
||||
control = XMLBuilder.create("message")
|
||||
|
@ -188,7 +188,7 @@ public class PacketParserUtilsTest {
|
|||
assertTrue(message.getBodyLanguages().contains(otherLanguage));
|
||||
assertEquals(otherLanguage, message.getBody(otherLanguage));
|
||||
assertNull(message.getBody(defaultLanguage));
|
||||
assertXMLEqual(control, message.toXML(null).toString());
|
||||
assertXMLEqual(control, message.toXML().toString());
|
||||
|
||||
// message has non-default language, body has default language
|
||||
control = XMLBuilder.create("message")
|
||||
|
@ -210,7 +210,7 @@ public class PacketParserUtilsTest {
|
|||
assertTrue(message.getBodyLanguages().contains(defaultLanguage));
|
||||
assertEquals(defaultLanguage, message.getBody(defaultLanguage));
|
||||
assertNull(message.getBody(otherLanguage));
|
||||
assertXMLEqual(control, message.toXML(null).toString());
|
||||
assertXMLEqual(control, message.toXML().toString());
|
||||
|
||||
}
|
||||
|
||||
|
@ -393,7 +393,7 @@ public class PacketParserUtilsTest {
|
|||
assertEquals(2, message.getBodies().size());
|
||||
assertEquals(1, message.getBodyLanguages().size());
|
||||
assertTrue(message.getBodyLanguages().contains(otherLanguage));
|
||||
assertXMLEqual(control, message.toXML(null).toString());
|
||||
assertXMLEqual(control, message.toXML().toString());
|
||||
|
||||
// message has non-default language, first body no language, second body default language
|
||||
control = XMLBuilder.create("message")
|
||||
|
@ -419,7 +419,7 @@ public class PacketParserUtilsTest {
|
|||
assertEquals(2, message.getBodies().size());
|
||||
assertEquals(1, message.getBodyLanguages().size());
|
||||
assertTrue(message.getBodyLanguages().contains(defaultLanguage));
|
||||
assertXMLEqual(control, message.toXML(null).toString());
|
||||
assertXMLEqual(control, message.toXML().toString());
|
||||
}
|
||||
|
||||
// TODO: Re-enable once we throw an exception on duplicate body elements.
|
||||
|
@ -452,7 +452,7 @@ public class PacketParserUtilsTest {
|
|||
assertEquals(defaultLanguage, message.getBody(defaultLanguage));
|
||||
assertEquals(1, message.getBodies().size());
|
||||
assertEquals(0, message.getBodyLanguages().size());
|
||||
assertXMLNotEqual(control, message.toXML(null).toString());
|
||||
assertXMLNotEqual(control, message.toXML().toString());
|
||||
}
|
||||
|
||||
@Ignore
|
||||
|
@ -510,7 +510,7 @@ public class PacketParserUtilsTest {
|
|||
assertEquals(otherLanguage, message.getBody(otherLanguage));
|
||||
assertEquals(2, message.getBodies().size());
|
||||
assertEquals(1, message.getBodyLanguages().size());
|
||||
assertXMLEqual(control, message.toXML(null).toString());
|
||||
assertXMLEqual(control, message.toXML().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -692,7 +692,7 @@ public class PacketParserUtilsTest {
|
|||
|
||||
Message message = PacketParserUtils.parseMessage(TestUtils.getMessageParser(control));
|
||||
|
||||
fail("Should throw exception. Instead got message: " + message.toXML(null).toString());
|
||||
fail("Should throw exception. Instead got message: " + message.toXML().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -763,7 +763,7 @@ public class PacketParserUtilsTest {
|
|||
.asString(outputProperties);
|
||||
|
||||
Stanza message = PacketParserUtils.parseStanza(control);
|
||||
XmlUnitUtils.assertSimilar(control, message.toXML(null));
|
||||
XmlUnitUtils.assertSimilar(control, message.toXML());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -105,14 +105,14 @@ public class SLF4JSmackDebugger extends SmackDebugger {
|
|||
@Override
|
||||
public void onIncomingStreamElement(TopLevelStreamElement streamElement) {
|
||||
if (SLF4JSmackDebugger.printInterpreted.get() && logger.isDebugEnabled()) {
|
||||
logger.debug("IN {}: {}", streamElement.getClass().getName(), streamElement.toXML(null));
|
||||
logger.debug("IN {}: {}", streamElement.getClass().getName(), streamElement.toXML());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOutgoingStreamElement(TopLevelStreamElement streamElement) {
|
||||
if (SLF4JSmackDebugger.printInterpreted.get() && logger.isDebugEnabled()) {
|
||||
logger.debug("OUT {}: {}", streamElement.getClass().getName(), streamElement.toXML(null));
|
||||
logger.debug("OUT {}: {}", streamElement.getClass().getName(), streamElement.toXML());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ import org.jivesoftware.smack.packet.Message;
|
|||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.TopLevelStreamElement;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.util.ObservableReader;
|
||||
import org.jivesoftware.smack.util.ObservableWriter;
|
||||
import org.jivesoftware.smack.util.ReaderListener;
|
||||
|
@ -810,7 +811,7 @@ public class EnhancedDebugger extends SmackDebugger {
|
|||
|
||||
messagesTable.addRow(
|
||||
new Object[] {
|
||||
XmlUtil.prettyFormatXml(packet.toXML(null).toString()),
|
||||
XmlUtil.prettyFormatXml(packet.toXML().toString()),
|
||||
dateFormatter.format(new Date()),
|
||||
packetReceivedIcon,
|
||||
packetTypeIcon,
|
||||
|
@ -881,7 +882,7 @@ public class EnhancedDebugger extends SmackDebugger {
|
|||
|
||||
messagesTable.addRow(
|
||||
new Object[] {
|
||||
XmlUtil.prettyFormatXml(packet.toXML(null).toString()),
|
||||
XmlUtil.prettyFormatXml(packet.toXML().toString()),
|
||||
dateFormatter.format(new Date()),
|
||||
packetSentIcon,
|
||||
packetTypeIcon,
|
||||
|
@ -938,15 +939,14 @@ public class EnhancedDebugger extends SmackDebugger {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toXML(String enclosingNamespace) {
|
||||
public String toXML(XmlEnvironment enclosingNamespace) {
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toXML(null);
|
||||
return toXML((XmlEnvironment) null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -323,8 +323,8 @@ public class LiteDebugger extends SmackDebugger {
|
|||
|
||||
@Override
|
||||
public void onIncomingStreamElement(TopLevelStreamElement streamElement) {
|
||||
interpretedText1.append(streamElement.toXML(null).toString());
|
||||
interpretedText2.append(streamElement.toXML(null).toString());
|
||||
interpretedText1.append(streamElement.toXML().toString());
|
||||
interpretedText2.append(streamElement.toXML().toString());
|
||||
interpretedText1.append(NEWLINE);
|
||||
interpretedText2.append(NEWLINE);
|
||||
}
|
||||
|
|
|
@ -79,10 +79,10 @@ public class CarbonExtension implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.rightAngleBracket();
|
||||
xml.append(fwd.toXML(null));
|
||||
xml.append(fwd.toXML());
|
||||
xml.closeElement(this);
|
||||
return xml;
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ public class CarbonExtension implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toXML(String enclosingNamespace) {
|
||||
public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
return "<" + ELEMENT + " xmlns='" + NAMESPACE + "'/>";
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public class ChatMarkersElements {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.closeEmptyElement();
|
||||
return xml;
|
||||
|
@ -93,7 +93,7 @@ public class ChatMarkersElements {
|
|||
}
|
||||
|
||||
@Override
|
||||
public final XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public final XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("id", id);
|
||||
xml.closeEmptyElement();
|
||||
|
|
|
@ -45,7 +45,7 @@ public class ClientStateIndication {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toXML(String enclosingNamespace) {
|
||||
public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
return '<' + ELEMENT + " xmlns='" + NAMESPACE + "'/>";
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class ClientStateIndication {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toXML(String enclosingNamespace) {
|
||||
public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
return '<' + ELEMENT + " xmlns='" + NAMESPACE + "'/>";
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ public class ClientStateIndication {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toXML(String enclosingNamespace) {
|
||||
public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
return '<' + ELEMENT + " xmlns='" + NAMESPACE + "'/>";
|
||||
}
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ public class ExplicitMessageEncryptionElement implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("namespace", getEncryptionNamespace());
|
||||
xml.optAttribute("name", getName());
|
||||
|
|
|
@ -93,7 +93,7 @@ public class HashElement implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder sb = new XmlStringBuilder(this);
|
||||
sb.attribute(ATTR_ALGO, algorithm.toString());
|
||||
sb.rightAngleBracket();
|
||||
|
@ -120,6 +120,6 @@ public class HashElement implements ExtensionElement {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return toXML(null).toString().hashCode();
|
||||
return toXML().toString().hashCode();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public final class NoCopyHint extends MessageProcessingHint {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toXML(String enclosingNamespace) {
|
||||
public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
return '<' + ELEMENT + " xmlns='" + NAMESPACE + "'/>";
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public final class NoPermanentStoreHint extends MessageProcessingHint {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toXML(String enclosingNamespace) {
|
||||
public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
return '<' + ELEMENT + " xmlns='" + NAMESPACE + "'/>";
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public final class NoStoreHint extends MessageProcessingHint {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toXML(String enclosingNamespace) {
|
||||
public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
return '<' + ELEMENT + " xmlns='" + NAMESPACE + "'/>";
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public final class StoreHint extends MessageProcessingHint {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toXML(String enclosingNamespace) {
|
||||
public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
return '<' + ELEMENT + " xmlns='" + NAMESPACE + "'/>";
|
||||
}
|
||||
|
||||
|
|
|
@ -171,7 +171,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
|||
* @return xml representation of this object
|
||||
*/
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.rightAngleBracket();
|
||||
xml.element(child);
|
||||
|
@ -215,7 +215,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.rightAngleBracket();
|
||||
xml.optAppend(text);
|
||||
|
@ -259,7 +259,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.rightAngleBracket();
|
||||
xml.optAppend(text);
|
||||
|
@ -303,7 +303,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.rightAngleBracket();
|
||||
xml.optAppend(text);
|
||||
|
@ -347,7 +347,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("streamId", streamId);
|
||||
xml.closeEmptyElement();
|
||||
|
@ -390,7 +390,7 @@ public abstract class AbstractHttpOverXmpp extends IQ {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("sid", sid);
|
||||
xml.closeEmptyElement();
|
||||
|
|
|
@ -117,7 +117,7 @@ public class Base64BinaryChunk implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("streamId", streamId);
|
||||
xml.attribute("nr", nr);
|
||||
|
|
|
@ -58,7 +58,7 @@ public class FileTooLargeError implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.rightAngleBracket();
|
||||
xml.element("max-file-size", String.valueOf(maxFileSize));
|
||||
|
|
|
@ -82,7 +82,7 @@ public abstract class SetData implements NamedElement {
|
|||
* @return the stanza extension as XML.
|
||||
*/
|
||||
@Override
|
||||
public final XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public final XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("name", name);
|
||||
xml.attribute("value", value);
|
||||
|
|
|
@ -52,7 +52,7 @@ public abstract class IoTDataField implements NamedElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public final XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public final XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("name", name).attribute("value", getValueString());
|
||||
// TODO handle 'unit' attribute as special case if <numeric/> is implemented.
|
||||
|
|
|
@ -68,7 +68,7 @@ public class IoTFieldsExtension implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("seqnr", Integer.toString(seqNr));
|
||||
xml.attribute("done", done);
|
||||
|
|
|
@ -50,7 +50,7 @@ public class NodeElement implements NamedElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
nodeInfo.appendTo(xml);
|
||||
xml.rightAngleBracket();
|
||||
|
|
|
@ -45,7 +45,7 @@ public class TimestampElement implements NamedElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("value", date);
|
||||
xml.rightAngleBracket();
|
||||
|
|
|
@ -58,7 +58,7 @@ public class Tag implements NamedElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("name", name);
|
||||
xml.attribute("value", value);
|
||||
|
|
|
@ -45,7 +45,7 @@ public class Friend implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("jid", friend);
|
||||
xml.closeEmptyElement();
|
||||
|
|
|
@ -47,7 +47,7 @@ public class Unfriend implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("jid", jid);
|
||||
xml.closeEmptyElement();
|
||||
|
|
|
@ -46,7 +46,7 @@ public class Checksum implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder sb = new XmlStringBuilder(this);
|
||||
sb.optAttribute(ATTR_CREATOR, creator);
|
||||
sb.optAttribute(ATTR_NAME, name);
|
||||
|
|
|
@ -86,7 +86,7 @@ public class JingleFileTransferChild extends JingleContentDescriptionChildElemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder sb = new XmlStringBuilder(this);
|
||||
sb.rightAngleBracket();
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ public class Range implements NamedElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder sb = new XmlStringBuilder(this);
|
||||
|
||||
if (offset > 0) {
|
||||
|
@ -133,6 +133,6 @@ public class Range implements NamedElement {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return toXML(null).toString().hashCode();
|
||||
return toXML().toString().hashCode();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public abstract class AbstractJsonPacketExtension implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public final XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public final XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.rightAngleBracket();
|
||||
xml.append(json);
|
||||
|
|
|
@ -126,7 +126,7 @@ public class MamElements {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.halfOpenElement(this);
|
||||
xml.xmlnsAttribute(NAMESPACE);
|
||||
|
@ -167,7 +167,7 @@ public class MamElements {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.openElement("always");
|
||||
|
||||
|
@ -201,7 +201,7 @@ public class MamElements {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.openElement("never");
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public class BlockQuoteElement implements MarkupElement.BlockLevelMarkupElement
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.halfOpenElement(this);
|
||||
xml.attribute(ATTR_START, getStart());
|
||||
|
|
|
@ -51,7 +51,7 @@ public class CodeBlockElement implements MarkupElement.BlockLevelMarkupElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.halfOpenElement(this);
|
||||
xml.attribute(ATTR_START, getStart());
|
||||
|
|
|
@ -68,7 +68,7 @@ public class ListElement implements MarkupElement.MarkupChildElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.halfOpenElement(this);
|
||||
xml.attribute(ATTR_START, getStart());
|
||||
|
@ -76,7 +76,7 @@ public class ListElement implements MarkupElement.MarkupChildElement {
|
|||
xml.rightAngleBracket();
|
||||
|
||||
for (ListEntryElement li : getEntries()) {
|
||||
xml.append(li.toXML(null));
|
||||
xml.append(li.toXML());
|
||||
}
|
||||
|
||||
xml.closeElement(this);
|
||||
|
@ -110,7 +110,7 @@ public class ListElement implements MarkupElement.MarkupChildElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.halfOpenElement(this);
|
||||
xml.attribute(ATTR_START, getStart());
|
||||
|
|
|
@ -68,11 +68,11 @@ public class MarkupElement implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this).rightAngleBracket();
|
||||
|
||||
for (MarkupChildElement child : getChildElements()) {
|
||||
xml.append(child.toXML(null));
|
||||
xml.append(child.toXML());
|
||||
}
|
||||
|
||||
xml.closeElement(this);
|
||||
|
|
|
@ -76,7 +76,7 @@ public class SpanElement implements MarkupElement.MarkupChildElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.halfOpenElement(this);
|
||||
xml.attribute(ATTR_START, getStart());
|
||||
|
|
|
@ -94,7 +94,7 @@ public abstract class MUCLightElements {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.rightAngleBracket();
|
||||
|
||||
|
@ -208,7 +208,7 @@ public abstract class MUCLightElements {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.rightAngleBracket();
|
||||
|
||||
|
@ -255,7 +255,7 @@ public abstract class MUCLightElements {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.openElement("configuration");
|
||||
|
||||
|
@ -296,7 +296,7 @@ public abstract class MUCLightElements {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.openElement("occupants");
|
||||
|
||||
|
@ -335,7 +335,7 @@ public abstract class MUCLightElements {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
xml.halfOpenElement("user");
|
||||
xml.attribute("affiliation", affiliation);
|
||||
|
@ -373,7 +373,7 @@ public abstract class MUCLightElements {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
|
||||
String tag = isRoom ? "room" : "user";
|
||||
|
|
|
@ -78,7 +78,7 @@ public class PushNotificationsElements {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
|
||||
xml.attribute("node", node);
|
||||
|
|
|
@ -174,7 +174,7 @@ public class ReferenceElement implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this)
|
||||
.optIntAttribute(ATTR_BEGIN, begin != null ? begin : -1)
|
||||
.optIntAttribute(ATTR_END, end != null ? end : -1)
|
||||
|
@ -186,7 +186,7 @@ public class ReferenceElement implements ExtensionElement {
|
|||
return xml.closeEmptyElement();
|
||||
} else {
|
||||
return xml.rightAngleBracket()
|
||||
.append(child.toXML(null))
|
||||
.append(child.toXML())
|
||||
.closeElement(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ public class OriginIdElement extends StableAndUniqueIdElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
return new XmlStringBuilder(this)
|
||||
.attribute(ATTR_ID, getId())
|
||||
.closeEmptyElement();
|
||||
|
|
|
@ -72,7 +72,7 @@ public class StanzaIdElement extends StableAndUniqueIdElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
return new XmlStringBuilder(this)
|
||||
.attribute(ATTR_ID, getId())
|
||||
.attribute(ATTR_BY, getBy())
|
||||
|
|
|
@ -151,7 +151,7 @@ public class SpoilerElement implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.optXmlLangAttribute(getLanguage());
|
||||
if (getHint() == null) {
|
||||
|
|
|
@ -42,18 +42,18 @@ public class MarkableExtensionTest {
|
|||
message.setStanzaId("message-1");
|
||||
message.setBody("My lord, dispatch; read o'er these articles.");
|
||||
message.addExtension(ChatMarkersElements.MarkableExtension.INSTANCE);
|
||||
Assert.assertEquals(markableMessageStanza, message.toXML(null).toString());
|
||||
Assert.assertEquals(markableMessageStanza, message.toXML().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkMarkableProvider() throws Exception {
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(markableExtension);
|
||||
MarkableExtension markableExtension1 = new MarkableProvider().parse(parser);
|
||||
Assert.assertEquals(markableExtension, markableExtension1.toXML(null).toString());
|
||||
Assert.assertEquals(markableExtension, markableExtension1.toXML().toString());
|
||||
|
||||
Message message = PacketParserUtils.parseStanza(markableMessageStanza);
|
||||
MarkableExtension markableExtension2 = MarkableExtension.from(message);
|
||||
Assert.assertEquals(markableExtension, markableExtension2.toXML(null).toString());
|
||||
Assert.assertEquals(markableExtension, markableExtension2.toXML().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,10 +41,10 @@ public class HashElementTest extends SmackTestSuite {
|
|||
String message = "Hello World!";
|
||||
HashElement element = HashManager.calculateHashElement(SHA_256, StringUtils.toUtf8Bytes(message));
|
||||
String expected = "<hash xmlns='urn:xmpp:hashes:2' algo='sha-256'>f4OxZX/x/FO5LcGBSKHWXfwtSx+j1ncoSt3SABJtkGk=</hash>";
|
||||
assertEquals(expected, element.toXML(null).toString());
|
||||
assertEquals(expected, element.toXML().toString());
|
||||
|
||||
HashElement parsed = new HashElementProvider().parse(TestUtils.getParser(expected));
|
||||
assertEquals(expected, parsed.toXML(null).toString());
|
||||
assertEquals(expected, parsed.toXML().toString());
|
||||
assertEquals(SHA_256, parsed.getAlgorithm());
|
||||
assertEquals("f4OxZX/x/FO5LcGBSKHWXfwtSx+j1ncoSt3SABJtkGk=", parsed.getHashB64());
|
||||
assertArrayEquals(HashManager.sha_256(message), parsed.getHash());
|
||||
|
|
|
@ -32,7 +32,7 @@ public class FileTooLargeErrorCreateTest {
|
|||
FileTooLargeError fileTooLargeError = new FileTooLargeError(20000);
|
||||
|
||||
Assert.assertEquals(20000, fileTooLargeError.getMaxFileSize());
|
||||
Assert.assertEquals(fileTooLargeErrorExtensionExample, fileTooLargeError.toXML(null).toString());
|
||||
Assert.assertEquals(fileTooLargeErrorExtensionExample, fileTooLargeError.toXML().toString());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ public class FiltersTest extends MamTest {
|
|||
List<String> values = new ArrayList<>();
|
||||
values.add(XmppDateTime.formatXEP0082Date(date));
|
||||
|
||||
assertEquals(getMamXMemberWith(fields, values), dataForm.toXML(null).toString());
|
||||
assertEquals(getMamXMemberWith(fields, values), dataForm.toXML().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -73,7 +73,7 @@ public class FiltersTest extends MamTest {
|
|||
List<String> values = new ArrayList<>();
|
||||
values.add(XmppDateTime.formatXEP0082Date(date));
|
||||
|
||||
assertEquals(getMamXMemberWith(fields, values), dataForm.toXML(null).toString());
|
||||
assertEquals(getMamXMemberWith(fields, values), dataForm.toXML().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -88,7 +88,7 @@ public class FiltersTest extends MamTest {
|
|||
List<CharSequence> values = new ArrayList<>();
|
||||
values.add(jid);
|
||||
|
||||
assertEquals(getMamXMemberWith(fields, values), dataForm.toXML(null).toString());
|
||||
assertEquals(getMamXMemberWith(fields, values), dataForm.toXML().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class RetrieveFormFieldsTest extends MamTest {
|
|||
.build();
|
||||
DataForm dataForm = mamQueryArgs.getDataForm();
|
||||
|
||||
String dataFormResult = dataForm.toXML(null).toString();
|
||||
String dataFormResult = dataForm.toXML().toString();
|
||||
|
||||
assertXmlSimilar(additionalFieldsStanza, dataFormResult);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public class MessageMarkupTest extends SmackTestSuite {
|
|||
"</markup>";
|
||||
MarkupElement.Builder m = MarkupElement.getBuilder();
|
||||
m.setEmphasis(9, 15);
|
||||
assertXMLEqual(xml, m.build().toXML(null).toString());
|
||||
assertXMLEqual(xml, m.build().toXML().toString());
|
||||
|
||||
XmlPullParser parser = TestUtils.getParser(xml);
|
||||
MarkupElement parsed = new MarkupElementProvider().parse(parser);
|
||||
|
@ -69,7 +69,7 @@ public class MessageMarkupTest extends SmackTestSuite {
|
|||
"</markup>";
|
||||
MarkupElement.Builder m = MarkupElement.getBuilder();
|
||||
m.setCode(9, 15);
|
||||
assertXMLEqual(xml, m.build().toXML(null).toString());
|
||||
assertXMLEqual(xml, m.build().toXML().toString());
|
||||
|
||||
XmlPullParser parser = TestUtils.getParser(xml);
|
||||
MarkupElement parsed = new MarkupElementProvider().parse(parser);
|
||||
|
@ -93,7 +93,7 @@ public class MessageMarkupTest extends SmackTestSuite {
|
|||
"</markup>";
|
||||
MarkupElement.Builder m = MarkupElement.getBuilder();
|
||||
m.setDeleted(9, 15);
|
||||
assertXMLEqual(xml, m.build().toXML(null).toString());
|
||||
assertXMLEqual(xml, m.build().toXML().toString());
|
||||
|
||||
XmlPullParser parser = TestUtils.getParser(xml);
|
||||
MarkupElement parsed = new MarkupElementProvider().parse(parser);
|
||||
|
@ -127,7 +127,7 @@ public class MessageMarkupTest extends SmackTestSuite {
|
|||
"</markup>";
|
||||
MarkupElement.Builder m = MarkupElement.getBuilder();
|
||||
m.setCodeBlock(23, 48);
|
||||
assertXMLEqual(xml, m.build().toXML(null).toString());
|
||||
assertXMLEqual(xml, m.build().toXML().toString());
|
||||
|
||||
XmlPullParser parser = TestUtils.getParser(xml);
|
||||
MarkupElement parsed = new MarkupElementProvider().parse(parser);
|
||||
|
@ -157,7 +157,7 @@ public class MessageMarkupTest extends SmackTestSuite {
|
|||
.addEntry(61, 69)
|
||||
.addEntry(69, 89)
|
||||
.endList();
|
||||
assertXMLEqual(xml, m.build().toXML(null).toString());
|
||||
assertXMLEqual(xml, m.build().toXML().toString());
|
||||
|
||||
XmlPullParser parser = TestUtils.getParser(xml);
|
||||
MarkupElement parsed = new MarkupElementProvider().parse(parser);
|
||||
|
@ -186,7 +186,7 @@ public class MessageMarkupTest extends SmackTestSuite {
|
|||
"</markup>";
|
||||
MarkupElement.Builder m = MarkupElement.getBuilder();
|
||||
m.setBlockQuote(9 ,32);
|
||||
assertXMLEqual(xml, m.build().toXML(null).toString());
|
||||
assertXMLEqual(xml, m.build().toXML().toString());
|
||||
|
||||
XmlPullParser parser = TestUtils.getParser(xml);
|
||||
MarkupElement parsed = new MarkupElementProvider().parse(parser);
|
||||
|
@ -208,7 +208,7 @@ public class MessageMarkupTest extends SmackTestSuite {
|
|||
MarkupElement.Builder m = MarkupElement.getBuilder();
|
||||
m.setBlockQuote(0, 57);
|
||||
m.setBlockQuote(11, 34);
|
||||
assertXMLEqual(xml, m.build().toXML(null).toString());
|
||||
assertXMLEqual(xml, m.build().toXML().toString());
|
||||
|
||||
XmlPullParser parser = TestUtils.getParser(xml);
|
||||
MarkupElement parsed = new MarkupElementProvider().parse(parser);
|
||||
|
|
|
@ -51,7 +51,7 @@ public class MUCLightConfigurationsChangeExtensionTest {
|
|||
Assert.assertEquals("To be or not to be?", configurationsChangeExtension.getSubject());
|
||||
Assert.assertNull(configurationsChangeExtension.getRoomName());
|
||||
Assert.assertNull(configurationsChangeExtension.getCustomConfigs());
|
||||
Assert.assertEquals(messageWithSubjectChangeExample, configurationsMessage.toXML(null).toString());
|
||||
Assert.assertEquals(messageWithSubjectChangeExample, configurationsMessage.toXML().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -65,7 +65,7 @@ public class MUCLightConfigurationsChangeExtensionTest {
|
|||
Assert.assertEquals("A Darker Cave", configurationsChangeExtension.getRoomName());
|
||||
Assert.assertNull(configurationsChangeExtension.getSubject());
|
||||
Assert.assertNull(configurationsChangeExtension.getCustomConfigs());
|
||||
Assert.assertEquals(messageWithRoomNameChangeExample, configurationsMessage.toXML(null).toString());
|
||||
Assert.assertEquals(messageWithRoomNameChangeExample, configurationsMessage.toXML().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -79,7 +79,7 @@ public class MUCLightConfigurationsChangeExtensionTest {
|
|||
Assert.assertEquals("A Darker Cave", configurationsChangeExtension.getRoomName());
|
||||
Assert.assertNull(configurationsChangeExtension.getSubject());
|
||||
Assert.assertEquals("blue", configurationsChangeExtension.getCustomConfigs().get("color"));
|
||||
Assert.assertEquals(messageWithConfigsChangeExample, configurationsMessage.toXML(null).toString());
|
||||
Assert.assertEquals(messageWithConfigsChangeExample, configurationsMessage.toXML().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class ReferenceTest extends SmackTestSuite {
|
|||
"uri='xmpp:juliet@capulet.lit' />";
|
||||
URI uri = new URI("xmpp:juliet@capulet.lit");
|
||||
ReferenceElement element = new ReferenceElement(72, 78, ReferenceElement.Type.mention, null, uri);
|
||||
assertXMLEqual(xml, element.toXML(null).toString());
|
||||
assertXMLEqual(xml, element.toXML().toString());
|
||||
assertEquals(72, (int) element.getBegin());
|
||||
assertEquals(78, (int) element.getEnd());
|
||||
assertEquals(ReferenceElement.Type.mention, element.getType());
|
||||
|
@ -49,7 +49,7 @@ public class ReferenceTest extends SmackTestSuite {
|
|||
assertEquals(uri, element.getUri());
|
||||
|
||||
ReferenceElement parsed = ReferenceProvider.TEST_PROVIDER.parse(TestUtils.getParser(xml));
|
||||
assertXMLEqual(xml, parsed.toXML(null).toString());
|
||||
assertXMLEqual(xml, parsed.toXML().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -64,7 +64,7 @@ public class ReferenceTest extends SmackTestSuite {
|
|||
"uri='xmpp:fdp.shakespeare.lit?;node=fdp/submitted/stan.isode.net/accidentreport;item=ndina872be' />";
|
||||
URI uri = new URI("xmpp:fdp.shakespeare.lit?;node=fdp/submitted/stan.isode.net/accidentreport;item=ndina872be");
|
||||
ReferenceElement element = new ReferenceElement(null, null, ReferenceElement.Type.data, null, uri);
|
||||
assertXMLEqual(xml, element.toXML(null).toString());
|
||||
assertXMLEqual(xml, element.toXML().toString());
|
||||
|
||||
assertNull(element.getBegin());
|
||||
assertNull(element.getEnd());
|
||||
|
@ -73,7 +73,7 @@ public class ReferenceTest extends SmackTestSuite {
|
|||
assertEquals(uri, element.getUri());
|
||||
|
||||
ReferenceElement parsed = ReferenceProvider.TEST_PROVIDER.parse(TestUtils.getParser(xml));
|
||||
assertXMLEqual(xml, parsed.toXML(null).toString());
|
||||
assertXMLEqual(xml, parsed.toXML().toString());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
|
|
|
@ -40,7 +40,7 @@ public class StableUniqueStanzaIdTest extends SmackTestSuite {
|
|||
StanzaIdElement element = new StanzaIdElement("de305d54-75b4-431b-adb2-eb6b9e546013", "alice@wonderland.lit");
|
||||
assertEquals("de305d54-75b4-431b-adb2-eb6b9e546013", element.getId());
|
||||
assertEquals("alice@wonderland.lit", element.getBy());
|
||||
assertXMLEqual(xml, element.toXML(null).toString());
|
||||
assertXMLEqual(xml, element.toXML().toString());
|
||||
|
||||
StanzaIdElement parsed = StanzaIdProvider.TEST_INSTANCE.parse(TestUtils.getParser(xml));
|
||||
assertEquals(element.getId(), parsed.getId());
|
||||
|
@ -52,7 +52,7 @@ public class StableUniqueStanzaIdTest extends SmackTestSuite {
|
|||
String xml = "<origin-id xmlns='urn:xmpp:sid:0' id='de305d54-75b4-431b-adb2-eb6b9e546013' />";
|
||||
OriginIdElement element = new OriginIdElement("de305d54-75b4-431b-adb2-eb6b9e546013");
|
||||
assertEquals("de305d54-75b4-431b-adb2-eb6b9e546013", element.getId());
|
||||
assertXMLEqual(xml, element.toXML(null).toString());
|
||||
assertXMLEqual(xml, element.toXML().toString());
|
||||
|
||||
OriginIdElement parsed = OriginIdProvider.TEST_INSTANCE.parse(TestUtils.getParser(xml));
|
||||
assertEquals(element.getId(), parsed.getId());
|
||||
|
|
|
@ -46,11 +46,11 @@ public class SpoilerTest extends SmackTestSuite {
|
|||
assertNull(empty.getHint());
|
||||
assertNull(empty.getLanguage());
|
||||
|
||||
assertXMLEqual(xml, empty.toXML(null).toString());
|
||||
assertXMLEqual(xml, empty.toXML().toString());
|
||||
|
||||
XmlPullParser parser = TestUtils.getParser(xml);
|
||||
SpoilerElement parsed = SpoilerProvider.INSTANCE.parse(parser);
|
||||
assertXMLEqual(xml, parsed.toXML(null).toString());
|
||||
assertXMLEqual(xml, parsed.toXML().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -65,12 +65,12 @@ public class SpoilerTest extends SmackTestSuite {
|
|||
assertEquals("Love story end", withHint.getHint());
|
||||
assertNull(withHint.getLanguage());
|
||||
|
||||
assertXMLEqual(xml, withHint.toXML(null).toString());
|
||||
assertXMLEqual(xml, withHint.toXML().toString());
|
||||
|
||||
XmlPullParser parser = TestUtils.getParser(xml);
|
||||
SpoilerElement parsed = SpoilerProvider.INSTANCE.parse(parser);
|
||||
|
||||
assertXMLEqual(xml, parsed.toXML(null).toString());
|
||||
assertXMLEqual(xml, parsed.toXML().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -85,13 +85,13 @@ public class SpoilerTest extends SmackTestSuite {
|
|||
assertEquals("Der Kuchen ist eine Lüge!", i18nHint.getHint());
|
||||
assertEquals("de", i18nHint.getLanguage());
|
||||
|
||||
assertXMLEqual(xml, i18nHint.toXML(null).toString());
|
||||
assertXMLEqual(xml, i18nHint.toXML().toString());
|
||||
|
||||
XmlPullParser parser = TestUtils.getParser(xml);
|
||||
SpoilerElement parsed = SpoilerProvider.INSTANCE.parse(parser);
|
||||
assertEquals(i18nHint.getLanguage(), parsed.getLanguage());
|
||||
|
||||
assertXMLEqual(xml, parsed.toXML(null).toString());
|
||||
assertXMLEqual(xml, parsed.toXML().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -211,19 +211,19 @@ public class MultipleRecipientManager {
|
|||
if (to != null) {
|
||||
for (Jid jid : to) {
|
||||
packet.setTo(jid);
|
||||
connection.sendStanza(new PacketCopy(packet.toXML(null)));
|
||||
connection.sendStanza(new PacketCopy(packet.toXML()));
|
||||
}
|
||||
}
|
||||
if (cc != null) {
|
||||
for (Jid jid : cc) {
|
||||
packet.setTo(jid);
|
||||
connection.sendStanza(new PacketCopy(packet.toXML(null)));
|
||||
connection.sendStanza(new PacketCopy(packet.toXML()));
|
||||
}
|
||||
}
|
||||
if (bcc != null) {
|
||||
for (Jid jid : bcc) {
|
||||
packet.setTo(jid);
|
||||
connection.sendStanza(new PacketCopy(packet.toXML(null)));
|
||||
connection.sendStanza(new PacketCopy(packet.toXML()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -309,13 +309,13 @@ public class MultipleRecipientManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toXML(null).toString();
|
||||
return toXML().toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -118,12 +118,12 @@ public class MultipleAddresses implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder buf = new XmlStringBuilder(this);
|
||||
buf.rightAngleBracket();
|
||||
// Loop through all the addresses and append them to the string buffer
|
||||
for (Address address : addresses) {
|
||||
buf.append(address.toXML(null));
|
||||
buf.append(address.toXML());
|
||||
}
|
||||
buf.closeElement(this);
|
||||
return buf;
|
||||
|
@ -194,7 +194,7 @@ public class MultipleAddresses implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder buf = new XmlStringBuilder();
|
||||
buf.halfOpenElement(this).attribute("type", type);
|
||||
buf.optAttribute("jid", jid);
|
||||
|
|
|
@ -154,7 +154,7 @@ public class AMPExtension implements ExtensionElement {
|
|||
* Returns the XML representation of a XHTML extension according the specification.
|
||||
**/
|
||||
@Override
|
||||
public String toXML(String enclosingNamespace) {
|
||||
public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append('<').append(getElementName()).append(" xmlns=\"").append(getNamespace()).append('"');
|
||||
if (status != null) {
|
||||
|
|
|
@ -69,7 +69,7 @@ public class AttentionExtension implements ExtensionElement {
|
|||
* @see org.jivesoftware.smack.packet.PacketExtension#toXML()
|
||||
*/
|
||||
@Override
|
||||
public String toXML(String enclosingNamespace) {
|
||||
public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append('<').append(getElementName()).append(" xmlns=\"").append(
|
||||
getNamespace()).append("\"/>");
|
||||
|
|
|
@ -46,7 +46,7 @@ public class BlockedErrorExtension implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.closeEmptyElement();
|
||||
return xml;
|
||||
|
|
|
@ -68,7 +68,7 @@ public class BoBExtension extends XHTMLExtension {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.rightAngleBracket();
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ public class DataPacketExtension implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = getIQChildElementBuilder(new IQChildElementXmlStringBuilder(this));
|
||||
xml.closeElement(this);
|
||||
return xml;
|
||||
|
|
|
@ -232,11 +232,11 @@ public class Bytestream extends IQ {
|
|||
xml.rightAngleBracket();
|
||||
if (getToActivate() == null) {
|
||||
for (StreamHost streamHost : getStreamHosts()) {
|
||||
xml.append(streamHost.toXML(null));
|
||||
xml.append(streamHost.toXML());
|
||||
}
|
||||
}
|
||||
else {
|
||||
xml.append(getToActivate().toXML(null));
|
||||
xml.append(getToActivate().toXML());
|
||||
}
|
||||
break;
|
||||
case result:
|
||||
|
@ -246,7 +246,7 @@ public class Bytestream extends IQ {
|
|||
// constructions mechanisms of Bytestream
|
||||
// A result from the server can also contain stream hosts
|
||||
for (StreamHost host : streamHosts) {
|
||||
xml.append(host.toXML(null));
|
||||
xml.append(host.toXML());
|
||||
}
|
||||
break;
|
||||
case get:
|
||||
|
@ -325,7 +325,7 @@ public class Bytestream extends IQ {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("jid", getJID());
|
||||
xml.attribute("host", getAddress());
|
||||
|
@ -375,7 +375,7 @@ public class Bytestream extends IQ {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("jid", getJID());
|
||||
xml.closeEmptyElement();
|
||||
|
@ -418,7 +418,7 @@ public class Bytestream extends IQ {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.rightAngleBracket();
|
||||
xml.escape(getTarget());
|
||||
|
|
|
@ -131,7 +131,7 @@ public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache
|
|||
*/
|
||||
private static void writeInfoToFile(File file, DiscoverInfo info) throws IOException {
|
||||
try (DataOutputStream dos = new DataOutputStream(new FileOutputStream(file))) {
|
||||
dos.writeUTF(info.toXML(null).toString());
|
||||
dos.writeUTF(info.toXML().toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ public class CapsExtension implements ExtensionElement {
|
|||
*
|
||||
*/
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("hash", hash).attribute("node", node).attribute("ver", ver);
|
||||
xml.closeEmptyElement();
|
||||
|
|
|
@ -59,7 +59,7 @@ public class ChatStateExtension implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.closeEmptyElement();
|
||||
return xml;
|
||||
|
|
|
@ -95,7 +95,7 @@ public class AdHocCommandData extends IQ {
|
|||
}
|
||||
|
||||
if (form != null) {
|
||||
xml.append(form.toXML(null));
|
||||
xml.append(form.toXML());
|
||||
}
|
||||
|
||||
for (AdHocCommandNote note : notes) {
|
||||
|
@ -264,7 +264,7 @@ public class AdHocCommandData extends IQ {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toXML(String enclosingNamespace) {
|
||||
public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append('<').append(getElementName());
|
||||
buf.append(" xmlns=\"").append(getNamespace()).append("\"/>");
|
||||
|
|
|
@ -102,7 +102,7 @@ public class DelayInformation implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute("stamp", XmppDateTime.formatXEP0082Date(stamp));
|
||||
xml.optAttribute("from", from);
|
||||
|
|
|
@ -71,7 +71,7 @@ public class Forwarded implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.rightAngleBracket();
|
||||
xml.optElement(getDelayInformation());
|
||||
|
|
|
@ -214,7 +214,7 @@ public final class GeoLocation implements Serializable, ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.rightAngleBracket();
|
||||
xml.optElement("accuracy", accuracy);
|
||||
|
|
|
@ -115,7 +115,7 @@ public class Registration extends IQ {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML(String enclosingNamespace) {
|
||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
return '<' + ELEMENT + " xmlns='" + NAMESPACE + "'/>";
|
||||
}
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ public final class JingleContent implements NamedElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.attribute(CREATOR_ATTRIBUTE_NAME, creator);
|
||||
xml.optAttribute(DISPOSITION_ATTRIBUTE_NAME, disposition);
|
||||
|
|
|
@ -56,7 +56,7 @@ public abstract class JingleContentDescription implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
addExtraAttributes(xml);
|
||||
xml.rightAngleBracket();
|
||||
|
|
|
@ -66,7 +66,7 @@ public abstract class JingleContentTransport implements ExtensionElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML(String enclosingNamespace) {
|
||||
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
addExtraAttributes(xml);
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue