blob: 26343a03102080dd5486fcaba2d29ef1d4403a9e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
/*
* 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 com.isode.stroke.elements.ResultSet;
import com.isode.stroke.parser.AttributeMap;
import com.isode.stroke.parser.GenericPayloadParser;
public class ResultSetParser extends GenericPayloadParser<ResultSet> {
public ResultSetParser() {
super(new ResultSet());
}
public void handleStartElement(String element, String ns, AttributeMap attributes) {
currentText_ = "";
if (level_ == 1) {
if (element == "first" && ns == "http://jabber.org/protocol/rsm") {
String attributeValue = attributes.getAttributeValue("index");
if (attributeValue != null) {
getPayloadInternal().setFirstIDIndex(Long.parseLong(attributeValue));
}
}
}
++level_;
}
public void handleEndElement(String element, String ns) {
--level_;
if (level_ == 1) {
if (element == "max") {
getPayloadInternal().setMaxItems(Long.parseLong(currentText_));
} else if (element == "count") {
getPayloadInternal().setCount(Long.parseLong(currentText_));
} else if (element == "first") {
getPayloadInternal().setFirstID(currentText_);
} else if (element == "last") {
getPayloadInternal().setLastID(currentText_);
} else if (element == "after") {
getPayloadInternal().setAfter(currentText_);
} else if (element == "before") {
getPayloadInternal().setBefore(currentText_);
}
}
}
public void handleCharacterData(String data) {
currentText_ += data;
}
private String currentText_;
private int level_;
}
|