Search in sources :

Example 16 with BeanDescriptor

use of java.beans.BeanDescriptor in project yamcs-studio by yamcs.

the class DefaultWidgetIntrospector method getBeanInfo.

public BeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionException {
    Introspector.flushFromCaches(beanClass);
    BeanInfo bi = Introspector.getBeanInfo(beanClass);
    BeanDescriptor bd = bi.getBeanDescriptor();
    MethodDescriptor[] mds = bi.getMethodDescriptors();
    EventSetDescriptor[] esds = bi.getEventSetDescriptors();
    PropertyDescriptor[] pds = bi.getPropertyDescriptors();
    List<PropertyDescriptor> filteredPDList = new ArrayList<PropertyDescriptor>();
    List<String> nonPropList = Arrays.asList(getNonProperties());
    for (PropertyDescriptor pd : pds) {
        if (!nonPropList.contains(pd.getName()) && pd.getWriteMethod() != null && pd.getReadMethod() != null)
            filteredPDList.add(pd);
    }
    int defaultEvent = bi.getDefaultEventIndex();
    int defaultProperty = bi.getDefaultPropertyIndex();
    return new GenericBeanInfo(bd, esds, defaultEvent, filteredPDList.toArray(new PropertyDescriptor[filteredPDList.size()]), defaultProperty, mds, null);
}
Also used : PropertyDescriptor(java.beans.PropertyDescriptor) BeanInfo(java.beans.BeanInfo) ArrayList(java.util.ArrayList) MethodDescriptor(java.beans.MethodDescriptor) EventSetDescriptor(java.beans.EventSetDescriptor) BeanDescriptor(java.beans.BeanDescriptor)

Example 17 with BeanDescriptor

use of java.beans.BeanDescriptor in project j2objc by google.

the class FakeFox01BeanInfo method getBeanDescriptor.

@Override
public BeanDescriptor getBeanDescriptor() {
    BeanDescriptor beanDesc = new BeanDescriptor(clazz);
    beanDesc.setDisplayName(beanDesc.getDisplayName() + suffix);
    return beanDesc;
}
Also used : BeanDescriptor(java.beans.BeanDescriptor)

Example 18 with BeanDescriptor

use of java.beans.BeanDescriptor in project j2objc by google.

the class IntrospectorTest method testBeanDescriptor.

/**
     * The test checks the getBeanDescriptor method
     */
public void testBeanDescriptor() throws Exception {
    String[] oldBeanInfoSearchPath = Introspector.getBeanInfoSearchPath();
    try {
        Introspector.setBeanInfoSearchPath(new String[] { "java.beans.infos" });
        BeanInfo info = Introspector.getBeanInfo(SampleBean.class);
        assertNotNull(info);
        BeanDescriptor descriptor = info.getBeanDescriptor();
        assertNotNull(descriptor);
        assertEquals(SampleBean.class, descriptor.getBeanClass());
    } finally {
        Introspector.setBeanInfoSearchPath(oldBeanInfoSearchPath);
    }
}
Also used : BeanDescriptor(java.beans.BeanDescriptor) BeanInfo(java.beans.BeanInfo) SimpleBeanInfo(java.beans.SimpleBeanInfo) FakeFox01BeanInfo(org.apache.harmony.beans.tests.support.mock.FakeFox01BeanInfo)

Example 19 with BeanDescriptor

use of java.beans.BeanDescriptor in project j2objc by google.

the class IntrospectorTest method testGetBeanInfoSearchPath_Default.

public void testGetBeanInfoSearchPath_Default() throws IntrospectionException, ClassNotFoundException {
    BeanInfo info = Introspector.getBeanInfo(MockFooButton.class);
    PropertyDescriptor[] pds = info.getPropertyDescriptors();
    BeanDescriptor beanDesc;
    assertEquals(2, pds.length);
    assertEquals("class", pds[0].getName());
    beanDesc = info.getBeanDescriptor();
    assertEquals("MockFooButton", beanDesc.getName());
}
Also used : IndexedPropertyDescriptor(java.beans.IndexedPropertyDescriptor) PropertyDescriptor(java.beans.PropertyDescriptor) BeanDescriptor(java.beans.BeanDescriptor) BeanInfo(java.beans.BeanInfo) SimpleBeanInfo(java.beans.SimpleBeanInfo) FakeFox01BeanInfo(org.apache.harmony.beans.tests.support.mock.FakeFox01BeanInfo)

Example 20 with BeanDescriptor

use of java.beans.BeanDescriptor in project j2objc by google.

the class IntrospectorTest method testFlushFromCaches_Null.

public void testFlushFromCaches_Null() throws IntrospectionException {
    BeanInfo info = Introspector.getBeanInfo(MockJavaBean.class);
    BeanDescriptor beanDesc = new BeanDescriptor(MockJavaBean.class);
    assertEquals(beanDesc.getName(), info.getBeanDescriptor().getName());
    assertEquals(beanDesc.isExpert(), info.getBeanDescriptor().isExpert());
    try {
        Introspector.flushFromCaches(null);
        fail("Should throw NullPointerException.");
    } catch (NullPointerException e) {
    }
}
Also used : BeanDescriptor(java.beans.BeanDescriptor) BeanInfo(java.beans.BeanInfo) SimpleBeanInfo(java.beans.SimpleBeanInfo) FakeFox01BeanInfo(org.apache.harmony.beans.tests.support.mock.FakeFox01BeanInfo)

Aggregations

BeanDescriptor (java.beans.BeanDescriptor)25 BeanInfo (java.beans.BeanInfo)10 SimpleBeanInfo (java.beans.SimpleBeanInfo)8 FakeFox01BeanInfo (org.apache.harmony.beans.tests.support.mock.FakeFox01BeanInfo)8 PropertyDescriptor (java.beans.PropertyDescriptor)6 IndexedPropertyDescriptor (java.beans.IndexedPropertyDescriptor)5 MethodDescriptor (java.beans.MethodDescriptor)4 MockJavaBean (org.apache.harmony.beans.tests.support.mock.MockJavaBean)3 EventSetDescriptor (java.beans.EventSetDescriptor)2 IntrospectionException (java.beans.IntrospectionException)2 Method (java.lang.reflect.Method)2 ArrayList (java.util.ArrayList)2 KeyEvent (java.awt.event.KeyEvent)1 KeyListener (java.awt.event.KeyListener)1 FeatureDescriptor (java.beans.FeatureDescriptor)1 IndexedPropertyChangeEvent (java.beans.IndexedPropertyChangeEvent)1 ParameterDescriptor (java.beans.ParameterDescriptor)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 Enumeration (java.util.Enumeration)1 LinkedList (java.util.LinkedList)1