diff options
author | Tarun Gupta <tarun1995gupta@gmail.com> | 2015-03-10 20:00:51 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2015-03-12 21:48:21 (GMT) |
commit | 158a5ca03eea87054c4cb19d7f0de872059c6000 (patch) | |
tree | 3a0955b3726526c11786b83783dde30154be81bd /src/com/isode/stroke/parser/payloadparsers/CapsInfoParser.java | |
parent | 91a69677c1ab752b867613c4f5666a5d97ba94f7 (diff) | |
download | stroke-158a5ca03eea87054c4cb19d7f0de872059c6000.zip stroke-158a5ca03eea87054c4cb19d7f0de872059c6000.tar.bz2 |
Add functionality for CapsInfo
Adds the Element, Parser, Serializer and CapsInfoSerializerTest.
License:
This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Test-Information:
Ported serializer test from Swiften, which passes.
Change-Id: Iefc10f49732c835f1f17e5da00dabed899da975e
Diffstat (limited to 'src/com/isode/stroke/parser/payloadparsers/CapsInfoParser.java')
-rw-r--r-- | src/com/isode/stroke/parser/payloadparsers/CapsInfoParser.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/com/isode/stroke/parser/payloadparsers/CapsInfoParser.java b/src/com/isode/stroke/parser/payloadparsers/CapsInfoParser.java new file mode 100644 index 0000000..de0053f --- /dev/null +++ b/src/com/isode/stroke/parser/payloadparsers/CapsInfoParser.java @@ -0,0 +1,40 @@ +package com.isode.stroke.parser.payloadparsers; + +import com.isode.stroke.parser.GenericPayloadParser; +import com.isode.stroke.parser.AttributeMap; +import com.isode.stroke.elements.CapsInfo; +import com.isode.stroke.base.NotNull; + +public class CapsInfoParser extends GenericPayloadParser<CapsInfo> { + + private int level_ = 0; + + /** + * CapsInfoParser(); + */ + public CapsInfoParser() { + super(new CapsInfo()); + } + + /** + * @param attributes, notnull. + */ + public void handleStartElement(String element, String ns, AttributeMap attributes) { + NotNull.exceptIfNull(attributes, "attributes"); + if (this.level_ == 0) { + getPayloadInternal().setHash(attributes.getAttribute("hash")); + getPayloadInternal().setNode(attributes.getAttribute("node")); + getPayloadInternal().setVersion(attributes.getAttribute("ver")); + } + ++level_; + } + + public void handleEndElement(String element, String ns) { + --level_; + } + + public void handleCharacterData(String data) { + + } + +} |