/*
 * Decompiled with CFR 0.152.
 */
package org.jivesoftware.smack.provider;

import java.io.IOException;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.packet.Bind;
import org.jivesoftware.smack.provider.IQProvider;
import org.jxmpp.jid.FullJid;
import org.jxmpp.jid.impl.JidCreate;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

public class BindIQProvider
extends IQProvider<Bind> {
    /*
     * Enabled aggressive block sorting
     */
    @Override
    public Bind parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
        Bind bind = null;
        while (true) {
            int eventType = parser.next();
            block0 : switch (eventType) {
                case 2: {
                    String name;
                    switch (name = parser.getName()) {
                        case "resource": {
                            bind = Bind.newSet(parser.nextText());
                            break block0;
                        }
                        case "jid": {
                            FullJid fullJid = JidCreate.fullFrom(parser.nextText());
                            bind = Bind.newResult(fullJid);
                            break block0;
                        }
                    }
                    break;
                }
                case 3: {
                    if (parser.getDepth() != initialDepth) break;
                    return bind;
                }
            }
        }
    }
}
