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 java.util.Collections; 020import java.util.List; 021 022/** 023 * Base class to represents events that are associated to subscriptions. 024 * 025 * @author Robin Collier 026 */ 027abstract public class SubscriptionEvent extends NodeEvent 028{ 029 private List<String> subIds = Collections.emptyList(); 030 031 /** 032 * Construct an event with no subscription id's. This can 033 * occur when there is only one subscription to a node. The 034 * event may or may not report the subscription id along 035 * with the event. 036 * 037 * @param nodeId The id of the node the event came from 038 */ 039 protected SubscriptionEvent(String nodeId) 040 { 041 super(nodeId); 042 } 043 044 /** 045 * Construct an event with multiple subscriptions. 046 * 047 * @param nodeId The id of the node the event came from 048 * @param subscriptionIds The list of subscription id's 049 */ 050 protected SubscriptionEvent(String nodeId, List<String> subscriptionIds) 051 { 052 super(nodeId); 053 054 if (subscriptionIds != null) 055 subIds = subscriptionIds; 056 } 057 058 /** 059 * Get the subscriptions this event is associated with. 060 * 061 * @return List of subscription id's 062 */ 063 public List<String> getSubscriptions() 064 { 065 return Collections.unmodifiableList(subIds); 066 } 067 068 /** 069 * Set the list of subscription id's for this event. 070 * 071 * @param subscriptionIds The list of subscription id's 072 */ 073 protected void setSubscriptions(List<String> subscriptionIds) 074 { 075 if (subscriptionIds != null) 076 subIds = subscriptionIds; 077 } 078}