KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xmpp > muc > DestroyRoom


1 /**
2  * $RCSfile: DestroyRoom.java,v $
3  * $Revision: 1.1 $
4  * $Date: 2005/03/27 16:24:56 $
5  *
6  * Copyright 2004 Jive Software.
7  *
8  * All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */

20
21 package org.xmpp.muc;
22
23 import org.dom4j.Element;
24 import org.xmpp.packet.IQ;
25 import org.xmpp.packet.JID;
26
27 /**
28  * DestroyRoom is a packet that when sent will ask the server to destroy a given room. The room to
29  * destroy must be specified in the TO attribute of the IQ packet. The server will send a presence
30  * unavailable together with the alternate room and reason for the destruction to all the room
31  * occupants before destroying the room.<p>
32  *
33  * When destroying a room it is possible to provide an alternate room which may be replacing the
34  * room about to be destroyed. It is also possible to provide a reason for the room destruction.
35  */

36 public class DestroyRoom extends IQ {
37
38     /**
39      * Creates a new DestroyRoom with the reason for the destruction and an alternate room JID.
40      *
41      * @param alternateJID JID of the alternate room or <tt>null</tt> if none.
42      * @param reason reason for the destruction or <tt>null</tt> if none.
43      */

44     public DestroyRoom(JID alternateJID, String JavaDoc reason) {
45         super();
46         setType(Type.set);
47         Element query = setChildElement("query", "http://jabber.org/protocol/muc#owner");
48         Element destroy = query.addElement("destroy");
49         if (alternateJID != null) {
50             destroy.addAttribute("jid", alternateJID.toString());
51         }
52         if (reason != null) {
53             destroy.addElement("reason").setText(reason);
54         }
55     }
56 }
57
Popular Tags