Package org.apache.commons.beanutils

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


    }
    // 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

    // 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

        // from the metadata
        Class clazz = Object.class;
        if (className != null) {
            clazz = loadClass(className);
        }
        return new DynaProperty(name, clazz);

    }
View Full Code Here

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

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

        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

     * Corner cases on getDynaProperty invalid arguments.
     */
    public void testGetDescriptorArguments() {

        try {
            DynaProperty descriptor =
                    dynaForm.getDynaClass().getDynaProperty("unknown");
            assertNull("Unknown property descriptor should be null",
                    descriptor);
        } catch (Throwable t) {
            fail("Threw " + t + " instead of returning null");
View Full Code Here

     * Positive test for getDynaPropertys().  Each property name
     * listed in <code>properties</code> should be returned exactly once.
     */
    public void testGetDescriptors() {

        DynaProperty pd[] = dynaForm.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();
            for (int j = 0; j < properties.length; j++) {
View Full Code Here

     * @param type Expected class type of this property
     */
    protected void testGetDescriptorBase(String name, Class type) {

        try {
            DynaProperty descriptor =
                    dynaForm.getDynaClass().getDynaProperty(name);
            assertNotNull("Got descriptor", descriptor);
            assertEquals("Got correct type", type, descriptor.getType());
        } catch (Throwable t) {
            fail("Threw an exception: " + t);
        }

    }
View Full Code Here

     * @exception 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

Related Classes of org.apache.commons.beanutils.DynaProperty

Copyright © 2018 www.massapicom. 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.