Examples of MethodReference


Examples of org.omnifaces.el.MethodReference

   * @return The new graphic resource.
   * @throws IllegalArgumentException When the "value" attribute of the given component is absent or does not
   * represent a method expression referring an existing method taking at least one argument.
   */
  public static GraphicResource create(FacesContext context, ValueExpression value, Object lastModified) {
    MethodReference methodReference = ExpressionInspector.getMethodReference(context.getELContext(), value);

    if (methodReference.getMethod() == null) {
      throw new IllegalArgumentException(String.format(ERROR_UNKNOWN_METHOD, value.getExpressionString()));
    }

    String name = getResourceName(methodReference);

    if (!ALLOWED_METHODS.containsKey(name)) { // No need to validate everytime when already known.
      Class<? extends Object> beanClass = methodReference.getBase().getClass();

      if (!isOneAnnotationPresent(beanClass, REQUIRED_ANNOTATION_TYPES)) {
        throw new IllegalArgumentException(String.format(ERROR_INVALID_SCOPE, beanClass));
      }

      ALLOWED_METHODS.put(name, new MethodReference(methodReference.getBase(), methodReference.getMethod()));
    }

    Object[] params = methodReference.getActualParameters();
    String[] convertedParams = convertToStrings(context, params, methodReference.getMethod().getParameterTypes());
    return new GraphicResource(name, convertedParams, lastModified);
  }
View Full Code Here

Examples of org.springframework.expression.spel.ast.MethodReference

        // property
        push(new PropertyOrFieldReference(nullSafeNavigation, methodOrPropertyName.data,toPos(methodOrPropertyName)));
        return true;
      } else {
        // methodreference
        push(new MethodReference(nullSafeNavigation, methodOrPropertyName.data,toPos(methodOrPropertyName),args));
        // TODO what is the end position for a method reference? the name or the last arg?
        return true;
      }
    }
    return false;
View Full Code Here

Examples of org.springframework.expression.spel.ast.MethodReference

        // property
        push(new PropertyOrFieldReference(nullSafeNavigation, methodOrPropertyName.data,toPos(methodOrPropertyName)));
        return true;
      } else {
        // methodreference
        push(new MethodReference(nullSafeNavigation, methodOrPropertyName.data,toPos(methodOrPropertyName),args));
        // TODO what is the end position for a method reference? the name or the last arg?
        return true;
      }
    }
    return false;
View Full Code Here

Examples of org.springframework.expression.spel.ast.MethodReference

        // property
        push(new PropertyOrFieldReference(nullSafeNavigation, methodOrPropertyName.data,toPos(methodOrPropertyName)));
        return true;
      } else {
        // methodreference
        push(new MethodReference(nullSafeNavigation, methodOrPropertyName.data,toPos(methodOrPropertyName),args));
        // TODO what is the end position for a method reference? the name or the last arg?
        return true;
      }
    }
    return false;
View Full Code Here

Examples of org.springframework.expression.spel.ast.MethodReference

        // property
        push(new PropertyOrFieldReference(nullSafeNavigation, methodOrPropertyName.data,toPos(methodOrPropertyName)));
        return true;
      }
      // methodreference
      push(new MethodReference(nullSafeNavigation, methodOrPropertyName.data, toPos(methodOrPropertyName), args));
      // TODO what is the end position for a method reference? the name or the last arg?
      return true;
    }
    return false;
  }
View Full Code Here

Examples of org.springframework.ide.eclipse.aop.ui.navigator.model.MethodReference

      for (IAopReference reference : foundSourceReferences) {
        if (refs.containsKey(reference.getSource())) {
          refs.get(reference.getSource()).getAspects().add(reference);
        }
        else {
          MethodReference r = new MethodReference();
          r.setMember(reference.getSource());
          r.getAspects().add(reference);
          refs.put(reference.getSource(), r);
        }
      }
      for (IAopReference reference : foundTargetReferences) {
        if (refs.containsKey(reference.getTarget())) {
          refs.get(reference.getTarget()).getAdvices().add(reference);
        }
        else {
          MethodReference r = new MethodReference();
          r.setMember(reference.getTarget());
          r.getAdvices().add(reference);
          refs.put(reference.getTarget(), r);
        }
      }
      for (Map.Entry<IMember, MethodReference> entry : refs.entrySet()) {
        nodes.add(new MethodBeanReferenceNode(entry.getKey(), entry.getValue().getAspects(), entry.getValue()
View Full Code Here

Examples of org.teavm.model.MethodReference

        context.writeExpr(context.getArgument(0));
        writer.append(".constructor)");
    }

    private void achieveGetClass(DependencyAgent agent, MethodDependency method) {
        MethodReference initMethod = new MethodReference(Class.class, "createNew", Class.class);
        agent.linkMethod(initMethod, method.getStack()).use();
        method.getResult().propagate(agent.getType("java.lang.Class"));
    }
View Full Code Here

Examples of org.teavm.model.MethodReference

    private void generateGetLength(GeneratorContext context, SourceWriter writer) throws IOException {
        String array = context.getParameterName(1);
        writer.append("if (" + array + " === null || " + array + ".constructor.$meta.item === undefined) {")
                .softNewLine().indent();
        String clsName = "java.lang.IllegalArgumentException";
        MethodReference cons = new MethodReference(clsName, new MethodDescriptor("<init>", ValueType.VOID));
        writer.append("$rt_throw(").appendClass(clsName).append(".").appendMethod(cons).append("());").softNewLine();
        writer.outdent().append("}").softNewLine();
        writer.append("return " + array + ".data.length;").softNewLine();
    }
View Full Code Here

Examples of org.teavm.model.MethodReference

    private void achieveGetLength(final DependencyAgent agent, final MethodDependency method) {
        method.getVariable(1).addConsumer(new DependencyConsumer() {
            @Override public void consume(DependencyAgentType type) {
                if (!type.getName().startsWith("[")) {
                    MethodReference cons = new MethodReference(IllegalArgumentException.class, "<init>", void.class);
                    agent.linkMethod(cons, method.getStack()).use();
                }
            }
        });
    }
View Full Code Here

Examples of org.teavm.model.MethodReference

        String array = context.getParameterName(1);
        writer.append("var item = " + array + ".data[" + context.getParameterName(2) + "];").softNewLine();
        writer.append("var type = " + array + ".constructor.$meta.item;").softNewLine();
        for (int i = 0; i < primitives.length; ++i) {
            String wrapper = "java.lang." + primitiveWrappers[i];
            MethodReference methodRef = new MethodReference(wrapper, "valueOf",
                    primitiveTypes[i], ValueType.object(wrapper));
            ClassReader cls = context.getClassSource().get(methodRef.getClassName());
            if (cls == null || cls.getMethod(methodRef.getDescriptor()) == null) {
                continue;
            }
            writer.append("if (type === $rt_" + primitives[i].toLowerCase() + "cls()) {").indent().softNewLine();
            writer.append("return ").appendMethodBody(methodRef).append("(item);").softNewLine();
            writer.outdent().append("} else ");
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.