001/** 002 * 003 * Copyright 2003-2007 Jive Software. 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package org.jivesoftware.smackx.muc.provider; 019 020import org.jivesoftware.smack.provider.IQProvider; 021import org.jivesoftware.smack.util.PacketParserUtils; 022 023import org.jivesoftware.smackx.muc.packet.MUCOwner; 024 025import org.xmlpull.v1.XmlPullParser; 026 027/** 028 * The MUCOwnerProvider parses MUCOwner packets. (@see MUCOwner) 029 * 030 * @author Gaston Dombiak 031 */ 032public class MUCOwnerProvider extends IQProvider<MUCOwner> { 033 034 @Override 035 public MUCOwner parse(XmlPullParser parser, int initialDepth) 036 throws Exception { 037 MUCOwner mucOwner = new MUCOwner(); 038 boolean done = false; 039 while (!done) { 040 int eventType = parser.next(); 041 if (eventType == XmlPullParser.START_TAG) { 042 if (parser.getName().equals("item")) { 043 mucOwner.addItem(MUCParserUtils.parseItem(parser)); 044 } 045 else if (parser.getName().equals("destroy")) { 046 mucOwner.setDestroy(MUCParserUtils.parseDestroy(parser)); 047 } 048 // Otherwise, it must be a packet extension. 049 else { 050 PacketParserUtils.addExtensionElement(mucOwner, parser); 051 } 052 } 053 else if (eventType == XmlPullParser.END_TAG) { 054 if (parser.getName().equals("query")) { 055 done = true; 056 } 057 } 058 } 059 060 return mucOwner; 061 } 062}