001/**
002 *
003 * Copyright the original author or authors
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.pubsub;
018
019import javax.xml.namespace.QName;
020
021import org.jivesoftware.smack.packet.ExtensionElement;
022
023import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
024
025/**
026 * Represents and item that has been deleted from a node.
027 *
028 * @author Robin Collier
029 */
030public class RetractItem implements ExtensionElement {
031    public static final QName QNAME = new QName(PubSubNamespace.event.getXmlns(), "retract");
032
033    private final String id;
034
035    /**
036     * Construct a <code>RetractItem</code> with the specified id.
037     *
038     * @param itemId The id if the item deleted
039     */
040    public RetractItem(String itemId) {
041        if (itemId == null)
042            throw new IllegalArgumentException("itemId must not be 'null'");
043        id = itemId;
044    }
045
046    public String getId() {
047        return id;
048    }
049
050    @Override
051    public String getElementName() {
052        return QNAME.getLocalPart();
053    }
054
055    @Override
056    public String getNamespace() {
057        return QNAME.getNamespaceURI();
058    }
059
060    @Override
061    public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
062        return "<retract id='" + id + "'/>";
063    }
064}