return parent.getEventType();
}
public final void update(EventBean[] newData, EventBean[] oldData)
{
OneEventCollection removedEvents = new OneEventCollection();
// Remove old data
if (oldData != null)
{
for (int i = 0; i < oldData.length; i++)
{
Object uniqueKey = getUniqueValues(oldData[i]);
Object existingSortKey = uniqueKeySortKeys.get(uniqueKey);
if (existingSortKey == null) {
continue;
}
EventBean event = removeFromSortedEvents(existingSortKey, uniqueKey);
if (event != null) {
numberOfEvents--;
uniqueKeySortKeys.remove(uniqueKey);
removedEvents.add(event);
}
}
}
// Add new data
if (newData != null)
{
for (int i = 0; i < newData.length; i++)
{
Object uniqueKey = getUniqueValues(newData[i]);
Object newSortKey = getSortValues(newData[i]);
Object existingSortKey = uniqueKeySortKeys.get(uniqueKey);
// not currently found: its a new entry
if (existingSortKey == null) {
compareAndAddOrPassthru(newData[i], uniqueKey, newSortKey, removedEvents);
}
// same unique-key event found already, remove and add again
else {
// key did not change, perform in-place substitute of event
if (existingSortKey.equals(newSortKey)) {
EventBean replaced = inplaceReplaceSortedEvents(existingSortKey, uniqueKey, newData[i]);
if (replaced != null) {
removedEvents.add(replaced);
}
}
else {
EventBean removed = removeFromSortedEvents(existingSortKey, uniqueKey);
if (removed != null) {
numberOfEvents--;
removedEvents.add(removed);
}
compareAndAddOrPassthru(newData[i], uniqueKey, newSortKey, removedEvents);
}
}
}
}
// Remove data that sorts to the bottom of the window
if (numberOfEvents > sortWindowSize)
{
while(numberOfEvents > sortWindowSize) {
Object lastKey = sortedEvents.lastKey();
Object existing = sortedEvents.get(lastKey);
if (existing instanceof List) {
List<EventBean> existingList = (List<EventBean>) existing;
while(numberOfEvents > sortWindowSize && !existingList.isEmpty()) {
EventBean newestEvent = existingList.remove(0);
Object uniqueKey = getUniqueValues(newestEvent);
uniqueKeySortKeys.remove(uniqueKey);
numberOfEvents--;
removedEvents.add(newestEvent);
}
if (existingList.isEmpty()) {
sortedEvents.remove(lastKey);
}
}
else {
EventBean lastSortedEvent = (EventBean) existing;
Object uniqueKey = getUniqueValues(lastSortedEvent);
uniqueKeySortKeys.remove(uniqueKey);
numberOfEvents--;
removedEvents.add(lastSortedEvent);
sortedEvents.remove(lastKey);
}
}
}
// If there are child views, fireStatementStopped update method
if (optionalRankedRandomAccess != null)
{
optionalRankedRandomAccess.refresh(sortedEvents, numberOfEvents, sortWindowSize);
}
if (this.hasViews())
{
EventBean[] expiredArr = null;
if (!removedEvents.isEmpty())
{
expiredArr = removedEvents.toArray();
}
updateChildren(newData, expiredArr);
}
}