Package org.apache.velocity.util.introspection

Examples of org.apache.velocity.util.introspection.VelPropertySet


         2) ref,put("foo", value ) to parallel the get() map introspection
         */

        try
        {
            VelPropertySet vs =
                    rsvc.getUberspect().getPropertySet(result, identifier,
                            value, uberInfo);

            if (vs == null)
            {
                if (strictRef)
                {
                    throw new MethodInvocationException("Object '" + result.getClass().getName() +
                       "' does not contain property '" + identifier + "'", null, identifier,
                       uberInfo.getTemplateName(), uberInfo.getLine(), uberInfo.getColumn());
                }
                else
                {
                  return false;
                }
            }

            vs.invoke(result, value);
        }
        catch(InvocationTargetException ite)
        {
            /*
             *  this is possible
View Full Code Here


         2) ref,put("foo", value ) to parallel the get() map introspection
         */

        try
        {
            VelPropertySet vs =
                    rsvc.getUberspect().getPropertySet(result, identifier,
                            value, uberInfo);

            if (vs == null)
            {
                if (strictRef)
                {
                    throw new MethodInvocationException("Object '" + result.getClass().getName() +
                       "' does not contain property '" + identifier + "'", null, identifier,
                       uberInfo.getTemplateName(), uberInfo.getLine(), uberInfo.getColumn());
                }
                else
                {
                  return false;
                }
            }

            vs.invoke(result, value);
        }
        catch(InvocationTargetException ite)
        {
            /*
             *  this is possible
View Full Code Here

         2) ref,put("foo", value ) to parallel the get() map introspection
         */

        try
        {
            VelPropertySet vs =
                    rsvc.getUberspect().getPropertySet(result, identifier,
                            value, uberInfo);

            if (vs == null)
            {
                if (strictRef)
                {
                    throw new MethodInvocationException("Object '" + result.getClass().getName() +
                       "' does not contain property '" + identifier + "'", null, identifier,
                       uberInfo.getTemplateName(), uberInfo.getLine(), uberInfo.getColumn());
                }
                else
                {
                  return false;
                }
            }

            vs.invoke(result, value);
        }
        catch(InvocationTargetException ite)
        {
            /*
             *  this is possible
View Full Code Here

         2) ref,put("foo", value ) to parallel the get() map introspection
         */

        try
        {
            VelPropertySet vs =
                    rsvc.getUberspect().getPropertySet(result, identifier,
                            value, uberInfo);

            if (vs == null)
                return false;

            vs.invoke(result, value);
        }
        catch(InvocationTargetException ite)
        {
            /*
             *  this is possible
View Full Code Here

        Uberspect u = ri.getUberspect();

        VelPropertyGet getter = u.getPropertyGet(null, "foo", null);
        assertNull(getter);

        VelPropertySet setter = u.getPropertySet(null, "foo", Object.class, null);
        assertNull(setter);
    }
View Full Code Here

            throws Exception
    {
        Uberspect u = ri.getUberspect();
        Map map = new HashMap();

        VelPropertySet setter = u.getPropertySet(map, "", Object.class, null);

        // Don't screw up on empty properties. That should map to put("", Object)
        assertNotNull(setter);
        assertEquals("Found wrong method", "put", setter.getMethodName());
    }
View Full Code Here

        Uberspect u = ri.getUberspect();
        GetPutObject gpo = new GetPutObject();
        Map map = new HashMap();

        // Don't screw up on null properties. That should map to put() on the GPO.
        VelPropertySet setter = u.getPropertySet(gpo, null, "", null);
        assertNotNull(setter);
        assertEquals("Found wrong method", "put", setter.getMethodName());

        // And should be null on a Map which does not have a put()
        setter = u.getPropertySet(map, null, "", null);
        assertNull(setter);
    }
View Full Code Here

    }

    public void testNullParameterType()
            throws Exception
    {
        VelPropertySet setter;

        Uberspect u = ri.getUberspect();
        UberspectorTestObject uto = new UberspectorTestObject();

        // setRegular()
        setter = u.getPropertySet(uto, "Regular", null, null);
        assertNotNull(setter);
        assertEquals("Found wrong method", "setRegular", setter.getMethodName());

        // setAmbigous() - String and StringBuffer available
        setter = u.getPropertySet(uto, "Ambigous", null, null);
        assertNull(setter);
View Full Code Here

    }

    public void testMultipleParameterTypes()
            throws Exception
    {
        VelPropertySet setter;

        Uberspect u = ri.getUberspect();
        UberspectorTestObject uto = new UberspectorTestObject();

        // setAmbigous() - String
        setter = u.getPropertySet(uto, "Ambigous", "", null);
        assertNotNull(setter);
        assertEquals("Found wrong method", "setAmbigous", setter.getMethodName());

        // setAmbigous() - StringBuffer
        setter = u.getPropertySet(uto, "Ambigous", new StringBuffer(), null);
        assertNotNull(setter);
        assertEquals("Found wrong method", "setAmbigous", setter.getMethodName());
    }
View Full Code Here


    public void testRegularSetters()
            throws Exception
    {
        VelPropertySet setter;

        Uberspect u = ri.getUberspect();
        UberspectorTestObject uto = new UberspectorTestObject();

        // setRegular()
        setter = u.getPropertySet(uto, "Regular", "", null);
        assertNotNull(setter);
        assertEquals("Found wrong method", "setRegular", setter.getMethodName());

        // Lowercase regular
        setter = u.getPropertySet(uto, "regular", "", null);
        assertNotNull(setter);
        assertEquals("Found wrong method", "setRegular", setter.getMethodName());

        // lowercase: setpremium()
        setter = u.getPropertySet(uto, "premium", "", null);
        assertNotNull(setter);
        assertEquals("Found wrong method", "setpremium", setter.getMethodName());

        // test uppercase: getpremium()
        setter = u.getPropertySet(uto, "Premium", "", null);
        assertNotNull(setter);
        assertEquals("Found wrong method", "setpremium", setter.getMethodName());
    }
View Full Code Here

TOP

Related Classes of org.apache.velocity.util.introspection.VelPropertySet

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.