diff options
author | Tarun Gupta <tarun1995gupta@gmail.com> | 2015-06-21 12:33:44 (GMT) |
---|---|---|
committer | Tarun Gupta <tarun1995gupta@gmail.com> | 2015-06-30 13:24:34 (GMT) |
commit | 25fade1995f559c8937b57585f462aaa2ae01c6a (patch) | |
tree | 008b432b08decc871f07bece2bc4307c033a6651 /src | |
parent | b830f64de47271777d8e45ddb0a18dc2ac740dd9 (diff) | |
download | stroke-25fade1995f559c8937b57585f462aaa2ae01c6a.zip stroke-25fade1995f559c8937b57585f462aaa2ae01c6a.tar.bz2 |
Add tests for Payloads Parsers and Payloads Serializers.
Updates DiscoInfoParser, DiscoItemsParser and VCard Element.
License:
This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Test-Information:
Test are added for:
DeliveryReceipt Parser and Serializer.
DiscoInfo Parser and Serializer, DiscoItemsParser.
Replace Parser and Serializer.
ResourceBind Parser and Serializer.
SecurityLabel Parser and Serializer.
SecurityLabelsCatalog Parser and Serializer.
Status Parser and Serializer.
StatusShow Parser and Serializer.
SoftwareVersion Parser and Serializer.
VCard Parser and Serializer.
All tests passes.
Change-Id: I8023372273e63813e1c8fe708fa6cdf39614e1f7
Diffstat (limited to 'src')
3 files changed, 29 insertions, 19 deletions
diff --git a/src/com/isode/stroke/elements/VCard.java b/src/com/isode/stroke/elements/VCard.java index 91a9093..ff4a02c 100644 --- a/src/com/isode/stroke/elements/VCard.java +++ b/src/com/isode/stroke/elements/VCard.java @@ -26,16 +26,16 @@ public class VCard extends Payload implements Serializable { private String nick_ = ""; private Date birthday_; private String unknownContent_ = ""; - private List<EMailAddress> emailAddresses_; - private List<Telephone> telephones_; - private List<Address> addresses_; - private List<AddressLabel> addressLabels_; - private List<JID> jids_; + private List<EMailAddress> emailAddresses_ = new ArrayList<EMailAddress>(); + private List<Telephone> telephones_ = new ArrayList<Telephone>(); + private List<Address> addresses_ = new ArrayList<Address>(); + private List<AddressLabel> addressLabels_ = new ArrayList<AddressLabel>(); + private List<JID> jids_ = new ArrayList<JID>(); private String description_ = ""; - private List<Organization> organizations_; - private List<String> titles_; - private List<String> roles_; - private List<String> urls_; + private List<Organization> organizations_ = new ArrayList<Organization>(); + private List<String> titles_ = new ArrayList<String>(); + private List<String> roles_ = new ArrayList<String>(); + private List<String> urls_ = new ArrayList<String>(); public static class EMailAddress { public boolean isHome; @@ -43,7 +43,7 @@ public class VCard extends Payload implements Serializable { public boolean isInternet; public boolean isPreferred; public boolean isX400; - public String address; + public String address = ""; }; public static class Telephone { @@ -60,7 +60,7 @@ public class VCard extends Payload implements Serializable { public boolean isISDN; public boolean isPCS; public boolean isPreferred; - public String number; + public String number = ""; }; public static enum DeliveryType { @@ -77,13 +77,13 @@ public class VCard extends Payload implements Serializable { public DeliveryType deliveryType; public boolean isPreferred; - public String poBox; - public String addressExtension; - public String street; - public String locality; - public String region; - public String postalCode; - public String country; + public String poBox = ""; + public String addressExtension = ""; + public String street = ""; + public String locality = ""; + public String region = ""; + public String postalCode = ""; + public String country = ""; }; public static class AddressLabel { @@ -97,7 +97,7 @@ public class VCard extends Payload implements Serializable { }; public static class Organization { - public String name; + public String name = ""; public List<String> units = new ArrayList<String>(); }; diff --git a/src/com/isode/stroke/parser/payloadparsers/DiscoInfoParser.java b/src/com/isode/stroke/parser/payloadparsers/DiscoInfoParser.java index acd1ae0..181caa2 100644 --- a/src/com/isode/stroke/parser/payloadparsers/DiscoInfoParser.java +++ b/src/com/isode/stroke/parser/payloadparsers/DiscoInfoParser.java @@ -19,6 +19,11 @@ public class DiscoInfoParser extends GenericPayloadParser<DiscoInfo> { } public void handleStartElement(String element, String ns, AttributeMap attributes) { + if (level_ == TopLevel) { + if (attributes.getAttributeValue("node") != null) { + getPayloadInternal().setNode(attributes.getAttributeValue("node")); + } + } if (level_ == PayloadLevel) { if (element .equals("identity")) { getPayloadInternal().addIdentity(new DiscoInfo.Identity(attributes.getAttribute("name"), attributes.getAttribute("category"), attributes.getAttribute("type"), attributes.getAttribute("lang", "http://www.w3.org/XML/1998/namespace"))); diff --git a/src/com/isode/stroke/parser/payloadparsers/DiscoItemsParser.java b/src/com/isode/stroke/parser/payloadparsers/DiscoItemsParser.java index 091fd32..abf7c29 100644 --- a/src/com/isode/stroke/parser/payloadparsers/DiscoItemsParser.java +++ b/src/com/isode/stroke/parser/payloadparsers/DiscoItemsParser.java @@ -26,6 +26,11 @@ public class DiscoItemsParser extends GenericPayloadParser<DiscoItems> { getPayloadInternal().addItem(item); } } + else if (level_ == TopLevel) { + if (element.equals("query")) { + getPayloadInternal().setNode(attributes.getAttribute("node")); + } + } ++level_; } |