1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-29 07:22:07 +01:00

Make <subject/> (XML) language optional

This commit is contained in:
Florian Schmaus 2018-05-09 16:48:53 +02:00
parent 4b8f7ca6b6
commit b4b75a3cca

View file

@ -544,9 +544,6 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
private final String language;
private Subject(String language, String subject) {
if (language == null) {
throw new NullPointerException("Language cannot be null.");
}
if (subject == null) {
throw new NullPointerException("Subject cannot be null.");
}
@ -577,7 +574,9 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + this.language.hashCode();
if (language != null) {
result = prime * result + this.language.hashCode();
}
result = prime * result + this.subject.hashCode();
return result;
}
@ -611,7 +610,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
@Override
public XmlStringBuilder toXML(String enclosingNamespace) {
XmlStringBuilder xml = new XmlStringBuilder();
xml.halfOpenElement(getElementName()).xmllangAttribute(getLanguage()).rightAngleBracket();
xml.halfOpenElement(getElementName()).optXmlLangAttribute(getLanguage()).rightAngleBracket();
xml.escape(subject);
xml.closeElement(getElementName());
return xml;