// // Set a listener on the root //
MyListener l = new MyListener("Book listener", book);
book.addVetoableChangeListener(l); //GraphManager.debug(true);
setTest("simple change event on the root - no veto");
l.reset();
String s = "This book is about how to veto changes"; // Change a property on the root - this should raises an event
book.setSummary(s); // Check the received event
check(l.oldValue() == null, "(old value)");
check(l.newValue().equals(s), "(new value)");
check(book.getSummary().equals(s), "(new value)");
boolean gotException = false;
setTest("simple change event on the root - veto");
l.reset();
l.veto();
String s2 = "this is the new value";
s = book.getSummary(); try {
book.setSummary(s2);
} catch(PropertyVetoException ve) {
check(book.getSummary().equals(s), "(got exception & same value)");
gotException = true;
}
if (!gotException)
check(false, " didn't get the veto exception (1)!");
setTest("Try to listen for a non vetoable property");
gotException = false; try {
book.addVetoableChangeListener("Reviews", l);
} catch(Exception e) {
check(true, "got exception:\n" + e.getMessage());
gotException = true;
}
if (!gotException)
check(false, " didn't get the runtime exception (2)!");
setTest("Indexed final property");
l.reset();
String [] ss = {"Author1", "Author2", "Author3"};
l.printStringArray();
book.setAuthor(ss);
if (!gotException)
check(false, " didn't get the veto exception (4)!");
}
}
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.13Bemerkung:
(vorverarbeitet am 2026-10-03)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.