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