1 /** 2 * $Revision$ 3 * $Date$ 4 * 5 * Copyright 2003-2007 Jive Software. 6 * 7 * All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20 package org.jivesoftware.smackx.workgroup.ext.forms; 21 22 import org.jivesoftware.smack.packet.IQ; 23 import org.jivesoftware.smack.provider.IQProvider; 24 import org.jivesoftware.smack.util.PacketParserUtils; 25 import org.xmlpull.v1.XmlPullParser; 26 27 public class WorkgroupForm extends IQ { 28 29 /** 30 * Element name of the packet extension. 31 */ 32 public static final String ELEMENT_NAME = "workgroup-form"; 33 34 /** 35 * Namespace of the packet extension. 36 */ 37 public static final String NAMESPACE = "http://jivesoftware.com/protocol/workgroup"; 38 39 public String getChildElementXML() { 40 StringBuilder buf = new StringBuilder(); 41 42 buf.append("<").append(ELEMENT_NAME).append(" xmlns=\"").append(NAMESPACE).append("\">"); 43 // Add packet extensions, if any are defined. 44 buf.append(getExtensionsXML()); 45 buf.append("</").append(ELEMENT_NAME).append("> "); 46 47 return buf.toString(); 48 } 49 50 /** 51 * An IQProvider for WebForm packets. 52 * 53 * @author Derek DeMoro 54 */ 55 public static class InternalProvider implements IQProvider { 56 57 public InternalProvider() { 58 super(); 59 } 60 61 public IQ parseIQ(XmlPullParser parser) throws Exception { 62 WorkgroupForm answer = new WorkgroupForm(); 63 64 boolean done = false; 65 while (!done) { 66 int eventType = parser.next(); 67 if (eventType == XmlPullParser.START_TAG) { 68 // Parse the packet extension 69 answer.addExtension(PacketParserUtils.parsePacketExtension(parser.getName(), 70 parser.getNamespace(), parser)); 71 } 72 else if (eventType == XmlPullParser.END_TAG) { 73 if (parser.getName().equals(ELEMENT_NAME)) { 74 done = true; 75 } 76 } 77 } 78 79 return answer; 80 } 81 } 82 } 83