Package railo.runtime.reflection.pairs

Examples of railo.runtime.reflection.pairs.MethodInstance


    //return pc.getFunctionWithNamedValues(get(query.getCurrentrow()), methodName, Caster.toFunctionValues(args));
  }

  @Override
  public Object call(PageContext pc, Key methodName, Object[] arguments) throws PageException {
    MethodInstance mi = Reflector.getMethodInstanceEL(this,this.getClass(), methodName, arguments);
    if(mi!=null) {
      try {
        return mi.invoke(this);
      } catch (Throwable t) {
        try {
          return pc.getFunction(QueryUtil.getValue(this,query.getCurrentrow(pc.getId())), methodName, arguments);
        } catch (PageException pe) {
          throw Caster.toPageException(t);
View Full Code Here


        if(methods[i]!=null) {
          Class[] parameterTypes = methods[i].getParameterTypes();
          for(int y=0;y<parameterTypes.length;y++) {
            if(toReferenceClass(parameterTypes[y])!=clazzArgs[y]) continue outer;
          }
          return new MethodInstance(methods[i],args);
        }
      }
      // like comparsion
        //MethodInstance mi=null;
        // print.e("like:"+methodName);
        outer:for(int i=0;i<methods.length;i++) {
        if(methods[i]!=null) {
          Class[] parameterTypes = methods[i].getParameterTypes();
          for(int y=0;y<parameterTypes.length;y++) {
            if(!like(clazzArgs[y],toReferenceClass(parameterTypes[y]))) continue outer;
          }
          return new MethodInstance(methods[i],args);
        }
      }
       
       
      // convert comparsion
        // print.e("convert:"+methodName);
        MethodInstance mi=null;
        int _rating=0;
      outer:for(int i=0;i<methods.length;i++) {
        if(methods[i]!=null) {
          RefInteger rating=(methods.length>1)?new RefIntegerImpl(0):null;
          Class[] parameterTypes = methods[i].getParameterTypes();
          Object[] newArgs = new Object[args.length];
          for(int y=0;y<parameterTypes.length;y++) {
            try {
              newArgs[y]=convert(args[y],toReferenceClass(parameterTypes[y]),rating);
            } catch (PageException e) {
              continue outer;
            }
          }
          if(mi==null || rating.toInt()>_rating) {
            if(rating!=null)_rating=rating.toInt();
            mi=new MethodInstance(methods[i],newArgs);
          }
          //return new MethodInstance(methods[i],newArgs);
        }
      }return mi;
    }
View Full Code Here

     * @throws NoSuchMethodException
     * @throws PageException
     */
    public static MethodInstance getMethodInstance(Object obj,Class clazz, String methodName, Object[] args)
        throws NoSuchMethodException {
        MethodInstance mi=getMethodInstanceEL(obj,clazz, KeyImpl.getInstance(methodName), args);
        if(mi!=null) return mi;
       
        Class[] classes = getClasses(args);
        //StringBuilder sb=null;
        JavaObject jo;
View Full Code Here

    }
   
    //checkAccesibility(obj,methodName);
       
       
    MethodInstance mi=getMethodInstanceEL(obj,obj.getClass(), methodName, args);
    if(mi==null)
        throw throwCall(obj,methodName,args);
      try {
        return mi.invoke(obj);
        }
    catch (InvocationTargetException e) {
      Throwable target = e.getTargetException();
      if(target instanceof PageException) throw (PageException)target;
      throw new NativeException(e.getTargetException());
View Full Code Here

    if(obj==null) {
      return defaultValue;
    }
    //checkAccesibility(obj,methodName);
       
    MethodInstance mi=getMethodInstanceEL(obj,obj.getClass(), methodName, args);
    if(mi==null)
        return defaultValue;
      try {
        return mi.invoke(obj);
        }
    catch (Throwable t) {
      return defaultValue;
    }
  }
View Full Code Here

     * @throws NoSuchMethodException
     * @throws PageException
     */
    public static MethodInstance getGetter(Class clazz, String prop) throws PageException, NoSuchMethodException {
        String getterName = "get"+StringUtil.ucFirst(prop);
        MethodInstance mi = getMethodInstanceEL(null,clazz,KeyImpl.getInstance(getterName),ArrayUtil.OBJECT_EMPTY);
       
        if(mi==null){
          String isName = "is"+StringUtil.ucFirst(prop);
            mi = getMethodInstanceEL(null,clazz,KeyImpl.getInstance(isName),ArrayUtil.OBJECT_EMPTY);
            if(mi!=null){
              Method m = mi.getMethod();
              Class rtn = m.getReturnType();
              if(rtn!=Boolean.class && rtn!=boolean.class) mi=null;
            }
        }
           
       
        if(mi==null)
          throw new ExpressionException("No matching property ["+prop+"] found in ["+Caster.toTypeName(clazz)+"]");
        Method m=mi.getMethod();
       
        if(m.getReturnType()==void.class)
            throw new NoSuchMethodException("invalid return Type, method ["+m.getName()+"] for Property ["+getterName+"] must have return type not void");
       
        return mi;
View Full Code Here

     * @param prop Name of the Method without get
     * @return return Value of the getter Method
     */
    public static MethodInstance getGetterEL(Class clazz, String prop) {
        prop="get"+StringUtil.ucFirst(prop);
        MethodInstance mi = getMethodInstanceEL(null,clazz,KeyImpl.getInstance(prop),ArrayUtil.OBJECT_EMPTY);
        if(mi==null) return null;
        if(mi.getMethod().getReturnType()==void.class) return null;
        return mi;
    }
View Full Code Here

     * @throws NoSuchMethodException
     * @throws PageException
     */
    public static MethodInstance getSetter(Object obj, String prop,Object value) throws NoSuchMethodException {
            prop="set"+StringUtil.ucFirst(prop);
            MethodInstance mi = getMethodInstance(obj,obj.getClass(),prop,new Object[]{value});
            Method m=mi.getMethod();
           
            if(m.getReturnType()!=void.class)
                throw new NoSuchMethodException("invalid return Type, method ["+m.getName()+"] must have return type void, now ["+m.getReturnType().getName()+"]");
            return mi;
    }
View Full Code Here

     * @param value Value to set to the Method
     * @return MethodInstance
     */
    public static MethodInstance getSetter(Object obj, String prop,Object value, MethodInstance defaultValue)  {
        prop="set"+StringUtil.ucFirst(prop);
        MethodInstance mi = getMethodInstanceEL(obj,obj.getClass(),KeyImpl.getInstance(prop),new Object[]{value});
        if(mi==null) return defaultValue;
        Method m=mi.getMethod();
       
        if(m.getReturnType()!=void.class) return defaultValue;
        return mi;
    }
View Full Code Here

   * @param value
   * @throws PageException
   */
  public static void callSetterEL(Object obj, String prop,Object value) throws PageException {
      try {
        MethodInstance setter = getSetter(obj, prop, value,null);
        if(setter!=null)setter.invoke(obj);
    }
    catch (InvocationTargetException e) {
      Throwable target = e.getTargetException();
      if(target instanceof PageException) throw (PageException)target;
      throw Caster.toPageException(e.getTargetException());
View Full Code Here

TOP

Related Classes of railo.runtime.reflection.pairs.MethodInstance

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.