int changeType = listChanges.getType();
switch (changeType) {
case ListEvent.DELETE:
changeList.getReadWriteLock().readLock().lock();
Download d1 = (Download) listChanges.getOldValue();
changeList.getReadWriteLock().readLock().unlock();
d1.removePropertyChangeListener(this);
md5ValuesMap.remove(d1);
linkStateValuesMap.remove(d1);
if (saveDelete) {
dao.deleteDownload(d1.getId());
}
WordSaver wordSaver = wordSavers.get(d1);
d1.removeWordsListener(wordSaver);
wordSavers.remove(d1);
HrefLinkSaver hrefSaver = hrefSavers.get(d1);
d1.removeHrefLinksListener(hrefSaver);
hrefSavers.remove(d1);
SrcLinkSaver srcSaver = srcSavers.get(d1);
d1.removeSrcLinksListener(srcSaver);
srcSavers.remove(d1);
LocationSaver locationSaver = locationSavers.get(d1);
d1.removeSrcLinksListener(locationSaver);
locationSavers.remove(d1);
break;
case ListEvent.INSERT:
changeList.getReadWriteLock().readLock().lock();
Download d2 = (Download) changeList.get(sourceIndex);
changeList.getReadWriteLock().readLock().unlock();
d2.addPropertyChangeListener(this);
dao.insertDownload(d2);
wordSavers.put(d2, new WordSaver(d2));
hrefSavers.put(d2, new HrefLinkSaver(d2));
srcSavers.put(d2, new SrcLinkSaver(d2));
locationSavers.put(d2, new LocationSaver(d2));
break;
case ListEvent.UPDATE:
changeList.getReadWriteLock().readLock().lock();
Download d3 = (Download) changeList.get(sourceIndex);
changeList.getReadWriteLock().readLock().unlock();
updateMD5(d3);
updateLinkState(d3);
break;