diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/XmlStringBuilder.java b/smack-core/src/main/java/org/jivesoftware/smack/util/XmlStringBuilder.java index c46e933c2..49972aacb 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/XmlStringBuilder.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/XmlStringBuilder.java @@ -389,6 +389,22 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element { return this; } + /** + * If the provided Integer argument is not null, then add a new XML attribute with the given name and the Integer as + * value. + * + * @param name the XML attribute name. + * @param value the optional integer to use as the attribute's value. + * @return a reference to this object. + * @since 4.4.1 + */ + public XmlStringBuilder optIntAttribute(String name, Integer value) { + if (value != null) { + attribute(name, value.toString()); + } + return this; + } + /** * Add the given attribute if value not null and {@code value => 0}. * diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/bob/element/BoBDataExtension.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/bob/element/BoBDataExtension.java index 76414d9bc..7b7f81709 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/bob/element/BoBDataExtension.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/bob/element/BoBDataExtension.java @@ -60,6 +60,26 @@ public class BoBDataExtension implements ExtensionElement { return NAMESPACE; } + /** + * Get the content ID. + * + * @return the content ID. + * @since 4.4.1 + */ + public final ContentId getContentId() { + return cid; + } + + /** + * Get the Bits of Binary (BOB) data. + * + * @return the BoB data. + * @since 4.4.1 + */ + public final BoBData getBobData() { + return bobData; + } + @Override public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) { XmlStringBuilder xml = new XmlStringBuilder(this); diff --git a/smack-im/src/main/java/org/jivesoftware/smack/roster/rosterstore/DirectoryRosterStore.java b/smack-im/src/main/java/org/jivesoftware/smack/roster/rosterstore/DirectoryRosterStore.java index a78a44c28..3b8e70bb8 100644 --- a/smack-im/src/main/java/org/jivesoftware/smack/roster/rosterstore/DirectoryRosterStore.java +++ b/smack-im/src/main/java/org/jivesoftware/smack/roster/rosterstore/DirectoryRosterStore.java @@ -183,7 +183,7 @@ public final class DirectoryRosterStore implements RosterStore { private static Item readEntry(File file) { Reader reader; try { - // TODO: Should use Files.newBufferedReader() but it is not available on Android. + // TODO: Use Files.newBufferedReader() once Smack's minimum Android API level is 26 or higher. reader = new FileReader(file); } catch (FileNotFoundException e) { LOGGER.log(Level.FINE, "Roster entry file not found", e); @@ -195,7 +195,7 @@ public final class DirectoryRosterStore implements RosterStore { Item item = RosterPacketProvider.parseItem(parser); reader.close(); return item; - } catch (XmlPullParserException | IOException e) { + } catch (XmlPullParserException | IOException | IllegalArgumentException e) { boolean deleted = file.delete(); String message = "Exception while parsing roster entry."; if (deleted) {