Java Code Examples for java.beans.PropertyDescriptor#setBound()

The following examples show how to use java.beans.PropertyDescriptor#setBound() . These examples are extracted from open source projects. 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 Project: j2objc   File: PropertyDescriptorTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testSetBound_true() throws SecurityException,
        NoSuchMethodException, IntrospectionException {
    Class<MockJavaBean> beanClass = MockJavaBean.class;
    String propertyName = "PropertyOne";
    Method readMethod = beanClass.getMethod("get" + propertyName,
            (Class[]) null);
    Method writeMethod = beanClass.getMethod("set" + propertyName,
            new Class[] { String.class });
    PropertyDescriptor pd = new PropertyDescriptor(propertyName,
            readMethod, writeMethod);
    pd.setBound(true);

    assertTrue(pd.isBound());
    assertFalse(pd.isConstrained());

    assertEquals(propertyName, pd.getDisplayName());
    assertEquals(propertyName, pd.getName());
    assertEquals(propertyName, pd.getShortDescription());

    assertNotNull(pd.attributeNames());

    assertFalse(pd.isExpert());
    assertFalse(pd.isHidden());
    assertFalse(pd.isPreferred());
}
 
Example 2
private static void test(Class type) {
    for (PropertyDescriptor pd : BeanUtils.getPropertyDescriptors(type)) {
        PropertyDescriptor pdCopy = create(pd);
        if (pdCopy != null) {
            // XXX - hack! The Introspector will set the bound property
            // since it assumes that propertyChange event set descriptors
            // infers that all the properties are bound
            pdCopy.setBound(pd.isBound());

            String name = pd.getName();
            System.out.println(" - " + name);

            if (!compare(pd, pdCopy))
                throw new Error("property delegates are not equal");

            if (!pd.equals(pdCopy))
                throw new Error("equals() failed");

            if (pd.hashCode() != pdCopy.hashCode())
                throw new Error("hashCode() failed");
        }
    }
}
 
Example 3
/**
 * Sets properties from the BeanInfo supplement on the
 * introspected PropertyDescriptor
 */
private void setDocInfoProps(DocBeanInfo dbi, PropertyDescriptor pds) {
    int beanflags = dbi.beanflags;

    if ((beanflags & DocBeanInfo.BOUND) != 0)
        pds.setBound(true);
    if ((beanflags & DocBeanInfo.EXPERT) != 0)
        pds.setExpert(true);
    if ((beanflags & DocBeanInfo.CONSTRAINED) != 0)
        pds.setConstrained(true);
    if ((beanflags & DocBeanInfo.HIDDEN) !=0)
        pds.setHidden(true);
    if ((beanflags & DocBeanInfo.PREFERRED) !=0)
        pds.setPreferred(true);

    if (!(dbi.desc.equals("null"))){
        pds.setShortDescription(dbi.desc);
    }
    if (!(dbi.displayname.equals("null"))){
        pds.setDisplayName(dbi.displayname);
    }
}
 
Example 4
private static void test(Class type) {
    for (PropertyDescriptor pd : BeanUtils.getPropertyDescriptors(type)) {
        PropertyDescriptor pdCopy = create(pd);
        if (pdCopy != null) {
            // XXX - hack! The Introspector will set the bound property
            // since it assumes that propertyChange event set descriptors
            // infers that all the properties are bound
            pdCopy.setBound(pd.isBound());

            String name = pd.getName();
            System.out.println(" - " + name);

            if (!compare(pd, pdCopy))
                throw new Error("property delegates are not equal");

            if (!pd.equals(pdCopy))
                throw new Error("equals() failed");

            if (pd.hashCode() != pdCopy.hashCode())
                throw new Error("hashCode() failed");
        }
    }
}
 
Example 5
/**
 * See {@link java.beans.FeatureDescriptor}.
 */
public static void copyNonMethodProperties(PropertyDescriptor source, PropertyDescriptor target) {
	target.setExpert(source.isExpert());
	target.setHidden(source.isHidden());
	target.setPreferred(source.isPreferred());
	target.setName(source.getName());
	target.setShortDescription(source.getShortDescription());
	target.setDisplayName(source.getDisplayName());

	// Copy all attributes (emulating behavior of private FeatureDescriptor#addTable)
	Enumeration<String> keys = source.attributeNames();
	while (keys.hasMoreElements()) {
		String key = keys.nextElement();
		target.setValue(key, source.getValue(key));
	}

	// See java.beans.PropertyDescriptor#PropertyDescriptor(PropertyDescriptor)
	target.setPropertyEditorClass(source.getPropertyEditorClass());
	target.setBound(source.isBound());
	target.setConstrained(source.isConstrained());
}
 
Example 6
private static void test(Class type) {
    for (PropertyDescriptor pd : BeanUtils.getPropertyDescriptors(type)) {
        PropertyDescriptor pdCopy = create(pd);
        if (pdCopy != null) {
            // XXX - hack! The Introspector will set the bound property
            // since it assumes that propertyChange event set descriptors
            // infers that all the properties are bound
            pdCopy.setBound(pd.isBound());

            String name = pd.getName();
            System.out.println(" - " + name);

            if (!compare(pd, pdCopy))
                throw new Error("property delegates are not equal");

            if (!pd.equals(pdCopy))
                throw new Error("equals() failed");

            if (pd.hashCode() != pdCopy.hashCode())
                throw new Error("hashCode() failed");
        }
    }
}
 
Example 7
/**
 * Sets properties from the BeanInfo supplement on the
 * introspected PropertyDescriptor
 */
private void setDocInfoProps(DocBeanInfo dbi, PropertyDescriptor pds) {
    int beanflags = dbi.beanflags;

    if ((beanflags & DocBeanInfo.BOUND) != 0)
        pds.setBound(true);
    if ((beanflags & DocBeanInfo.EXPERT) != 0)
        pds.setExpert(true);
    if ((beanflags & DocBeanInfo.CONSTRAINED) != 0)
        pds.setConstrained(true);
    if ((beanflags & DocBeanInfo.HIDDEN) !=0)
        pds.setHidden(true);
    if ((beanflags & DocBeanInfo.PREFERRED) !=0)
        pds.setPreferred(true);

    if (!(dbi.desc.equals("null"))){
        pds.setShortDescription(dbi.desc);
    }
    if (!(dbi.displayname.equals("null"))){
        pds.setDisplayName(dbi.displayname);
    }
}
 
Example 8
/**
 * Sets properties from the BeanInfo supplement on the
 * introspected PropertyDescriptor
 */
private void setDocInfoProps(DocBeanInfo dbi, PropertyDescriptor pds) {
    int beanflags = dbi.beanflags;

    if ((beanflags & DocBeanInfo.BOUND) != 0)
        pds.setBound(true);
    if ((beanflags & DocBeanInfo.EXPERT) != 0)
        pds.setExpert(true);
    if ((beanflags & DocBeanInfo.CONSTRAINED) != 0)
        pds.setConstrained(true);
    if ((beanflags & DocBeanInfo.HIDDEN) !=0)
        pds.setHidden(true);
    if ((beanflags & DocBeanInfo.PREFERRED) !=0)
        pds.setPreferred(true);

    if (!(dbi.desc.equals("null"))){
        pds.setShortDescription(dbi.desc);
    }
    if (!(dbi.displayname.equals("null"))){
        pds.setDisplayName(dbi.displayname);
    }
}
 
Example 9
private static void test(Class type) {
    for (PropertyDescriptor pd : BeanUtils.getPropertyDescriptors(type)) {
        PropertyDescriptor pdCopy = create(pd);
        if (pdCopy != null) {
            // XXX - hack! The Introspector will set the bound property
            // since it assumes that propertyChange event set descriptors
            // infers that all the properties are bound
            pdCopy.setBound(pd.isBound());

            String name = pd.getName();
            System.out.println(" - " + name);

            if (!compare(pd, pdCopy))
                throw new Error("property delegates are not equal");

            if (!pd.equals(pdCopy))
                throw new Error("equals() failed");

            if (pd.hashCode() != pdCopy.hashCode())
                throw new Error("hashCode() failed");
        }
    }
}
 
Example 10
/**
 * See {@link java.beans.FeatureDescriptor}.
 */
public static void copyNonMethodProperties(PropertyDescriptor source, PropertyDescriptor target)
		throws IntrospectionException {

	target.setExpert(source.isExpert());
	target.setHidden(source.isHidden());
	target.setPreferred(source.isPreferred());
	target.setName(source.getName());
	target.setShortDescription(source.getShortDescription());
	target.setDisplayName(source.getDisplayName());

	// Copy all attributes (emulating behavior of private FeatureDescriptor#addTable)
	Enumeration<String> keys = source.attributeNames();
	while (keys.hasMoreElements()) {
		String key = keys.nextElement();
		target.setValue(key, source.getValue(key));
	}

	// See java.beans.PropertyDescriptor#PropertyDescriptor(PropertyDescriptor)
	target.setPropertyEditorClass(source.getPropertyEditorClass());
	target.setBound(source.isBound());
	target.setConstrained(source.isConstrained());
}
 
Example 11
/**
 * Sets properties from the BeanInfo supplement on the
 * introspected PropertyDescriptor
 */
private void setDocInfoProps(DocBeanInfo dbi, PropertyDescriptor pds) {
    int beanflags = dbi.beanflags;

    if ((beanflags & DocBeanInfo.BOUND) != 0)
        pds.setBound(true);
    if ((beanflags & DocBeanInfo.EXPERT) != 0)
        pds.setExpert(true);
    if ((beanflags & DocBeanInfo.CONSTRAINED) != 0)
        pds.setConstrained(true);
    if ((beanflags & DocBeanInfo.HIDDEN) !=0)
        pds.setHidden(true);
    if ((beanflags & DocBeanInfo.PREFERRED) !=0)
        pds.setPreferred(true);

    if (!(dbi.desc.equals("null"))){
        pds.setShortDescription(dbi.desc);
    }
    if (!(dbi.displayname.equals("null"))){
        pds.setDisplayName(dbi.displayname);
    }
}
 
Example 12
private static void test(Class type) {
    for (PropertyDescriptor pd : BeanUtils.getPropertyDescriptors(type)) {
        PropertyDescriptor pdCopy = create(pd);
        if (pdCopy != null) {
            // XXX - hack! The Introspector will set the bound property
            // since it assumes that propertyChange event set descriptors
            // infers that all the properties are bound
            pdCopy.setBound(pd.isBound());

            String name = pd.getName();
            System.out.println(" - " + name);

            if (!compare(pd, pdCopy))
                throw new Error("property delegates are not equal");

            if (!pd.equals(pdCopy))
                throw new Error("equals() failed");

            if (pd.hashCode() != pdCopy.hashCode())
                throw new Error("hashCode() failed");
        }
    }
}
 
Example 13
private static void test(Class type) {
    for (PropertyDescriptor pd : BeanUtils.getPropertyDescriptors(type)) {
        PropertyDescriptor pdCopy = create(pd);
        if (pdCopy != null) {
            // XXX - hack! The Introspector will set the bound property
            // since it assumes that propertyChange event set descriptors
            // infers that all the properties are bound
            pdCopy.setBound(pd.isBound());

            String name = pd.getName();
            System.out.println(" - " + name);

            if (!compare(pd, pdCopy))
                throw new Error("property delegates are not equal");

            if (!pd.equals(pdCopy))
                throw new Error("equals() failed");

            if (pd.hashCode() != pdCopy.hashCode())
                throw new Error("hashCode() failed");
        }
    }
}
 
Example 14
private static void test(Class type) {
    for (PropertyDescriptor pd : BeanUtils.getPropertyDescriptors(type)) {
        PropertyDescriptor pdCopy = create(pd);
        if (pdCopy != null) {
            // XXX - hack! The Introspector will set the bound property
            // since it assumes that propertyChange event set descriptors
            // infers that all the properties are bound
            pdCopy.setBound(pd.isBound());

            String name = pd.getName();
            System.out.println(" - " + name);

            if (!compare(pd, pdCopy))
                throw new Error("property delegates are not equal");

            if (!pd.equals(pdCopy))
                throw new Error("equals() failed");

            if (pd.hashCode() != pdCopy.hashCode())
                throw new Error("hashCode() failed");
        }
    }
}
 
Example 15
private static void test(Class type) {
    for (PropertyDescriptor pd : BeanUtils.getPropertyDescriptors(type)) {
        PropertyDescriptor pdCopy = create(pd);
        if (pdCopy != null) {
            // XXX - hack! The Introspector will set the bound property
            // since it assumes that propertyChange event set descriptors
            // infers that all the properties are bound
            pdCopy.setBound(pd.isBound());

            String name = pd.getName();
            System.out.println(" - " + name);

            if (!compare(pd, pdCopy))
                throw new Error("property delegates are not equal");

            if (!pd.equals(pdCopy))
                throw new Error("equals() failed");

            if (pd.hashCode() != pdCopy.hashCode())
                throw new Error("hashCode() failed");
        }
    }
}
 
Example 16
private static void test(Class type) {
    for (PropertyDescriptor pd : BeanUtils.getPropertyDescriptors(type)) {
        PropertyDescriptor pdCopy = create(pd);
        if (pdCopy != null) {
            // XXX - hack! The Introspector will set the bound property
            // since it assumes that propertyChange event set descriptors
            // infers that all the properties are bound
            pdCopy.setBound(pd.isBound());

            String name = pd.getName();
            System.out.println(" - " + name);

            if (!compare(pd, pdCopy))
                throw new Error("property delegates are not equal");

            if (!pd.equals(pdCopy))
                throw new Error("equals() failed");

            if (pd.hashCode() != pdCopy.hashCode())
                throw new Error("hashCode() failed");
        }
    }
}
 
Example 17
/**
 * Sets properties from the BeanInfo supplement on the
 * introspected PropertyDescriptor
 */
private void setDocInfoProps(DocBeanInfo dbi, PropertyDescriptor pds) {
    int beanflags = dbi.beanflags;

    if ((beanflags & DocBeanInfo.BOUND) != 0)
        pds.setBound(true);
    if ((beanflags & DocBeanInfo.EXPERT) != 0)
        pds.setExpert(true);
    if ((beanflags & DocBeanInfo.CONSTRAINED) != 0)
        pds.setConstrained(true);
    if ((beanflags & DocBeanInfo.HIDDEN) !=0)
        pds.setHidden(true);
    if ((beanflags & DocBeanInfo.PREFERRED) !=0)
        pds.setPreferred(true);

    if (!(dbi.desc.equals("null"))){
        pds.setShortDescription(dbi.desc);
    }
    if (!(dbi.displayname.equals("null"))){
        pds.setDisplayName(dbi.displayname);
    }
}
 
Example 18
/**
 * See {@link java.beans.FeatureDescriptor}.
 */
public static void copyNonMethodProperties(PropertyDescriptor source, PropertyDescriptor target)
		throws IntrospectionException {

	target.setExpert(source.isExpert());
	target.setHidden(source.isHidden());
	target.setPreferred(source.isPreferred());
	target.setName(source.getName());
	target.setShortDescription(source.getShortDescription());
	target.setDisplayName(source.getDisplayName());

	// Copy all attributes (emulating behavior of private FeatureDescriptor#addTable)
	Enumeration<String> keys = source.attributeNames();
	while (keys.hasMoreElements()) {
		String key = keys.nextElement();
		target.setValue(key, source.getValue(key));
	}

	// See java.beans.PropertyDescriptor#PropertyDescriptor(PropertyDescriptor)
	target.setPropertyEditorClass(source.getPropertyEditorClass());
	target.setBound(source.isBound());
	target.setConstrained(source.isConstrained());
}
 
Example 19
Source Project: j2objc   File: PropertyDescriptorTest.java    License: Apache License 2.0 5 votes vote down vote up
public void testEquals_Bound() throws IntrospectionException,
        SecurityException, NoSuchMethodException {
    String propertyName = "PropertyOne";

    PropertyDescriptor pd = new PropertyDescriptor(propertyName, null, null);

    String propertyName2 = "PropertyThree";
    PropertyDescriptor pd2 = new PropertyDescriptor(propertyName2, null,
            null);
    pd.setBound(true);
    assertFalse(pd.equals(pd2));
}
 
Example 20
@Override
public PropertyDescriptor[] getPropertyDescriptors() {

    PropertyDescriptor[] p = new PropertyDescriptor[2];

    try {

        // value
        PropertyDescriptor pdValue = new PropertyDescriptor(
            "value", TestClass.class, "getValue", "setValue");
        pdValue.setBound(true);
        pdValue.setConstrained(true);
        pdValue.setExpert(true);
        pdValue.setHidden(true);
        pdValue.setPreferred(true);
        pdValue.setValue("required", true);
        pdValue.setValue("visualUpdate", true);
        pdValue.setShortDescription("user-defined-value");
        pdValue.setValue("enumerationValues", new Object[]{
                "EAST", 3, "javax.swing.SwingConstants.EAST",
                "WEST", 7, "javax.swing.SwingConstants.WEST"});
        p[iValue] = pdValue;

        // other
        PropertyDescriptor pdOther = new PropertyDescriptor(
                "other", TestClass.class, "getOther", "setOther");
        pdOther.setBound(false);
        pdOther.setConstrained(false);
        pdOther.setExpert(false);
        pdOther.setHidden(false);
        pdOther.setPreferred(false);
        pdOther.setValue("required", false);
        pdOther.setValue("visualUpdate", false);
        pdOther.setShortDescription("user-defined-other");
        pdOther.setValue("enumerationValues", new Object[]{
                "TOP", 1, "javax.swing.SwingConstants.TOP"});
        p[iOther] = pdOther;

    } catch(IntrospectionException e) {
        e.printStackTrace();
    }

    return p;
}