blob: d552b59085f8fa44e2ec18e69901f022d5aad4ec (
plain) (
blame)
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
|
package com.juick.server;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import static com.juick.server.StreamNamespaces.NS_XMPP_STREAMS;
/**
* Created by vitalyster on 03.02.2017.
*/
public class StreamError {
private String condition;
public StreamError() {}
public StreamError(String condition) {
this.condition = condition;
}
public static StreamError parse(XmlPullParser parser) throws IOException, XmlPullParserException {
StreamError streamError = new StreamError();
while (parser.next() == XmlPullParser.START_TAG) {
final String tag = parser.getName();
final String xmlns = parser.getNamespace();
if (xmlns.equals(NS_XMPP_STREAMS)) {
streamError.condition = tag;
} else {
XmlUtils.skip(parser);
}
}
return streamError;
}
public String getCondition() {
return condition;
}
@Override
public String toString() {
return String.format("<stream:error><%s xmlns='%s'/></stream:error>", condition, NS_XMPP_STREAMS);
}
}
|