Home | History | Annotate | Download | only in pubsub
      1 /**
      2  * All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
      3  * you may not use this file except in compliance with the License.
      4  * You may obtain a copy of the License at
      5  *
      6  *     http://www.apache.org/licenses/LICENSE-2.0
      7  *
      8  * Unless required by applicable law or agreed to in writing, software
      9  * distributed under the License is distributed on an "AS IS" BASIS,
     10  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     11  * See the License for the specific language governing permissions and
     12  * limitations under the License.
     13  */
     14 package org.jivesoftware.smackx.pubsub;
     15 
     16 import java.util.Collections;
     17 import java.util.List;
     18 
     19 /**
     20  * Represents an event in which items have been deleted from the node.
     21  *
     22  * @author Robin Collier
     23  */
     24 public class ItemDeleteEvent extends SubscriptionEvent
     25 {
     26 	private List<String> itemIds = Collections.EMPTY_LIST;
     27 
     28 	/**
     29 	 * Constructs an <tt>ItemDeleteEvent</tt> that indicates the the supplied
     30 	 * items (by id) have been deleted, and that the event matches the listed
     31 	 * subscriptions.  The subscriptions would have been created by calling
     32 	 * {@link LeafNode#subscribe(String)}.
     33 	 *
     34 	 * @param nodeId The id of the node the event came from
     35 	 * @param deletedItemIds The item ids of the items that were deleted.
     36 	 * @param subscriptionIds The subscriptions that match the event.
     37 	 */
     38 	public ItemDeleteEvent(String nodeId, List<String> deletedItemIds, List<String> subscriptionIds)
     39 	{
     40 		super(nodeId, subscriptionIds);
     41 
     42 		if (deletedItemIds == null)
     43 			throw new IllegalArgumentException("deletedItemIds cannot be null");
     44 		itemIds = deletedItemIds;
     45 	}
     46 
     47 	/**
     48 	 * Get the item id's of the items that have been deleted.
     49 	 *
     50 	 * @return List of item id's
     51 	 */
     52 	public List<String> getItemIds()
     53 	{
     54 		return Collections.unmodifiableList(itemIds);
     55 	}
     56 
     57 	@Override
     58 	public String toString()
     59 	{
     60 		return getClass().getName() + "  [subscriptions: " + getSubscriptions() + "], [Deleted Items: " + itemIds + ']';
     61 	}
     62 }
     63