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.workgroup.packet;
019
020import java.io.IOException;
021
022import org.jivesoftware.smack.SmackException;
023import org.jivesoftware.smack.packet.SimpleIQ;
024import org.jivesoftware.smack.provider.IQProvider;
025import org.jivesoftware.smack.util.PacketParserUtils;
026import org.xmlpull.v1.XmlPullParser;
027import org.xmlpull.v1.XmlPullParserException;
028
029/**
030 * IQ stanza(/packet) for retrieving the transcript search form, submiting the completed search form
031 * or retrieving the answer of a transcript search.
032 *
033 * @author Gaston Dombiak
034 */
035public class TranscriptSearch extends SimpleIQ {
036
037    /**
038    * Element name of the stanza(/packet) extension.
039    */
040   public static final String ELEMENT_NAME = "transcript-search";
041
042   /**
043    * Namespace of the stanza(/packet) extension.
044    */
045   public static final String NAMESPACE = "http://jivesoftware.com/protocol/workgroup";
046
047   public TranscriptSearch() {
048       super(ELEMENT_NAME, NAMESPACE);
049   }
050
051    /**
052     * An IQProvider for TranscriptSearch packets.
053     *
054     * @author Gaston Dombiak
055     */
056    public static class Provider extends IQProvider<TranscriptSearch> {
057
058        @Override
059        public TranscriptSearch parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
060            TranscriptSearch answer = new TranscriptSearch();
061
062            boolean done = false;
063            while (!done) {
064                int eventType = parser.next();
065                if (eventType == XmlPullParser.START_TAG) {
066                    // Parse the packet extension
067                    PacketParserUtils.addExtensionElement(answer, parser);
068                }
069                else if (eventType == XmlPullParser.END_TAG) {
070                    if (parser.getName().equals(ELEMENT_NAME)) {
071                        done = true;
072                    }
073                }
074            }
075
076            return answer;
077        }
078    }
079}