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 * Base class to represents events that are associated to subscriptions. 21 * 22 * @author Robin Collier 23 */ 24 abstract public class SubscriptionEvent extends NodeEvent 25 { 26 private List<String> subIds = Collections.EMPTY_LIST; 27 28 /** 29 * Construct an event with no subscription id's. This can 30 * occur when there is only one subscription to a node. The 31 * event may or may not report the subscription id along 32 * with the event. 33 * 34 * @param nodeId The id of the node the event came from 35 */ 36 protected SubscriptionEvent(String nodeId) 37 { 38 super(nodeId); 39 } 40 41 /** 42 * Construct an event with multiple subscriptions. 43 * 44 * @param nodeId The id of the node the event came from 45 * @param subscriptionIds The list of subscription id's 46 */ 47 protected SubscriptionEvent(String nodeId, List<String> subscriptionIds) 48 { 49 super(nodeId); 50 51 if (subscriptionIds != null) 52 subIds = subscriptionIds; 53 } 54 55 /** 56 * Get the subscriptions this event is associated with. 57 * 58 * @return List of subscription id's 59 */ 60 public List<String> getSubscriptions() 61 { 62 return Collections.unmodifiableList(subIds); 63 } 64 65 /** 66 * Set the list of subscription id's for this event. 67 * 68 * @param subscriptionIds The list of subscription id's 69 */ 70 protected void setSubscriptions(List<String> subscriptionIds) 71 { 72 if (subscriptionIds != null) 73 subIds = subscriptionIds; 74 } 75 } 76