Examples of DynaProperty


Examples of org.apache.commons.beanutils.DynaProperty

     * Positive test for getDynaPropertys().  Each property name
     * listed in <code>properties</code> should be returned exactly once.
     */
    public void testGetDescriptors()
    {
        DynaProperty pd[] = bean.getDynaClass().getDynaProperties();
        assertNotNull("Got descriptors", pd);
        int count[] = new int[properties.length];
        for (int i = 0; i < pd.length; i++)
        {
            String name = pd[i].getName();
View Full Code Here

Examples of org.apache.commons.beanutils.DynaProperty

     * @param name Name of the property to be retrieved
     * @param type Expected class type of this property
     */
    protected void testGetDescriptorBase(String name, Class type)
    {
        DynaProperty descriptor = bean.getDynaClass().getDynaProperty(name);

        assertNotNull("Failed to get descriptor", descriptor);
        assertEquals("Got incorrect type", type, descriptor.getType());
    }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaProperty

        }

        // Force an exception if the property does not exist
        // (BeanUtils.setProperty() silently returns in this case)
        if (top instanceof DynaBean) {
            DynaProperty desc =
                ((DynaBean) top).getDynaClass().getDynaProperty(property);
            if (desc == null) {
                throw new NoSuchMethodException
                    ("Bean has no property named " + property);
            }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaProperty

        }

        // Force an exception if the property does not exist
        // (BeanUtils.setProperty() silently returns in this case)
        if (top instanceof DynaBean) {
            DynaProperty desc =
                ((DynaBean) top).getDynaClass().getDynaProperty(actualName);
            if (desc == null) {
                throw new NoSuchMethodException
                    ("Bean has no property named " + actualName);
            }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaProperty

            else if (type == Short.class)
            {
                type = Short.TYPE;
            }

            return new DynaProperty(name, type);
        }
    }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaProperty

        Iterator keys = configuration.getKeys();
        List properties = new ArrayList();
        while (keys.hasNext())
        {
            String key = (String) keys.next();
            DynaProperty property = getDynaProperty(key);
            properties.add(property);
        }

        DynaProperty[] propertyArray = new DynaProperty[properties.size()];
        properties.toArray(propertyArray);
View Full Code Here

Examples of org.apache.commons.beanutils.DynaProperty

            throw new NullPointerException();
        } else if ((base instanceof DynaActionForm) &&
                   ("map".equals(name))) {
            return (Map.class);
        } else if (base instanceof DynaBean) {
            DynaProperty dynaProperty =
                getDynaProperty((DynaBean) base, name.toString());
            if (dynaProperty != null) {
                return (dynaProperty.getType());
            } else {
                throw new PropertyNotFoundException(name.toString());
            }
        } else {
            return (resolver.getType(base, name));
View Full Code Here

Examples of org.apache.commons.beanutils.DynaProperty

     * @param name Name of the property to be checked
     */
    private DynaProperty getDynaProperty(DynaBean bean, String name)
        throws PropertyNotFoundException {

        DynaProperty dynaProperty = null;
        try {
            dynaProperty = bean.getDynaClass().getDynaProperty(name);
        } catch (IllegalArgumentException e) {
            ;
        }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaProperty

        // Create corresponding dynamic property definitions
        properties = new DynaProperty[descriptors.length];

        for (int i = 0; i < descriptors.length; i++) {
            properties[i] =
                new DynaProperty(descriptors[i].getName(),
                    descriptors[i].getTypeClass());
            propertiesMap.put(properties[i].getName(), properties[i]);
        }
    }
View Full Code Here

Examples of org.apache.commons.beanutils.DynaProperty

     *                                  is invalid
     * @throws NullPointerException     if an attempt is made to set a
     *                                  primitive property to null
     */
    public void set(String name, Object value) {
        DynaProperty descriptor = getDynaProperty(name);

        if (descriptor.getType() == null) {
            throw new NullPointerException("The type for property " + name
                + " is invalid");
        }

        if (value == null) {
            if (descriptor.getType().isPrimitive()) {
                throw new NullPointerException("Primitive value for '" + name
                    + "'");
            }
        } else if (!isDynaAssignable(descriptor.getType(), value.getClass())) {
            throw new ConversionException("Cannot assign value of type '"
                + value.getClass().getName() + "' to property '" + name
                + "' of type '" + descriptor.getType().getName() + "'");
        }

        dynaValues.put(name, value);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.