diff options
author | 2018-04-02 16:47:02 +0300 | |
---|---|---|
committer | 2018-04-02 16:47:02 +0300 | |
commit | 5b5ca32a22e2e8e95c9bca86ce23d19c4a69f83d (patch) | |
tree | b65bd56a0a7fdd59ced863e4a0063ed6510840c0 /juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/StreamError.java | |
parent | 22ee9166d87a9b6a853c25c5f2bb3ff95aacad35 (diff) |
xmpp: move to library project
Diffstat (limited to 'juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/StreamError.java')
-rw-r--r-- | juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/StreamError.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/StreamError.java b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/StreamError.java new file mode 100644 index 00000000..7eacfc94 --- /dev/null +++ b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/StreamError.java @@ -0,0 +1,44 @@ +package com.juick.server.xmpp.router; + +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; + +import java.io.IOException; + + +/** + * 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(StreamNamespaces.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, StreamNamespaces.NS_XMPP_STREAMS); + } +} |