Package org.apache.commons.beanutils

Examples of org.apache.commons.beanutils.DynaProperty


     * @exception IndexOutOfBoundsException if the specified index
     *  is outside the range of the underlying property
     */
    public void set(String name, int index, Object value) {

        DynaProperty descriptor = getDynaProperty(name);
        Object prop = dynaValues.get(name);
        if (prop == null) {
            throw new NullPointerException
                ("No indexed value for '" + name + "[" + index + "]'");
        } else if (prop.getClass().isArray()) {
View Full Code Here


     * @exception IllegalArgumentException if the specified property
     *  exists, but is not mapped
     */
    public void set(String name, String key, Object value) {

        DynaProperty descriptor = getDynaProperty(name);
        Object prop = dynaValues.get(name);
        if (prop == null) {
            throw new NullPointerException
                ("No mapped value for '" + name + "(" + key + ")'");
        } else if (prop instanceof Map) {
View Full Code Here

     */
    public String toString() {

        StringBuffer sb = new StringBuffer("DynaActionForm[dynaClass=");
        sb.append(getDynaClass().getName());
        DynaProperty props[] = getDynaClass().getDynaProperties();
        if (props == null) {
            props = new DynaProperty[0];
        }
        for (int i = 0; i < props.length; i++) {
            sb.append(',');
View Full Code Here

     * @exception IllegalArgumentException if this is not a valid property
     *  name for our DynaClass
     */
    protected DynaProperty getDynaProperty(String name) {

        DynaProperty descriptor = getDynaClass().getDynaProperty(name);
        if (descriptor == null) {
            throw new IllegalArgumentException
                ("Invalid property name '" + name + "'");
        }
        return (descriptor);
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

    protected DynaClass createDynaClass()
    {
        DynaClass dynaClass = new BasicDynaClass
                ("TestDynaClass", null,
                        new DynaProperty[]{
                            new DynaProperty("name", String.class),
                        });
        return (dynaClass);
    }
View Full Code Here

        // (BeanUtils.setProperty() silently returns in this case)
        //
        // This code should probably use PropertyUtils.isWriteable(),
        // like SetPropertiesRule does.
        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

            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

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.