summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Young <consult.awy@gmail.com>2015-07-06 08:14:13 (GMT)
committerKevin Smith <git@kismith.co.uk>2015-08-13 08:05:42 (GMT)
commit9bf162922691c1f45813da6a21f2e274bfad3114 (patch)
tree2d7c49abc72ede17701c3300140718b1c3e81bcc /src/com/isode/stroke/elements
parentaf3bb03053b9d83f4d38b31d66b292792206a327 (diff)
downloadstroke-9bf162922691c1f45813da6a21f2e274bfad3114.zip
stroke-9bf162922691c1f45813da6a21f2e274bfad3114.tar.bz2
VCard.getPhoto() to return null for absent photo.
Most of the time when VCard.getPhoto() is called it is only used to determine presence or absence of a photo. Thus, it makes no sense to allocate an empty ByteArray() just for this purpose. Return null instead, if absent. Change-Id: I3bae02ffbece5589c74c950bbb4c0db6c0376c76
Diffstat (limited to 'src/com/isode/stroke/elements')
-rw-r--r--src/com/isode/stroke/elements/VCard.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/com/isode/stroke/elements/VCard.java b/src/com/isode/stroke/elements/VCard.java
index 3bd4db2..3e64c7c 100644
--- a/src/com/isode/stroke/elements/VCard.java
+++ b/src/com/isode/stroke/elements/VCard.java
@@ -131,14 +131,17 @@ public class VCard extends Payload implements Serializable {
public void setNickname(final String nick) { nick_ = nick; }
public final String getNickname() { return nick_; }
- public void setPhoto(final ByteArray photo) { photo_ = photo; }
+ /**
+ * Set the photo, but store null if the photo is empty.
+ */
+ public void setPhoto(final ByteArray photo) { photo_ = photo != null && !photo.isEmpty() ? photo : null; }
+ /**
+ * Get the photo.
+ * Unlike Swiften, this will return null for empty photos,
+ * instead of an empty ByteArray.
+ */
public final ByteArray getPhoto() {
- if(this.photo_ != null) {
- return photo_;
- }
- else {
- return new ByteArray();
- }
+ return photo_;
}
public void setPhotoType(final String photoType) { photoType_ = photoType; }