}
public synchronized void assignDuplicate(DataModel duplicate, CopyPairs copyPairs) {
DataModelEnumeration enDuplicate = duplicate.getEnumeration();
DataModelEnumeration enOrig = getEnumeration();
CopyPairs cp = null;
boolean valueChanged = false;
CopyPairs origChildren = null;
deleted = null;
if (((ArrayModel) duplicate).getSize() != getSize()) {
valueChanged = true;
}
DataModelVector newChildren = new DataModelVector();
while (enDuplicate.hasMore()) {
DataModel duplicateChild = enDuplicate.next();
DataModel origChild = (DataModel) copyPairs.getOrig(duplicateChild);
if (origChild == null) {
valueChanged = true;
if (cp == null) {
cp = new CopyPairs();
}
newChildren.append(duplicateChild.duplicate(null, cp));
} else {
if (origChildren == null) {
origChildren = new CopyPairs();
}
origChild.assignDuplicate(duplicateChild, copyPairs);
origChildren.put(origChild, origChild);
origChild.setParentDataModelContainer(null);
newChildren.append(origChild);
}
if (!valueChanged) {
// check, whether the order has changed
DataModel origChildAtPos = enOrig.next();
if (origChildAtPos != origChild) {
valueChanged = true;
}
}
}
if (valueChanged) {
// store the deleted instances
DataModelEnumeration en = getEnumeration();
while (en.hasMore()) {
DataModel model = en.next();
if (origChildren == null || origChildren.getCopy(model) == null) {
if (deleted == null) {
deleted = new DataModelVector();
}
deleted.append(model);
}