1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 22:32:06 +01:00

Remove XmlLangStanza

since all stanza types could have 'xml:lang' defined as top-level
stream element attribute.
This commit is contained in:
Florian Schmaus 2014-09-12 11:20:34 +02:00
parent 3a37b71e19
commit c024931de8
4 changed files with 34 additions and 50 deletions

View file

@ -51,7 +51,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
*
* @author Matt Tucker
*/
public class Message extends XmlLangStanza {
public class Message extends Packet {
public static final String ELEMENT = "message";
public static final String BODY = "body";
@ -396,7 +396,6 @@ public class Message extends XmlLangStanza {
public XmlStringBuilder toXML() {
XmlStringBuilder buf = new XmlStringBuilder();
buf.halfOpenElement(ELEMENT);
buf.xmllangAttribute(language);
addCommonAttributes(buf);
if (type != Type.normal) {
buf.attribute("type", type);

View file

@ -61,6 +61,18 @@ public abstract class Packet extends TopLevelStreamElement {
private XMPPError error = null;
/**
* Optional value of the 'xml:lang' attribute of the outermost element of
* the stanza.
* <p>
* Such an attribute is defined for all stanza types. For IQ, see for
* example XEP-50 3.7:
* "The requester SHOULD provide its locale information using the "xml:lang
* " attribute on either the <iq/> (RECOMMENDED) or <command/> element."
* </p>
*/
protected String language;
public Packet() {
this(prefix + Long.toString(id.incrementAndGet()));
}
@ -165,6 +177,24 @@ public abstract class Packet extends TopLevelStreamElement {
this.error = error;
}
/**
* Returns the xml:lang of this Stanza, or null if one has not been set.
*
* @return the xml:lang of this Stanza, or null.
*/
public String getLanguage() {
return language;
}
/**
* Sets the xml:lang of this Stanza.
*
* @param language the xml:lang of this Stanza.
*/
public void setLanguage(String language) {
this.language = language;
}
/**
* Returns an unmodifiable collection of the packet extensions attached to the packet.
*
@ -305,7 +335,7 @@ public abstract class Packet extends TopLevelStreamElement {
}
/**
* Add to, from and id attributes
* Add to, from, id and 'xml:lang' attributes
*
* @param xml
*/
@ -313,5 +343,6 @@ public abstract class Packet extends TopLevelStreamElement {
xml.optAttribute("id", getPacketID());
xml.optAttribute("to", getTo());
xml.optAttribute("from", getFrom());
xml.xmllangAttribute(getLanguage());
}
}

View file

@ -55,7 +55,7 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
* @see RosterPacket
* @author Matt Tucker
*/
public class Presence extends XmlLangStanza {
public class Presence extends Packet {
public static final String ELEMENT = "presence";
@ -207,7 +207,6 @@ public class Presence extends XmlLangStanza {
public XmlStringBuilder toXML() {
XmlStringBuilder buf = new XmlStringBuilder();
buf.halfOpenElement(ELEMENT);
buf.xmllangAttribute(language);
addCommonAttributes(buf);
if (type != Type.available) {
buf.attribute("type", type);

View file

@ -1,45 +0,0 @@
/**
*
* Copyright © 2014 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;
/**
* Abstract class for stanzas that can contain a 'xml:lang' definition in their
* top level element, ie. Message and Presence stanzas.
*/
public abstract class XmlLangStanza extends Packet {
protected String language;
/**
* Returns the xml:lang of this Stanza, or null if one has not been set.
*
* @return the xml:lang of this Stanza, or null.
*/
public String getLanguage() {
return language;
}
/**
* Sets the xml:lang of this Stanza.
*
* @param language the xml:lang of this Stanza.
*/
public void setLanguage(String language) {
this.language = language;
}
}