类java.beans.BeanDescriptor源码实例Demo

下面列出了怎么用java.beans.BeanDescriptor的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: j2objc   文件: BeanDescriptorTest.java
public void testBeanDescriptorClassClass_CustomizerClassNull() {
    String beanName = "BeanDescriptorTest.bean";
    MockJavaBean bean = new MockJavaBean(beanName);
    Class<? extends MockJavaBean> beanClass = bean.getClass();
    Class<?> cusClass = null;
    BeanDescriptor bd = new BeanDescriptor(beanClass, cusClass);

    assertSame(beanClass, bd.getBeanClass());
    assertNull(bd.getCustomizerClass());

    String displayName = beanClass.getName().substring(
            beanClass.getName().lastIndexOf('.') + 1);
    assertEquals(displayName, bd.getDisplayName());
    assertEquals(displayName, bd.getName());
    assertEquals(displayName, bd.getShortDescription());

    assertNotNull(bd.attributeNames());
    assertFalse(bd.isExpert());
    assertFalse(bd.isHidden());
    assertFalse(bd.isPreferred());
}
 
源代码2 项目: j2objc   文件: BeanDescriptorTest.java
public void testBeanDescriptorClass() {
    String beanName = "BeanDescriptorTest.bean";
    MockJavaBean bean = new MockJavaBean(beanName);
    Class<? extends MockJavaBean> beanClass = bean.getClass();
    BeanDescriptor bd = new BeanDescriptor(beanClass);

    assertSame(beanClass, bd.getBeanClass());
    String displayName = beanClass.getName().substring(
            beanClass.getName().lastIndexOf('.') + 1);
    assertEquals(displayName, bd.getDisplayName());
    assertEquals(displayName, bd.getName());
    assertEquals(displayName, bd.getShortDescription());

    assertNotNull(bd.attributeNames());
    assertFalse(bd.isExpert());
    assertFalse(bd.isHidden());
    assertFalse(bd.isPreferred());
}
 
源代码3 项目: netbeans   文件: ModelProperty.java
private static String findDisplayNameFor(Object o) {
    try {
        if (o == null) {
            return null;
        }

        if (o instanceof Node.Property) {
            return ((Node.Property) o).getDisplayName();
        }

        BeanInfo bi = Introspector.getBeanInfo(o.getClass());

        if (bi != null) {
            BeanDescriptor bd = bi.getBeanDescriptor();

            if (bd != null) {
                return bd.getDisplayName();
            }
        }
    } catch (Exception e) {
        //okay, we did our best
    }

    return null;
}
 
源代码4 项目: netbeans   文件: BeanNode.java
/**
* Returns name of the bean.
*/
private String getNameForBean() {
    if (nameGetter != null) {
        try {
            String name = (String) nameGetter.invoke(bean);

            return (name != null) ? name : ""; // NOI18N
        } catch (Exception ex) {
            NodeOp.warning(ex);
        }
    }

    BeanDescriptor descriptor = beanInfo.getBeanDescriptor();

    return descriptor.getDisplayName();
}
 
源代码5 项目: dragonwell8_jdk   文件: BeanUtils.java
/**
 * Returns a bean descriptor for specified class.
 *
 * @param type  the class to introspect
 * @return a bean descriptor
 */
public static BeanDescriptor getBeanDescriptor(Class type) {
    try {
        return Introspector.getBeanInfo(type).getBeanDescriptor();
    } catch (IntrospectionException exception) {
        throw new Error("unexpected exception", exception);
    }
}
 
源代码6 项目: jdk8u-dev-jdk   文件: BeanUtils.java
/**
 * Returns a bean descriptor for specified class.
 *
 * @param type  the class to introspect
 * @return a bean descriptor
 */
public static BeanDescriptor getBeanDescriptor(Class type) {
    try {
        return Introspector.getBeanInfo(type).getBeanDescriptor();
    } catch (IntrospectionException exception) {
        throw new Error("unexpected exception", exception);
    }
}
 
源代码7 项目: j2objc   文件: BeanDescriptorTest.java
/**
 * @tests java.beans.BeanDescriptor#BeanDescriptor( java.lang.Class,
 *        java.lang.Class)
 */
public void test_Ctor2_NullPointerException() {
    try {
        // Regression for HARMONY-225
        new BeanDescriptor(null, String.class);
        fail("No expected NullPointerException");
    } catch (NullPointerException e) {
    }
}
 
源代码8 项目: openjdk-jdk9   文件: TestBeanInfoPriority.java
@Override
public BeanDescriptor getBeanDescriptor() {

    BeanDescriptor bd = new BeanDescriptor(TestClass.class, null);
    bd.setShortDescription("user-defined-description");
    bd.setValue("isContainer", true);
    bd.setValue("containerDelegate", "user-defined-delegate");

    return bd;
}
 
源代码9 项目: Openfire   文件: JiveBeanInfo.java
@Override
public BeanDescriptor getBeanDescriptor() {
    BeanDescriptor descriptor = new BeanDescriptor(getBeanClass());
    try {
        // Attempt to load the displayName and shortDescription explicitly.
        String displayName = bundle.getString("displayName");
        if (displayName != null) {
            descriptor.setDisplayName(displayName);
        }
        String shortDescription = bundle.getString("shortDescription");
        if (shortDescription != null) {
            descriptor.setShortDescription(shortDescription);
        }
        // Add any other properties that are specified.
        Enumeration enumeration = bundle.getKeys();
        while (enumeration.hasMoreElements()) {
            String key = (String)enumeration.nextElement();
            String value = bundle.getString(key);
            if (value != null) {
                descriptor.setValue(key, value);
            }
        }
    }
    catch (Exception e) {
        // Ignore any exceptions. We may get some if we try to load a
        // a property that doesn't appear in the resource bundle.
    }
    return descriptor;
}
 
源代码10 项目: j2objc   文件: IntrospectorTest.java
public void testSetBeanInfoSearchPath_SameClassesInDifferentPackage()
        throws IntrospectionException {
    // set the search path in the correct sequence
    Introspector
            .setBeanInfoSearchPath(new String[] {
                    "org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.info",
                    "org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject2.info", });

    BeanInfo beanInfo = Introspector
            .getBeanInfo(org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.MockHomonymySubject.class);
    BeanDescriptor beanDesc = beanInfo.getBeanDescriptor();

    assertEquals(beanDesc.getName(), "mocksubject1");
    assertEquals(
            beanDesc.getBeanClass(),
            org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.MockHomonymySubject.class);

    // set the search path in the reverse sequence
    Introspector
            .setBeanInfoSearchPath(new String[] {
                    "org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject2.info",
                    "org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.info", });

    beanInfo = Introspector
            .getBeanInfo(org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.MockHomonymySubject.class);
    beanDesc = beanInfo.getBeanDescriptor();

    assertEquals(beanDesc.getName(), "mocksubject1");
    assertEquals(
            beanDesc.getBeanClass(),
            org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.MockHomonymySubject.class);

}
 
源代码11 项目: j2objc   文件: BeanDescriptorTest.java
public void testBeanDescriptorClass_Null() {
    try {
        new BeanDescriptor(null);
        fail("Should throw NullPointerException.");
    } catch (NullPointerException e) {
    }
}
 
源代码12 项目: j2objc   文件: IntrospectorTest.java
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());
}
 
源代码13 项目: jdk8u-jdk   文件: BeanUtils.java
/**
 * Returns a bean descriptor for specified class.
 *
 * @param type  the class to introspect
 * @return a bean descriptor
 */
public static BeanDescriptor getBeanDescriptor(Class type) {
    try {
        return Introspector.getBeanInfo(type).getBeanDescriptor();
    } catch (IntrospectionException exception) {
        throw new Error("unexpected exception", exception);
    }
}
 
源代码14 项目: openjdk-8   文件: BeanUtils.java
/**
 * Returns a bean descriptor for specified class.
 *
 * @param type  the class to introspect
 * @return a bean descriptor
 */
public static BeanDescriptor getBeanDescriptor(Class type) {
    try {
        return Introspector.getBeanInfo(type).getBeanDescriptor();
    } catch (IntrospectionException exception) {
        throw new Error("unexpected exception", exception);
    }
}
 
源代码15 项目: netbeans   文件: SerialDataNode.java
private Sheet.Set createPropertiesSet(BeanNode.Descriptor descr, BeanDescriptor bd) {
    Sheet.Set props;
    props = Sheet.createPropertiesSet();
    if (descr.property != null) {
        convertProps (props, descr.property, this);
    }
    if (bd != null) {
        // #29550: help from the beaninfo on property tabs
        Object helpID = bd.getValue("propertiesHelpID"); // NOI18N
        if (helpID != null && helpID instanceof String) {
            props.setValue("helpID", helpID); // NOI18N
        }
    }
    return props;
}
 
源代码16 项目: netbeans   文件: MicrosoftEdgeBrowserBeanInfo.java
@Override
   public BeanDescriptor getBeanDescriptor() {
       BeanDescriptor descr = new BeanDescriptor(MicrosoftEdgeBrowser.class);
       descr.setDisplayName(NbBundle.getMessage(MicrosoftEdgeBrowserBeanInfo.class, "CTL_MicrosoftEdgeBrowserName")); // NOI18N
       descr.setShortDescription(NbBundle.getMessage(MicrosoftEdgeBrowserBeanInfo.class, "HINT_MicrosoftEdgeBrowserName")); // NOI18N
       descr.setValue ("helpID", "org.netbeans.modules.extbrowser.ExtWebBrowser");  // NOI18N
return descr;
   }
 
源代码17 项目: dragonwell8_jdk   文件: BeanInfoFinder.java
@Override
protected BeanInfo instantiate(Class<?> type, String prefix, String name) {
    if (DEFAULT.equals(prefix)) {
        prefix = DEFAULT_NEW;
    }
    // this optimization will only use the BeanInfo search path
    // if is has changed from the original
    // or trying to get the ComponentBeanInfo
    BeanInfo info = !DEFAULT_NEW.equals(prefix) || "ComponentBeanInfo".equals(name)
            ? super.instantiate(type, prefix, name)
            : null;

    if (info != null) {
        // make sure that the returned BeanInfo matches the class
        BeanDescriptor bd = info.getBeanDescriptor();
        if (bd != null) {
            if (type.equals(bd.getBeanClass())) {
                return info;
            }
        }
        else {
            PropertyDescriptor[] pds = info.getPropertyDescriptors();
            if (pds != null) {
                for (PropertyDescriptor pd : pds) {
                    Method method = pd.getReadMethod();
                    if (method == null) {
                        method = pd.getWriteMethod();
                    }
                    if (isValid(type, method)) {
                        return info;
                    }
                }
            }
            else {
                MethodDescriptor[] mds = info.getMethodDescriptors();
                if (mds != null) {
                    for (MethodDescriptor md : mds) {
                        if (isValid(type, md.getMethod())) {
                            return info;
                        }
                    }
                }
            }
        }
    }
    return null;
}
 
源代码18 项目: jdk8u-jdk   文件: ComponentBeanInfo.java
public BeanDescriptor getBeanDescriptor() {
    BeanDescriptor bd = new BeanDescriptor(Component.class);
    // set a value to ensure that it's unique
    bd.setValue("test", Boolean.TRUE);
    return bd;
}
 
源代码19 项目: openjdk-8   文件: FooBarBeanInfo.java
public BeanDescriptor getBeanDescriptor() {
    BeanDescriptor bd = new BeanDescriptor(FooBar.class);
    // set a value to ensure that it's unique
    bd.setValue("test", Boolean.TRUE);
    return bd;
}
 
源代码20 项目: talent-aio   文件: MsgTextAreaJPopupMenuBeanInfo.java
private static BeanDescriptor getBdescriptor(){
BeanDescriptor beanDescriptor = new BeanDescriptor  ( com.talent.aio.examples.im.client.ui.component.MsgTextAreaJPopupMenu.class , null ); // NOI18N//GEN-HEADEREND:BeanDescriptor
// Here you can add code for customizing the BeanDescriptor.

return beanDescriptor;     }
 
源代码21 项目: openjdk-jdk9   文件: FirstBeanBeanInfo.java
@Override
public BeanDescriptor getBeanDescriptor() {
    return new BeanDescriptor(FirstBean.class);
}
 
源代码22 项目: jdk8u-dev-jdk   文件: Foo.java
public BeanDescriptor getBeanDescriptor() {
    BeanDescriptor bd = new BeanDescriptor(Foo.class);
    // set a value to ensure that it's unique
    bd.setValue("test", Boolean.TRUE);
    return bd;
}
 
源代码23 项目: jdk8u_jdk   文件: Test7193977.java
public BeanDescriptor getBeanDescriptor() {
    return this.info.getBeanDescriptor();
}
 
源代码24 项目: hottub   文件: Test6447751.java
public BeanDescriptor getBeanDescriptor() {
    return new BeanDescriptor(Manual.class, AutomaticCustomizer.class);
}
 
源代码25 项目: dragonwell8_jdk   文件: WombatBeanInfo.java
public BeanDescriptor getBeanDescriptor() {
    BeanDescriptor bd = new BeanDescriptor(Wombat.class);
    // set a value to ensure that it's unique
    bd.setValue("test", Boolean.TRUE);
    return bd;
}
 
源代码26 项目: dragonwell8_jdk   文件: Foo.java
public BeanDescriptor getBeanDescriptor() {
    BeanDescriptor bd = new BeanDescriptor(Foo.class);
    // set a value to ensure that it's unique
    bd.setValue("test", Boolean.TRUE);
    return bd;
}
 
源代码27 项目: openjdk-jdk8u-backup   文件: Test7193977.java
public BeanDescriptor getBeanDescriptor() {
    return this.info.getBeanDescriptor();
}
 
源代码28 项目: TencentKona-8   文件: Test6447751.java
public BeanDescriptor getBeanDescriptor() {
    return new BeanDescriptor(Manual.class, AutomaticCustomizer.class);
}
 
源代码29 项目: TencentKona-8   文件: SecondBeanBeanInfo.java
@Override
public BeanDescriptor getBeanDescriptor() {
    return new BeanDescriptor(SecondBean.class);
}
 
源代码30 项目: TencentKona-8   文件: Test7193977.java
public BeanDescriptor getBeanDescriptor() {
    return this.info.getBeanDescriptor();
}
 
 类所在包
 同包方法