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);
}
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;
}
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);
}
}
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());
}
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) {
}
}
Aggregations