1 17 package org.eclipse.emf.common.notify.impl; 18 19 20 import org.eclipse.emf.common.notify.Notification; 21 import org.eclipse.emf.common.notify.NotificationChain; 22 import org.eclipse.emf.common.notify.Notifier; 23 import org.eclipse.emf.common.util.BasicEList; 24 25 26 29 public class NotificationChainImpl extends BasicEList implements NotificationChain 30 { 31 34 public NotificationChainImpl() 35 { 36 super(); 37 } 38 39 43 public NotificationChainImpl(int initialCapacity) 44 { 45 super(initialCapacity); 46 } 47 48 52 protected Object [] newData(int capacity) 53 { 54 return new Notification [capacity]; 55 } 56 57 62 public boolean add(Notification newNotification) 63 { 64 if (newNotification == null) 65 { 66 return false; 67 } 68 else 69 { 70 for (int i = 0; i < size; ++i) 71 { 72 Notification notification = (Notification)data[i]; 73 if (notification.merge(newNotification)) 74 { 75 return false; 76 } 77 } 78 79 return super.add(newNotification); 80 } 81 } 82 83 88 public boolean add(Object object) 89 { 90 return add((Notification)object); 91 } 92 93 96 public void dispatch() 97 { 98 for (int i = 0; i < size; ++i) 99 { 100 Notification notification = (Notification)data[i]; 101 dispatch(notification); 102 } 103 } 104 105 108 protected void dispatch(Notification notification) 109 { 110 Object notifier = notification.getNotifier(); 111 if (notifier != null && notification.getEventType() != -1) 112 { 113 ((Notifier)notifier).eNotify(notification); 114 } 115 } 116 } 117 | Popular Tags |