1 19 package jcckit.data; 20 21 26 public class DataEvent { 27 private final DataContainer _container; 28 private final DataEventType _type; 29 private final int _index; 30 private final DataElement _deletedElement; 31 32 40 private DataEvent(DataContainer container, DataEventType type, int index, 41 DataElement deletedElement) { 42 _container = container; 43 _type = type; 44 _index = index; 45 _deletedElement = deletedElement; 46 } 47 48 54 public static final DataEvent createAddEvent(DataContainer container) { 55 return new DataEvent(container, DataEventType.ELEMENT_ADDED, 56 container.getNumberOfElements() - 1, null); 57 } 58 59 66 public static final DataEvent createInsertEvent(DataContainer container, 67 int index) { 68 return new DataEvent(container, DataEventType.ELEMENT_INSERTED, index, 69 null); 70 } 71 72 80 public static final DataEvent createReplaceEvent(DataContainer container, 81 int index, DataElement replacedElement) { 82 return new DataEvent(container, DataEventType.ELEMENT_REPLACED, index, 83 replacedElement); 84 } 85 86 94 public static final DataEvent createRemoveEvent(DataContainer container, 95 int index, DataElement removedElement) { 96 return new DataEvent(container, DataEventType.ELEMENT_REMOVED, index, 97 removedElement); 98 } 99 100 101 public DataContainer getContainer() { 102 return _container; 103 } 104 105 112 public DataEventType getType() { 113 return _type; 114 } 115 116 117 public int getIndex() { 118 return _index; 119 } 120 121 125 public DataElement getDeletedElement() { 126 return _deletedElement; 127 } 128 } 129 | Popular Tags |