blob: 72693c494f1751575e79617f6c6376b1b81a5528 [file] [log] [blame]
Shuyi Chend7955ce2013-05-22 14:51:55 -07001/**
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
20package org.jivesoftware.smackx.workgroup.packet;
21
22import org.jivesoftware.smack.packet.IQ;
23import org.jivesoftware.smack.provider.IQProvider;
24import org.jivesoftware.smack.util.PacketParserUtils;
25import org.xmlpull.v1.XmlPullParser;
26
27/**
28 * IQ packet for retrieving the transcript search form, submiting the completed search form
29 * or retrieving the answer of a transcript search.
30 *
31 * @author Gaston Dombiak
32 */
33public class TranscriptSearch extends IQ {
34
35 /**
36 * Element name of the packet extension.
37 */
38 public static final String ELEMENT_NAME = "transcript-search";
39
40 /**
41 * Namespace of the packet extension.
42 */
43 public static final String NAMESPACE = "http://jivesoftware.com/protocol/workgroup";
44
45 public String getChildElementXML() {
46 StringBuilder buf = new StringBuilder();
47
48 buf.append("<").append(ELEMENT_NAME).append(" xmlns=\"").append(NAMESPACE).append("\">");
49 // Add packet extensions, if any are defined.
50 buf.append(getExtensionsXML());
51 buf.append("</").append(ELEMENT_NAME).append("> ");
52
53 return buf.toString();
54 }
55
56 /**
57 * An IQProvider for TranscriptSearch packets.
58 *
59 * @author Gaston Dombiak
60 */
61 public static class Provider implements IQProvider {
62
63 public Provider() {
64 super();
65 }
66
67 public IQ parseIQ(XmlPullParser parser) throws Exception {
68 TranscriptSearch answer = new TranscriptSearch();
69
70 boolean done = false;
71 while (!done) {
72 int eventType = parser.next();
73 if (eventType == XmlPullParser.START_TAG) {
74 // Parse the packet extension
75 answer.addExtension(PacketParserUtils.parsePacketExtension(parser.getName(), parser.getNamespace(), parser));
76 }
77 else if (eventType == XmlPullParser.END_TAG) {
78 if (parser.getName().equals(ELEMENT_NAME)) {
79 done = true;
80 }
81 }
82 }
83
84 return answer;
85 }
86 }
87}