summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/isode/stroke/parser/payloadparsers/DelayParser.java')
-rw-r--r--src/com/isode/stroke/parser/payloadparsers/DelayParser.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/com/isode/stroke/parser/payloadparsers/DelayParser.java b/src/com/isode/stroke/parser/payloadparsers/DelayParser.java
new file mode 100644
index 0000000..44d21ce
--- /dev/null
+++ b/src/com/isode/stroke/parser/payloadparsers/DelayParser.java
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2014 Kevin Smith and Remko Tronçon
+* All rights reserved.
+*/
+
+/*
+* Copyright (c) 2014, Isode Limited, London, England.
+* All rights reserved.
+*/
+
+package com.isode.stroke.parser.payloadparsers;
+
+import java.util.Date;
+import com.isode.stroke.base.DateTime;
+import com.isode.stroke.elements.Delay;
+import com.isode.stroke.jid.JID;
+import com.isode.stroke.parser.AttributeMap;
+import com.isode.stroke.parser.GenericPayloadParser;
+
+public class DelayParser extends GenericPayloadParser<Delay> {
+
+ public DelayParser() {
+ super(new Delay());
+ }
+
+ public void handleStartElement(String element, String ns, AttributeMap attributes) {
+ if (level_ == 0) {
+ Date stamp = DateTime.stringToDate(attributes.getAttribute("stamp"));
+ getPayloadInternal().setStamp(stamp);
+ if (!attributes.getAttribute("from").isEmpty()) {
+ String from = attributes.getAttribute("from");
+ getPayloadInternal().setFrom(new JID(from));
+ }
+ }
+ ++level_;
+ }
+
+ public void handleEndElement(String element, String ns) {
+ --level_;
+ }
+
+ public void handleCharacterData(String data) {
+ }
+
+ private int level_;
+}