RetractItem.java

  1. /**
  2.  *
  3.  * Copyright the original author or authors
  4.  *
  5.  * Licensed under the Apache License, Version 2.0 (the "License");
  6.  * you may not use this file except in compliance with the License.
  7.  * You may obtain a copy of the License at
  8.  *
  9.  *     http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.jivesoftware.smackx.pubsub;

  18. import javax.xml.namespace.QName;

  19. import org.jivesoftware.smack.packet.ExtensionElement;

  20. import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;

  21. /**
  22.  * Represents and item that has been deleted from a node.
  23.  *
  24.  * @author Robin Collier
  25.  */
  26. public class RetractItem implements ExtensionElement {
  27.     public static final QName QNAME = new QName(PubSubNamespace.event.getXmlns(), "retract");

  28.     private final String id;

  29.     /**
  30.      * Construct a <code>RetractItem</code> with the specified id.
  31.      *
  32.      * @param itemId The id if the item deleted
  33.      */
  34.     public RetractItem(String itemId) {
  35.         if (itemId == null)
  36.             throw new IllegalArgumentException("itemId must not be 'null'");
  37.         id = itemId;
  38.     }

  39.     public String getId() {
  40.         return id;
  41.     }

  42.     @Override
  43.     public String getElementName() {
  44.         return QNAME.getLocalPart();
  45.     }

  46.     @Override
  47.     public String getNamespace() {
  48.         return QNAME.getNamespaceURI();
  49.     }

  50.     @Override
  51.     public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
  52.         return "<retract id='" + id + "'/>";
  53.     }
  54. }