mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 06:12:05 +01:00
Add XmlStringBuilder.optAttribute(String, Number)
This commit is contained in:
parent
0e52560358
commit
505493d889
2 changed files with 9 additions and 7 deletions
|
@ -327,6 +327,13 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public XmlStringBuilder optAttribute(String name, Number number) {
|
||||||
|
if (number != null) {
|
||||||
|
attribute(name, number.toString());
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the given attribute if {@code value => 0}.
|
* Add the given attribute if {@code value => 0}.
|
||||||
*
|
*
|
||||||
|
|
|
@ -103,13 +103,8 @@ public class Range implements NamedElement {
|
||||||
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
|
||||||
XmlStringBuilder sb = new XmlStringBuilder(this);
|
XmlStringBuilder sb = new XmlStringBuilder(this);
|
||||||
|
|
||||||
// TODO: (Introduce and) use XmlStringBuilder.optXmlAttribute(name, Number).
|
sb.optAttribute(ATTR_OFFSET, offset);
|
||||||
if (offset != null) {
|
sb.optAttribute(ATTR_LENGTH, length);
|
||||||
sb.attribute(ATTR_OFFSET, offset);
|
|
||||||
}
|
|
||||||
if (length != null) {
|
|
||||||
sb.attribute(ATTR_LENGTH, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hash != null) {
|
if (hash != null) {
|
||||||
sb.rightAngleBracket();
|
sb.rightAngleBracket();
|
||||||
|
|
Loading…
Reference in a new issue