java.beans.EventSetDescriptor Java Examples
The following examples show how to use
java.beans.EventSetDescriptor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EventSetDescriptorTest.java From j2objc with Apache License 2.0 | 6 votes |
public void testEventSetDescriptorClassStringClassString_EventEmpty() throws IntrospectionException { String eventSetName = "mockPropertyChange"; String listenerMethodName = eventSetName; Class<MockSourceClass> sourceClass = MockSourceClass.class; Class<?> listenerType = MockPropertyChangeListener.class; try { // RI doesn't throw exception here but this doesn't really make // much sense. Moreover, it is against the java.beans // package description: null values or empty Strings are not // valid parameters unless explicitly stated new EventSetDescriptor(sourceClass, "", listenerType, listenerMethodName); } catch (IntrospectionException e) { // valid } }
Example #2
Source File: EventSetDescriptorTest.java From j2objc with Apache License 2.0 | 6 votes |
public void testEventSetDescriptorClassStringClassStringArrayStringString_sourceClassNull() throws IntrospectionException { Class<?> sourceClass = null; String eventSetName = "MockPropertyChange"; Class<?> listenerType = MockPropertyChangeListener.class; String[] listenerMethodNames = { "mockPropertyChange", "mockPropertyChange2", }; String addMethod = "addMockPropertyChangeListener"; String removeMethod = "removeMockPropertyChangeListener"; try { new EventSetDescriptor(sourceClass, eventSetName, listenerType, listenerMethodNames, addMethod, removeMethod); fail("Should throw NullPointerException."); } catch (NullPointerException e) { } }
Example #3
Source File: EventSetDescriptorTest.java From j2objc with Apache License 2.0 | 6 votes |
public void testSetUnicast_false() throws SecurityException, NoSuchMethodException, IntrospectionException { String eventSetName = "MockPropertyChange"; Class<?> listenerType = MockPropertyChangeListener.class; Method[] listenerMethods = { listenerType.getMethod("mockPropertyChange", MockPropertyChangeEvent.class), listenerType.getMethod("mockPropertyChange2", MockPropertyChangeEvent.class) }; MethodDescriptor[] listenerMethodDescriptors = { new MethodDescriptor(listenerMethods[0]), new MethodDescriptor(listenerMethods[1]), }; Class<MockSourceClass> sourceClass = MockSourceClass.class; Method addMethod = sourceClass.getMethod( "addMockPropertyChangeListener",listenerType); Method removeMethod = sourceClass.getMethod( "removeMockPropertyChangeListener", listenerType); EventSetDescriptor esd = new EventSetDescriptor(eventSetName, listenerType, listenerMethodDescriptors, addMethod, removeMethod); assertFalse(esd.isUnicast()); esd.setInDefaultEventSet(false); assertFalse(esd.isInDefaultEventSet()); }
Example #4
Source File: Test6311051.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws IntrospectionException, NoSuchMethodException { EventSetDescriptor esd = new EventSetDescriptor( "foo", FooListener.class, new Method[] { FooListener.class.getMethod("fooHappened", EventObject.class), FooListener.class.getMethod("moreFooHappened", EventObject.class, Object.class), FooListener.class.getMethod("lessFooHappened"), }, Bean.class.getMethod("addFooListener", FooListener.class), Bean.class.getMethod("removeFooListener", FooListener.class) ); System.gc(); for (Method method : esd.getListenerMethods()) { System.out.println(method); } }
Example #5
Source File: Test6311051.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws IntrospectionException, NoSuchMethodException { EventSetDescriptor esd = new EventSetDescriptor( "foo", FooListener.class, new Method[] { FooListener.class.getMethod("fooHappened", EventObject.class), FooListener.class.getMethod("moreFooHappened", EventObject.class, Object.class), FooListener.class.getMethod("lessFooHappened"), }, Bean.class.getMethod("addFooListener", FooListener.class), Bean.class.getMethod("removeFooListener", FooListener.class) ); System.gc(); for (Method method : esd.getListenerMethods()) { System.out.println(method); } }
Example #6
Source File: Test6976577.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { Class<?> bt = Accessor.getBeanType(); Class<?> lt = Accessor.getListenerType(); // test PropertyDescriptor PropertyDescriptor pd = new PropertyDescriptor("boolean", bt); test(pd.getReadMethod()); test(pd.getWriteMethod()); // test IndexedPropertyDescriptor IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor("indexed", bt); test(ipd.getReadMethod()); test(ipd.getWriteMethod()); test(ipd.getIndexedReadMethod()); test(ipd.getIndexedWriteMethod()); // test EventSetDescriptor EventSetDescriptor esd = new EventSetDescriptor(bt, "test", lt, "process"); test(esd.getAddListenerMethod()); test(esd.getRemoveListenerMethod()); test(esd.getGetListenerMethod()); test(esd.getListenerMethods()); }
Example #7
Source File: Test6311051.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws IntrospectionException, NoSuchMethodException { EventSetDescriptor esd = new EventSetDescriptor( "foo", FooListener.class, new Method[] { FooListener.class.getMethod("fooHappened", EventObject.class), FooListener.class.getMethod("moreFooHappened", EventObject.class, Object.class), FooListener.class.getMethod("lessFooHappened"), }, Bean.class.getMethod("addFooListener", FooListener.class), Bean.class.getMethod("removeFooListener", FooListener.class) ); System.gc(); for (Method method : esd.getListenerMethods()) { System.out.println(method); } }
Example #8
Source File: EventSetDescriptorTest.java From j2objc with Apache License 2.0 | 6 votes |
public void testEventSetDescriptorClassStringClassStringArrayStringStringString_getListenerMethodNameNull() throws IntrospectionException { Class<MockSourceClass> sourceClass = MockSourceClass.class; String eventSetName = "MockPropertyChange"; Class<?> listenerType = MockPropertyChangeListener.class; String[] listenerMethodNames = { "mockPropertyChange", "mockPropertyChange2", }; String addMethod = "addMockPropertyChangeListener"; String removeMethod = "removeMockPropertyChangeListener"; String getMethod = null; EventSetDescriptor esd = new EventSetDescriptor(sourceClass, eventSetName, listenerType, listenerMethodNames, addMethod, removeMethod, getMethod); assertNull(esd.getGetListenerMethod()); //Regression for Harmony-1504 try { new EventSetDescriptor(sourceClass, eventSetName, listenerType, null, addMethod, removeMethod, getMethod); fail("NullPointerException expected"); } catch (NullPointerException e) { //expected } }
Example #9
Source File: Test6311051.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws IntrospectionException, NoSuchMethodException { EventSetDescriptor esd = new EventSetDescriptor( "foo", FooListener.class, new Method[] { FooListener.class.getMethod("fooHappened", EventObject.class), FooListener.class.getMethod("moreFooHappened", EventObject.class, Object.class), FooListener.class.getMethod("lessFooHappened"), }, Bean.class.getMethod("addFooListener", FooListener.class), Bean.class.getMethod("removeFooListener", FooListener.class) ); System.gc(); for (Method method : esd.getListenerMethods()) { System.out.println(method); } }
Example #10
Source File: Test6311051.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws IntrospectionException, NoSuchMethodException { EventSetDescriptor esd = new EventSetDescriptor( "foo", FooListener.class, new Method[] { FooListener.class.getMethod("fooHappened", EventObject.class), FooListener.class.getMethod("moreFooHappened", EventObject.class, Object.class), FooListener.class.getMethod("lessFooHappened"), }, Bean.class.getMethod("addFooListener", FooListener.class), Bean.class.getMethod("removeFooListener", FooListener.class) ); System.gc(); for (Method method : esd.getListenerMethods()) { System.out.println(method); } }
Example #11
Source File: Test6976577.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { Class<?> bt = Accessor.getBeanType(); Class<?> lt = Accessor.getListenerType(); // test PropertyDescriptor PropertyDescriptor pd = new PropertyDescriptor("boolean", bt); test(pd.getReadMethod()); test(pd.getWriteMethod()); // test IndexedPropertyDescriptor IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor("indexed", bt); test(ipd.getReadMethod()); test(ipd.getWriteMethod()); test(ipd.getIndexedReadMethod()); test(ipd.getIndexedWriteMethod()); // test EventSetDescriptor EventSetDescriptor esd = new EventSetDescriptor(bt, "test", lt, "process"); test(esd.getAddListenerMethod()); test(esd.getRemoveListenerMethod()); test(esd.getGetListenerMethod()); test(esd.getListenerMethods()); }
Example #12
Source File: Test6976577.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { Class<?> bt = Accessor.getBeanType(); Class<?> lt = Accessor.getListenerType(); // test PropertyDescriptor PropertyDescriptor pd = new PropertyDescriptor("boolean", bt); test(pd.getReadMethod()); test(pd.getWriteMethod()); // test IndexedPropertyDescriptor IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor("indexed", bt); test(ipd.getReadMethod()); test(ipd.getWriteMethod()); test(ipd.getIndexedReadMethod()); test(ipd.getIndexedWriteMethod()); // test EventSetDescriptor EventSetDescriptor esd = new EventSetDescriptor(bt, "test", lt, "process"); test(esd.getAddListenerMethod()); test(esd.getRemoveListenerMethod()); test(esd.getGetListenerMethod()); test(esd.getListenerMethods()); }
Example #13
Source File: EventSetDescriptorTest.java From j2objc with Apache License 2.0 | 6 votes |
public void testEventSetDescriptorStringClassMethodArrayMethodMethod_removeListenerMethodInvalid() throws IntrospectionException, NoSuchMethodException { String eventSetName = "MockPropertyChange"; Class<?> listenerType = MockPropertyChangeListener.class; Method[] listenerMethods = new Method[] { listenerType.getMethod("mockPropertyChange", new Class[] { MockPropertyChangeEvent.class }), listenerType.getMethod("mockPropertyChange2", new Class[] { MockPropertyChangeEvent.class }), }; Class<MockSourceClass> sourceClass = MockSourceClass.class; Method addMethod = sourceClass.getMethod( "addMockPropertyChangeListener", new Class[] { listenerType }); Method removeMethod = sourceClass.getMethod( "addMockPropertyChangeListener_Invalid", (Class[]) null); EventSetDescriptor esd = new EventSetDescriptor(eventSetName, listenerType, listenerMethods, addMethod, removeMethod); assertEquals(removeMethod, esd.getRemoveListenerMethod()); }
Example #14
Source File: EventSetDescriptorTest.java From j2objc with Apache License 2.0 | 6 votes |
public void testEventSetDescriptorStringClassMethodDescriptorArrayMethodMethod_ListenerMDNull() throws IntrospectionException, NoSuchMethodException { String eventSetName = "MockPropertyChange"; Class<?> listenerType = MockPropertyChangeListener.class; Class<MockSourceClass> sourceClass = MockSourceClass.class; Method addMethod = sourceClass.getMethod( "addMockPropertyChangeListener", listenerType); Method removeMethod = sourceClass.getMethod( "removeMockPropertyChangeListener", listenerType); EventSetDescriptor esd = new EventSetDescriptor(eventSetName, listenerType, (MethodDescriptor[]) null, addMethod, removeMethod); assertNull(esd.getListenerMethodDescriptors()); assertNull(esd.getListenerMethods()); }
Example #15
Source File: Test6311051.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws IntrospectionException, NoSuchMethodException { EventSetDescriptor esd = new EventSetDescriptor( "foo", FooListener.class, new Method[] { FooListener.class.getMethod("fooHappened", EventObject.class), FooListener.class.getMethod("moreFooHappened", EventObject.class, Object.class), FooListener.class.getMethod("lessFooHappened"), }, Bean.class.getMethod("addFooListener", FooListener.class), Bean.class.getMethod("removeFooListener", FooListener.class) ); System.gc(); for (Method method : esd.getListenerMethods()) { System.out.println(method); } }
Example #16
Source File: Test6976577.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { Class<?> bt = Accessor.getBeanType(); Class<?> lt = Accessor.getListenerType(); // test PropertyDescriptor PropertyDescriptor pd = new PropertyDescriptor("boolean", bt); test(pd.getReadMethod()); test(pd.getWriteMethod()); // test IndexedPropertyDescriptor IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor("indexed", bt); test(ipd.getReadMethod()); test(ipd.getWriteMethod()); test(ipd.getIndexedReadMethod()); test(ipd.getIndexedWriteMethod()); // test EventSetDescriptor EventSetDescriptor esd = new EventSetDescriptor(bt, "test", lt, "process"); test(esd.getAddListenerMethod()); test(esd.getRemoveListenerMethod()); test(esd.getGetListenerMethod()); test(esd.getListenerMethods()); }
Example #17
Source File: EventSetDescriptorTest.java From j2objc with Apache License 2.0 | 6 votes |
public void testEventSetDescriptorStringClassMethodArrayMethodMethod_listenerMethodsNull() throws IntrospectionException, NoSuchMethodException { String eventSetName = "MockPropertyChange"; Class<?> listenerType = MockPropertyChangeListener.class; Class<MockSourceClass> sourceClass = MockSourceClass.class; Method addMethod = sourceClass.getMethod( "addMockPropertyChangeListener", listenerType); Method removeMethod = sourceClass.getMethod( "removeMockPropertyChangeListener", listenerType); EventSetDescriptor esd = new EventSetDescriptor(eventSetName, listenerType, (Method[]) null, addMethod, removeMethod); assertEquals(addMethod, esd.getAddListenerMethod()); assertEquals(removeMethod, esd.getRemoveListenerMethod()); assertNull(esd.getGetListenerMethod()); assertNull(esd.getListenerMethods()); assertNull(esd.getListenerMethodDescriptors()); assertEquals(listenerType, esd.getListenerType()); assertTrue(esd.isInDefaultEventSet()); assertFalse(esd.isUnicast()); }
Example #18
Source File: EventSetDescriptorTest.java From j2objc with Apache License 2.0 | 6 votes |
public void testEventSetDescriptorClassStringClassString2() throws IntrospectionException, ClassNotFoundException, IOException, SecurityException, NoSuchMethodException { String eventSetName = "mockPropertyChange"; String listenerMethodName = eventSetName; Class<MockSourceClass> sourceClass = MockSourceClass.class; Class<?> listenerType = MockPropertyChangeListener.class; try { new EventSetDescriptor(sourceClass, "FFF", listenerType, listenerMethodName); fail("Should throw IntrospectionException."); } catch (IntrospectionException e) { // valid } }
Example #19
Source File: Test6976577.java From hottub with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { Class<?> bt = Accessor.getBeanType(); Class<?> lt = Accessor.getListenerType(); // test PropertyDescriptor PropertyDescriptor pd = new PropertyDescriptor("boolean", bt); test(pd.getReadMethod()); test(pd.getWriteMethod()); // test IndexedPropertyDescriptor IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor("indexed", bt); test(ipd.getReadMethod()); test(ipd.getWriteMethod()); test(ipd.getIndexedReadMethod()); test(ipd.getIndexedWriteMethod()); // test EventSetDescriptor EventSetDescriptor esd = new EventSetDescriptor(bt, "test", lt, "process"); test(esd.getAddListenerMethod()); test(esd.getRemoveListenerMethod()); test(esd.getGetListenerMethod()); test(esd.getListenerMethods()); }
Example #20
Source File: Test6976577.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { Class<?> bt = Accessor.getBeanType(); Class<?> lt = Accessor.getListenerType(); // test PropertyDescriptor PropertyDescriptor pd = new PropertyDescriptor("boolean", bt); test(pd.getReadMethod()); test(pd.getWriteMethod()); // test IndexedPropertyDescriptor IndexedPropertyDescriptor ipd = new IndexedPropertyDescriptor("indexed", bt); test(ipd.getReadMethod()); test(ipd.getWriteMethod()); test(ipd.getIndexedReadMethod()); test(ipd.getIndexedWriteMethod()); // test EventSetDescriptor EventSetDescriptor esd = new EventSetDescriptor(bt, "test", lt, "process"); test(esd.getAddListenerMethod()); test(esd.getRemoveListenerMethod()); test(esd.getGetListenerMethod()); test(esd.getListenerMethods()); }
Example #21
Source File: Test8005065.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static void testEventSetDescriptor() { try { MethodDescriptor[] array = { new MethodDescriptor(MyDPD.class.getMethod("getArray")) }; EventSetDescriptor descriptor = new EventSetDescriptor(null, null, array, null, null); test(descriptor.getListenerMethodDescriptors()); array[0] = null; test(descriptor.getListenerMethodDescriptors()); descriptor.getListenerMethodDescriptors()[0] = null; test(descriptor.getListenerMethodDescriptors()); } catch (Exception exception) { throw new Error("unexpected error", exception); } }
Example #22
Source File: Test8005065.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void testEventSetDescriptor() { try { MethodDescriptor[] array = { new MethodDescriptor(MyDPD.class.getMethod("getArray")) }; EventSetDescriptor descriptor = new EventSetDescriptor(null, null, array, null, null); test(descriptor.getListenerMethodDescriptors()); array[0] = null; test(descriptor.getListenerMethodDescriptors()); descriptor.getListenerMethodDescriptors()[0] = null; test(descriptor.getListenerMethodDescriptors()); } catch (Exception exception) { throw new Error("unexpected error", exception); } }
Example #23
Source File: EventSetDescriptorTest.java From j2objc with Apache License 2.0 | 5 votes |
public void testEventSetDescriptorClassStringClassStringArrayStringString_addListenerMethodNameNull() throws IntrospectionException { Class<MockSourceClass> sourceClass = MockSourceClass.class; String eventSetName = "MockPropertyChange"; Class<?> listenerType = MockPropertyChangeListener.class; String[] listenerMethodNames = { "mockPropertyChange", "mockPropertyChange2", }; String addMethod = null; String removeMethod = "removeMockPropertyChangeListener"; EventSetDescriptor esd = new EventSetDescriptor(sourceClass, eventSetName, listenerType, listenerMethodNames, addMethod, removeMethod); assertNull(esd.getAddListenerMethod()); }
Example #24
Source File: Test8005065.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static void testEventSetDescriptor() { try { MethodDescriptor[] array = { new MethodDescriptor(MyDPD.class.getMethod("getArray")) }; EventSetDescriptor descriptor = new EventSetDescriptor(null, null, array, null, null); test(descriptor.getListenerMethodDescriptors()); array[0] = null; test(descriptor.getListenerMethodDescriptors()); descriptor.getListenerMethodDescriptors()[0] = null; test(descriptor.getListenerMethodDescriptors()); } catch (Exception exception) { throw new Error("unexpected error", exception); } }
Example #25
Source File: EventSetDescriptorTest.java From j2objc with Apache License 2.0 | 5 votes |
public void testEventSetDescriptorClassStringClassStringArrayStringString_listenerMethodNamesInvalid() { Class<MockSourceClass> sourceClass = MockSourceClass.class; String eventSetName = "MockPropertyChange"; Class<?> listenerType = MockPropertyChangeListener.class; String[] listenerMethodNames = { "mockPropertyChange_Invalid", "mockPropertyChange2", }; String addMethod = "addMockPropertyChangeListener"; String removeMethod = "removeMockPropertyChangeListener"; try { new EventSetDescriptor(sourceClass, eventSetName, listenerType, listenerMethodNames, addMethod, removeMethod); fail("Should throw IntrospectionException."); } catch (IntrospectionException e) { } }
Example #26
Source File: AbstractResource.java From gate-core with GNU Lesser General Public License v3.0 | 5 votes |
/** * Adds listeners to a resource. * @param listeners The listeners to be registered with the resource. A * {@link java.util.Map} that maps from fully qualified class name (as a * string) to listener (of the type declared by the key). * @param resource the resource that listeners will be registered to. */ public static void setResourceListeners(Resource resource, Map<String, ? extends Object> listeners) throws IntrospectionException, InvocationTargetException, IllegalAccessException, GateException { // get the beaninfo for the resource bean, excluding data about Object BeanInfo resBeanInfo = getBeanInfo(resource.getClass()); // get all the events the bean can fire EventSetDescriptor[] events = resBeanInfo.getEventSetDescriptors(); // add the listeners if (events != null) { EventSetDescriptor event; for(int i = 0; i < events.length; i++) { event = events[i]; // did we get such a listener? Object listener = listeners.get(event.getListenerType().getName()); if(listener != null) { Method addListener = event.getAddListenerMethod(); // call the set method with the parameter value Object[] args = new Object[1]; args[0] = listener; addListener.invoke(resource, args); } } // for each event } // if events != null }
Example #27
Source File: BeanUtils.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Reports all the interesting information in an EventSetDescriptor */ public static void reportEventSetDescriptor(EventSetDescriptor esd) { System.out.println("event set name: " + esd.getName()); System.out.println(" listener type: " + esd.getListenerType()); System.out.println(" method get: " + esd.getGetListenerMethod()); System.out.println(" method add: " + esd.getAddListenerMethod()); System.out.println(" method remove: " + esd.getRemoveListenerMethod()); }
Example #28
Source File: BeanUtils.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns an array of event set descriptors for specified class. * * @param type the class to introspect * @return an array of event set descriptors */ public static EventSetDescriptor[] getEventSetDescriptors(Class type) { try { return Introspector.getBeanInfo(type).getEventSetDescriptors(); } catch (IntrospectionException exception) { throw new Error("unexpected exception", exception); } }
Example #29
Source File: BeanUtils.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns an array of event set descriptors for specified class. * * @param type the class to introspect * @return an array of event set descriptors */ public static EventSetDescriptor[] getEventSetDescriptors(Class type) { try { return Introspector.getBeanInfo(type).getEventSetDescriptors(); } catch (IntrospectionException exception) { throw new Error("unexpected exception", exception); } }
Example #30
Source File: BeanUtils.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Returns an array of event set descriptors for specified class. * * @param type the class to introspect * @return an array of event set descriptors */ public static EventSetDescriptor[] getEventSetDescriptors(Class type) { try { return Introspector.getBeanInfo(type).getEventSetDescriptors(); } catch (IntrospectionException exception) { throw new Error("unexpected exception", exception); } }