mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-25 15:52:06 +01:00
Make Body and Subject implement ExtensionElement
This commit is contained in:
parent
f51ea33036
commit
52a52e12d2
1 changed files with 48 additions and 8 deletions
|
@ -490,9 +490,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
||||||
// Skip the default language
|
// Skip the default language
|
||||||
if(subject.equals(defaultSubject))
|
if(subject.equals(defaultSubject))
|
||||||
continue;
|
continue;
|
||||||
buf.halfOpenElement("subject").xmllangAttribute(subject.language).rightAngleBracket();
|
buf.append(subject.toXML());
|
||||||
buf.escape(subject.subject);
|
|
||||||
buf.closeElement("subject");
|
|
||||||
}
|
}
|
||||||
// Add the body in the default language
|
// Add the body in the default language
|
||||||
Body defaultBody = getMessageBody(null);
|
Body defaultBody = getMessageBody(null);
|
||||||
|
@ -504,9 +502,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
||||||
// Skip the default language
|
// Skip the default language
|
||||||
if(body.equals(defaultBody))
|
if(body.equals(defaultBody))
|
||||||
continue;
|
continue;
|
||||||
buf.halfOpenElement(BODY).xmllangAttribute(body.getLanguage()).rightAngleBracket();
|
buf.append(body.toXML());
|
||||||
buf.escape(body.getMessage());
|
|
||||||
buf.closeElement(BODY);
|
|
||||||
}
|
}
|
||||||
buf.optElement("thread", thread);
|
buf.optElement("thread", thread);
|
||||||
// Append the error subpacket if the message type is an error.
|
// Append the error subpacket if the message type is an error.
|
||||||
|
@ -535,7 +531,10 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
||||||
/**
|
/**
|
||||||
* Represents a message subject, its language and the content of the subject.
|
* Represents a message subject, its language and the content of the subject.
|
||||||
*/
|
*/
|
||||||
public static final class Subject {
|
public static final class Subject implements ExtensionElement {
|
||||||
|
|
||||||
|
public static final String ELEMENT = "subject";
|
||||||
|
public static final String NAMESPACE = StreamOpen.CLIENT_NAMESPACE;
|
||||||
|
|
||||||
private final String subject;
|
private final String subject;
|
||||||
private final String language;
|
private final String language;
|
||||||
|
@ -595,12 +594,34 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
||||||
return this.language.equals(other.language) && this.subject.equals(other.subject);
|
return this.language.equals(other.language) && this.subject.equals(other.subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getElementName() {
|
||||||
|
return ELEMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNamespace() {
|
||||||
|
return NAMESPACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public XmlStringBuilder toXML() {
|
||||||
|
XmlStringBuilder xml = new XmlStringBuilder();
|
||||||
|
xml.halfOpenElement(getElementName()).xmllangAttribute(getLanguage()).rightAngleBracket();
|
||||||
|
xml.escape(subject);
|
||||||
|
xml.closeElement(getElementName());
|
||||||
|
return xml;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a message body, its language and the content of the message.
|
* Represents a message body, its language and the content of the message.
|
||||||
*/
|
*/
|
||||||
public static final class Body {
|
public static final class Body implements ExtensionElement {
|
||||||
|
|
||||||
|
public static final String ELEMENT = "body";
|
||||||
|
public static final String NAMESPACE = StreamOpen.CLIENT_NAMESPACE;
|
||||||
|
|
||||||
private final String message;
|
private final String message;
|
||||||
private final String language;
|
private final String language;
|
||||||
|
@ -659,6 +680,25 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
|
||||||
return this.language.equals(other.language) && this.message.equals(other.message);
|
return this.language.equals(other.language) && this.message.equals(other.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getElementName() {
|
||||||
|
return ELEMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNamespace() {
|
||||||
|
return NAMESPACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public XmlStringBuilder toXML() {
|
||||||
|
XmlStringBuilder xml = new XmlStringBuilder();
|
||||||
|
xml.halfOpenElement(getElementName()).xmllangAttribute(getLanguage()).rightAngleBracket();
|
||||||
|
xml.escape(message);
|
||||||
|
xml.closeElement(getElementName());
|
||||||
|
return xml;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue