Examples of VelPropertyGet


Examples of org.apache.commons.jexl.util.introspection.VelPropertyGet

             * "Otherwise (a JavaBean object)..." huh? :)
             */

            String s = loc.toString();

            VelPropertyGet vg = Introspector.getUberspect().getPropertyGet(o, s, DUMMY);

            if (vg != null) {
                return vg.invoke(o);
            }
        }

        throw new Exception("Unsupported object type for array [] accessor");
    }
View Full Code Here

Examples of org.apache.commons.jexl.util.introspection.VelPropertyGet

             "Otherwise (a JavaBean object)..."  huh? :)
             */

            String s = loc.toString();

            VelPropertyGet vg = Introspector.getUberspect().getPropertyGet(o, s, DUMMY);

            if (vg != null)
            {
                return vg.invoke(o);
            }
        }

        throw new Exception("Unsupported object type for array [] accessor");
    }
View Full Code Here

Examples of org.apache.flex.forks.velocity.util.introspection.VelPropertyGet

     */
    public Object execute(Object o, InternalContextAdapter context)
        throws MethodInvocationException
    {

        VelPropertyGet vg = null;

        try
        {
            Class c = o.getClass();

            /*
             *  first, see if we have this information cached.
             */

            IntrospectionCacheData icd = context.icacheGet(this);

            /*
             * if we have the cache data and the class of the object we are
             * invoked with is the same as that in the cache, then we must
             * be allright.  The last 'variable' is the method name, and
             * that is fixed in the template :)
             */

            if (icd != null && icd.contextData == c)
            {
                vg = (VelPropertyGet) icd.thingy;
            }
            else
            {
                /*
                 *  otherwise, do the introspection, and cache it.  Use the
                 *  uberspector
                 */

                vg = rsvc.getUberspect().getPropertyGet(o,identifier, uberInfo);

                if (vg != null && vg.isCacheable())
                {
                    icd = new IntrospectionCacheData();
                    icd.contextData = c;
                    icd.thingy = vg;
                    context.icachePut(this,icd);
                }
            }
        }
        catch(Exception e)
        {
            rsvc.error("ASTIdentifier.execute() : identifier = "
                               + identifier + " : " + e);
        }

        /*
         *  we have no getter... punt...
         */

        if (vg == null)
        {
            return null;
        }

        /*
         *  now try and execute.  If we get a MIE, throw that
         *  as the app wants to get these.  If not, log and punt.
         */
        try
        {
            return vg.invoke(o);
        }
        catch(InvocationTargetException ite)
        {
            EventCartridge ec = context.getEventCartridge();

            /*
             *  if we have an event cartridge, see if it wants to veto
             *  also, let non-Exception Throwables go...
             */

            if (ec != null
                    && ite.getTargetException() instanceof java.lang.Exception)
            {
                try
                {
                    return ec.methodException(o.getClass(), vg.getMethodName(),
                            (Exception)ite.getTargetException());
                }
                catch(Exception e)
                {
                    throw new MethodInvocationException(
                      "Invocation of method '" + vg.getMethodName() + "'"
                      + " in  " + o.getClass()
                      + " threw exception "
                      + ite.getTargetException().getClass() + " : "
                      + ite.getTargetException().getMessage(),
                      ite.getTargetException(), vg.getMethodName());
                }
            }
            else
            {
                /*
                 * no event cartridge to override. Just throw
                 */

                throw  new MethodInvocationException(
                "Invocation of method '" + vg.getMethodName() + "'"
                + " in  " + o.getClass()
                + " threw exception "
                + ite.getTargetException().getClass() + " : "
                + ite.getTargetException().getMessage(),
                ite.getTargetException(), vg.getMethodName());


            }
        }
        catch(IllegalArgumentException iae)
View Full Code Here

Examples of org.apache.flex.forks.velocity.util.introspection.VelPropertyGet

  public static class StrictUberspectImpl extends UberspectImpl
  {
    public VelPropertyGet getPropertyGet(Object obj, String identifier,
                                         Info i) throws Exception
    {
      VelPropertyGet getter = super.getPropertyGet(obj, identifier, i);
      // there is no clean way to see if super succeeded
      // @see http://issues.apache.org/bugzilla/show_bug.cgi?id=31742
      try
      {
        getter.getMethodName();
      }
      catch (NullPointerException e)
      {
        ThreadLocalToolkit.log(new GetMethodNotFound(i.getTemplateName(), i.getLine(), i.getColumn(), identifier, obj.getClass().getName()));
      }
View Full Code Here

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

        return method;
    }

    public VelPropertyGet getPropertyGet(Object obj, String identifier, Info i) throws Exception
    {
        VelPropertyGet propertyGet = super.getPropertyGet(obj, identifier, i);
       
        if (propertyGet == null)
        {
            if (obj == null)
                throw new UberspectTestException("Can't call getter '" + identifier + "' on null object",i);
View Full Code Here

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

            throws Exception
    {
        // How about some null objects... Gee, I'm mean. ;-)
        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

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

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

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

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

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

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

        VelPropertyGet getter = u.getPropertyGet(gpo, null, null);

        // Don't screw up on null properties. That should map to get() on the GPO.
        assertNotNull(getter);
        assertEquals("Found wrong method", "get", getter.getMethodName());

        // And should be null on a Map which does not have a get()
        getter = u.getPropertyGet(map, null, null);
        assertNull(getter);
View Full Code Here

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


    public void testRegularGetters()
            throws Exception
    {
        VelPropertyGet getter;

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

        // getRegular()
        getter = u.getPropertyGet(uto, "Regular", null);
        assertNotNull(getter);
        assertEquals("Found wrong method", "getRegular", getter.getMethodName());

        // Lowercase regular
        getter = u.getPropertyGet(uto, "regular", null);
        assertNotNull(getter);
        assertEquals("Found wrong method", "getRegular", getter.getMethodName());

        // lowercase: getpremium()
        getter = u.getPropertyGet(uto, "premium", null);
        assertNotNull(getter);
        assertEquals("Found wrong method", "getpremium", getter.getMethodName());

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

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

    }

    public void testBooleanGetters()
            throws Exception
    {
        VelPropertyGet getter;

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

        // getRegular()
        getter = u.getPropertyGet(uto, "RegularBool", null);
        assertNotNull(getter);
        assertEquals("Found wrong method", "isRegularBool", getter.getMethodName());

        // Lowercase regular
        getter = u.getPropertyGet(uto, "regularBool", null);
        assertNotNull(getter);
        assertEquals("Found wrong method", "isRegularBool", getter.getMethodName());

        // lowercase: getpremiumBool()
        getter = u.getPropertyGet(uto, "premiumBool", null);
        assertNotNull(getter);
        assertEquals("Found wrong method", "ispremiumBool", getter.getMethodName());

        // test uppercase: ()
        getter = u.getPropertyGet(uto, "PremiumBool", null);
        assertNotNull(getter);
        assertEquals("Found wrong method", "ispremiumBool", getter.getMethodName());
    }
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.