本文整理汇总了Java中java.beans.VetoableChangeSupport.getVetoableChangeListeners方法的典型用法代码示例。如果您正苦于以下问题:Java VetoableChangeSupport.getVetoableChangeListeners方法的具体用法?Java VetoableChangeSupport.getVetoableChangeListeners怎么用?Java VetoableChangeSupport.getVetoableChangeListeners使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.beans.VetoableChangeSupport
的用法示例。
在下文中一共展示了VetoableChangeSupport.getVetoableChangeListeners方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAddVetoableChangeListenerStringVetoableChangeListener_null
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
public void testAddVetoableChangeListenerStringVetoableChangeListener_null() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
String propertyName = "label";
support.addVetoableChangeListener(propertyName, null);
VetoableChangeListener[] listeners1 = support
.getVetoableChangeListeners();
VetoableChangeListener[] listeners2 = support
.getVetoableChangeListeners(propertyName);
assertFalse(support.hasListeners(propertyName));
assertFalse(support.hasListeners("text"));
assertEquals(0, listeners1.length);
assertEquals(0, listeners2.length);
}
示例2: testAddVetoableChangeListenerStringVetoableChangeListener_property_invalid
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
public void testAddVetoableChangeListenerStringVetoableChangeListener_property_invalid() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
String propertyName = "label_invalid";
support.addVetoableChangeListener(propertyName, proxy);
VetoableChangeListener[] listeners1 = support
.getVetoableChangeListeners();
VetoableChangeListener[] listeners2 = support
.getVetoableChangeListeners("label_invalid");
assertEquals(1, listeners1.length);
assertEquals(1, listeners2.length);
assertEquals("label_invalid",
((VetoableChangeListenerProxy) listeners1[0]).getPropertyName());
assertSame(proxy, listeners2[0]);
assertFalse(support.hasListeners("label"));
}
示例3: testAddVetoableChangeListenerVetoableChangeListener_null
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
public void testAddVetoableChangeListenerVetoableChangeListener_null() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
support.addVetoableChangeListener(null);
assertFalse(support.hasListeners("label"));
assertFalse(support.hasListeners("text"));
VetoableChangeListener[] listeners1 = support
.getVetoableChangeListeners();
VetoableChangeListener[] listeners2 = support
.getVetoableChangeListeners("label");
VetoableChangeListener[] listeners3 = support
.getVetoableChangeListeners("text");
assertEquals(0, listeners1.length);
assertEquals(0, listeners2.length);
assertEquals(0, listeners3.length);
}
示例4: testAddVetoableChangeListenerVetoableChangeListener_duplicate
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
public void testAddVetoableChangeListenerVetoableChangeListener_duplicate() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
support.addVetoableChangeListener(proxy);
support.addVetoableChangeListener(proxy);
assertTrue(support.hasListeners("label"));
assertTrue(support.hasListeners("text"));
VetoableChangeListener[] listeners1 = support
.getVetoableChangeListeners();
VetoableChangeListener[] listeners2 = support
.getVetoableChangeListeners("label");
VetoableChangeListener[] listeners3 = support
.getVetoableChangeListeners("text");
assertEquals(2, listeners1.length);
assertEquals(0, listeners2.length);
assertEquals(0, listeners3.length);
for (VetoableChangeListener element : listeners1) {
assertSame(proxy, element);
}
}
示例5: testAddVetoableChangeListenerByPropertyName
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
/**
* The test checks the method add() for property specified
*/
public void testAddVetoableChangeListenerByPropertyName() {
VetoableChangeSupport vcs = new VetoableChangeSupport("bean1");
VetoableChangeListener vcl = new VetoableChangeListener() {
public void vetoableChange(PropertyChangeEvent pce) {
}
};
vcs.addVetoableChangeListener("property1", vcl);
VetoableChangeListener[] vcls = vcs
.getVetoableChangeListeners("property1");
assertNotNull("Returned listeners is null.", vcls);
assertEquals(1, vcls.length);
assertEquals(vcl, vcls[0]);
}
示例6: testAddVetoableChangeListenerProxy
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
/**
* The test checks the method add() for VetoableChangeListenerProxy
*/
public void testAddVetoableChangeListenerProxy() {
VetoableChangeSupport vcs = new VetoableChangeSupport("bean1");
VetoableChangeListener vcl = new VetoableChangeListener() {
public void vetoableChange(PropertyChangeEvent pce) {
}
};
vcs.addVetoableChangeListener("property1", vcl);
VetoableChangeListener[] vcls = vcs.getVetoableChangeListeners();
assertNotNull("Returned listeners is null.", vcls);
assertEquals(1, vcls.length);
assertTrue("Listener is not of VetoableChangeListenerProxy type",
vcls[0] instanceof VetoableChangeListenerProxy);
assertEquals(vcl, ((VetoableChangeListenerProxy) vcls[0]).getListener());
assertEquals("property1", ((VetoableChangeListenerProxy) vcls[0])
.getPropertyName());
}
示例7: check
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
private static void check(VetoableChangeSupport vcs) {
VetoableChangeListener[] namedListeners = vcs.getVetoableChangeListeners(NAME);
check(namedListeners, 1);
check(namedListeners[0], 1);
VetoableChangeListener[] allListeners = vcs.getVetoableChangeListeners();
check(allListeners, 2);
check(allListeners[0], 0);
check(allListeners[1], 1, NAME);
}
示例8: testAddVetoableChangeListenerStringVetoableChangeListener
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
public void testAddVetoableChangeListenerStringVetoableChangeListener() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
String propertyName = "label";
support.addVetoableChangeListener(propertyName, proxy);
assertTrue(support.hasListeners(propertyName));
assertFalse(support.hasListeners("text"));
VetoableChangeListener[] listeners1 = support
.getVetoableChangeListeners();
VetoableChangeListener[] listeners2 = support
.getVetoableChangeListeners(propertyName);
VetoableChangeListener[] listeners3 = support
.getVetoableChangeListeners("text");
assertEquals(0, listeners3.length);
assertEquals(1, listeners1.length);
assertEquals(1, listeners2.length);
assertSame(proxy, listeners2[0]);
VetoableChangeListenerProxy wrappers = (VetoableChangeListenerProxy) listeners1[0];
assertSame(proxy, wrappers.getListener());
assertEquals(propertyName, wrappers.getPropertyName());
}
示例9: testAddVetoableChangeListenerStringVetoableChangeListener_property_duplicate
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
public void testAddVetoableChangeListenerStringVetoableChangeListener_property_duplicate() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
VetoableChangeListener proxy2 = EventHandler.create(
VetoableChangeListener.class, source, "setText");
String propertyName = "label";
support.addVetoableChangeListener(propertyName, proxy);
support.addVetoableChangeListener(propertyName, proxy2);
assertTrue(support.hasListeners(propertyName));
assertFalse(support.hasListeners("text"));
VetoableChangeListener[] listeners1 = support
.getVetoableChangeListeners();
VetoableChangeListener[] listeners2 = support
.getVetoableChangeListeners(propertyName);
VetoableChangeListener[] listeners3 = support
.getVetoableChangeListeners("text");
assertEquals(0, listeners3.length);
assertEquals(2, listeners1.length);
assertEquals(2, listeners2.length);
for (int i = 0; i < listeners2.length; i++) {
assertTrue((proxy == listeners2[i]) || (proxy2 == listeners2[i]));
VetoableChangeListenerProxy wrappers = (VetoableChangeListenerProxy) listeners1[i];
assertTrue((proxy == wrappers.getListener())
|| (proxy2 == wrappers.getListener()));
assertEquals(propertyName, wrappers.getPropertyName());
}
}
示例10: testAddVetoableChangeListenerVetoableChangeListener_TwoDifferent
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
public void testAddVetoableChangeListenerVetoableChangeListener_TwoDifferent() {
MockSource source = new MockSource();
VetoableChangeSupport support = new VetoableChangeSupport(source);
VetoableChangeListener proxy = EventHandler.create(
VetoableChangeListener.class, source, "setText");
VetoableChangeListener proxy2 = EventHandler.create(
VetoableChangeListener.class, source, "getText");
support.addVetoableChangeListener(proxy);
support.addVetoableChangeListener(proxy2);
assertTrue(support.hasListeners("label"));
assertTrue(support.hasListeners("text"));
VetoableChangeListener[] listeners1 = support
.getVetoableChangeListeners();
VetoableChangeListener[] listeners2 = support
.getVetoableChangeListeners("label");
VetoableChangeListener[] listeners3 = support
.getVetoableChangeListeners("text");
assertEquals(2, listeners1.length);
assertEquals(0, listeners2.length);
assertEquals(0, listeners3.length);
for (VetoableChangeListener element : listeners1) {
assertTrue((proxy == element) || (proxy2 == element));
}
}
示例11: testAddVetoableChangeListener
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
/**
* The test checks the method add() with no property specified
*/
public void testAddVetoableChangeListener() {
VetoableChangeSupport vcs = new VetoableChangeSupport("bean1");
VetoableChangeListener vcl = new VetoableChangeListener() {
public void vetoableChange(PropertyChangeEvent pce) {
}
};
vcs.addVetoableChangeListener(vcl);
VetoableChangeListener[] vcls = vcs.getVetoableChangeListeners();
assertNotNull("Returned listeners is null.", vcls);
assertEquals(1, vcls.length);
assertEquals(vcl, vcls[0]);
}
示例12: main
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
public static void main(String[] args) throws PropertyVetoException {
VetoableChangeSupport vcs = new VetoableChangeSupport(TestListeners.class);
vcs.addVetoableChangeListener(new TestListeners(0));
vcs.addVetoableChangeListener(NAME, new TestListeners(2));
vcs.addVetoableChangeListener(new TestListeners(1));
vcs.addVetoableChangeListener(NAME, new VetoableChangeListenerProxy(NAME, new TestListeners(3)));
current = 0;
vcs.fireVetoableChange(NAME, 0, 1);
if (current != 4)
throw new Error("Expected 4 listeners, but called " + current);
current = 0;
vcs.fireVetoableChange(NONE, 1, 0);
if (current != 2)
throw new Error("Expected 2 listeners, but called " + current);
VetoableChangeListener[] all = vcs.getVetoableChangeListeners();
if (all.length != 4)
throw new Error("Expected 4 listeners, but contained " + all.length);
VetoableChangeListener[] named = vcs.getVetoableChangeListeners(NAME);
if (named.length != 2)
throw new Error("Expected 2 named listeners, but contained " + named.length);
VetoableChangeListener[] other = vcs.getVetoableChangeListeners(NONE);
if (other.length != 0)
throw new Error("Expected 0 other listeners, but contained " + other.length);
vcs.removeVetoableChangeListener(new TestListeners(0));
vcs.removeVetoableChangeListener(new TestListeners(1));
vcs.removeVetoableChangeListener(NAME, new TestListeners(2));
vcs.removeVetoableChangeListener(NAME, new VetoableChangeListenerProxy(NAME, new TestListeners(3)));
all = vcs.getVetoableChangeListeners();
if (all.length != 0)
throw new Error("Expected 4 listeners, but contained " + all.length);
named = vcs.getVetoableChangeListeners(NAME);
if (named.length != 0)
throw new Error("Expected 2 named listeners, but contained " + named.length);
other = vcs.getVetoableChangeListeners(NONE);
if (other.length != 0)
throw new Error("Expected 0 other listeners, but contained " + other.length);
}
示例13: assertEqualsSerially
import java.beans.VetoableChangeSupport; //导入方法依赖的package包/类
public static void assertEqualsSerially(BeanContextChildSupport orig,
BeanContextChildSupport ser) {
// check peer
if (orig == orig.getBeanContextChildPeer()) {
assertSame(ser, ser.getBeanContextChildPeer());
} else {
assertSame(orig.getBeanContextChildPeer().getClass(), ser
.getBeanContextChildPeer().getClass());
if (orig.getBeanContextChildPeer() instanceof MockBeanContextChildDelegateS) {
MockBeanContextChildDelegateS origPeer = (MockBeanContextChildDelegateS) orig
.getBeanContextChildPeer();
MockBeanContextChildDelegateS serPeer = (MockBeanContextChildDelegateS) ser
.getBeanContextChildPeer();
assertEquals(origPeer.id, serPeer.id);
}
}
// check property change listeners
PropertyChangeSupport origPCS = (PropertyChangeSupport) Utils.getField(
orig, "pcSupport");
PropertyChangeSupport serPCS = (PropertyChangeSupport) Utils.getField(
ser, "pcSupport");
PropertyChangeListener origPCL[] = origPCS
.getPropertyChangeListeners("beanContext");
PropertyChangeListener serPCL[] = serPCS
.getPropertyChangeListeners("beanContext");
int i = 0, j = 0;
while (i < origPCL.length) {
if (origPCL[i] instanceof Serializable) {
assertSame(origPCL[i].getClass(), serPCL[j].getClass());
if (origPCL[i] instanceof MockPropertyChangeListenerS) {
assertEquals(((MockPropertyChangeListenerS) origPCL[i]).id,
((MockPropertyChangeListenerS) serPCL[j]).id);
}
i++;
j++;
} else {
i++;
}
}
assertEquals(serPCL.length, j);
// check vetoable change listeners
VetoableChangeSupport origVCS = (VetoableChangeSupport) Utils.getField(
orig, "vcSupport");
VetoableChangeSupport serVCS = (VetoableChangeSupport) Utils.getField(
ser, "vcSupport");
VetoableChangeListener origVCL[] = origVCS
.getVetoableChangeListeners("beanContext");
VetoableChangeListener serVCL[] = serVCS
.getVetoableChangeListeners("beanContext");
i = 0;
j = 0;
while (i < origVCL.length) {
if (origVCL[i] instanceof Serializable) {
assertSame(origVCL[i].getClass(), serVCL[j].getClass());
if (origVCL[i] instanceof MockVetoableChangeListenerS) {
assertEquals(((MockVetoableChangeListenerS) origVCL[i]).id,
((MockVetoableChangeListenerS) serVCL[j]).id);
}
i++;
j++;
} else {
i++;
}
}
assertEquals(serVCL.length, j);
}