ReplaceablePropertyChangeListener[] localListeners = fListeners;
if (localListeners == null) {
return;
}
ReplaceablePropertyChangeListener target = null;
int i = 0; // so is accessible in catch phrase
if (trace) {
writeDebug(replaceIndent + getObjectIdString(this) + ".fireReplaceObject",
"old=" + getObjectIdString(oldObject) + ",new=" + getObjectIdString(newObject));
replaceIndent = replaceIndent + " ";
}
try {
ReplacementEvent evt = new ReplacementEvent(oldObject, newObject);
for (i = 0; i < localListeners.length; i++) {
target = localListeners[i];
if (trace) {
writeDebug(replaceIndent, getObjectIdString(target));
}
notifyEventMonitors(target, evt);
target.replaceObject(evt);
}
} catch (ReplacementVetoException ex) {
writeDebug(this,
"ReplacementVetoException trapped in replaceObject, from " +
target.toString());
try {
ReplacementEvent reverseEvt = new ReplacementEvent(newObject, oldObject);
for (int j = i - 1; j >= 0; j--) {
target = localListeners[j];
if (target != null) {
notifyEventMonitors(target, reverseEvt);
target.replaceObject(reverseEvt);
}
}
} catch (ReplacementVetoException ex2) {
// ignore it
}