001/**
002 *
003 * Copyright 2003-2007 Jive Software, 2014 Florian Schmaus
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 */
017package org.jivesoftware.smackx.muc.packet;
018
019import org.jivesoftware.smack.packet.NamedElement;
020import org.jivesoftware.smack.util.XmlStringBuilder;
021
022/**
023 * Represents a request to the server to destroy a room. The sender of the request should be the
024 * room's owner. If the sender of the destroy request is not the room's owner then the server will
025 * answer a "Forbidden" error.
026 * 
027 * @author Gaston Dombiak
028 */
029public class Destroy implements NamedElement {
030    public static final String ELEMENT = "destroy";
031
032    private String reason;
033    private String jid;
034
035    /**
036     * Returns the JID of an alternate location since the current room is being destroyed.
037     * 
038     * @return the JID of an alternate location.
039     */
040    public String getJid() {
041        return jid;
042    }
043
044    /**
045     * Returns the reason for the room destruction.
046     * 
047     * @return the reason for the room destruction.
048     */
049    public String getReason() {
050        return reason;
051    }
052
053    /**
054     * Sets the JID of an alternate location since the current room is being destroyed.
055     * 
056     * @param jid the JID of an alternate location.
057     */
058    public void setJid(String jid) {
059        this.jid = jid;
060    }
061
062    /**
063     * Sets the reason for the room destruction.
064     * 
065     * @param reason the reason for the room destruction.
066     */
067    public void setReason(String reason) {
068        this.reason = reason;
069    }
070
071    @Override
072    public XmlStringBuilder toXML() {
073        XmlStringBuilder xml = new XmlStringBuilder(this);
074        xml.optAttribute("jid", getJid());
075        xml.rightAngleBracket();
076        xml.optElement("reason", getReason());
077        xml.closeElement(this);
078        return xml;
079    }
080
081    @Override
082    public String getElementName() {
083        return ELEMENT;
084    }
085
086}