コード例 #1
0
ファイル: ExpressionBuilder.java プロジェクト: kabir/jbw-play
  /*
   * (non-Javadoc)
   *
   * @see com.sun.el.parser.NodeVisitor#visit(com.sun.el.parser.Node)
   */
  @Override
  public void visit(Node node) throws ELException {
    if (node instanceof AstFunction) {

      AstFunction funcNode = (AstFunction) node;

      if (this.fnMapper == null) {
        throw new ELException(MESSAGES.missingFunctionMapper());
      }
      Method m = fnMapper.resolveFunction(funcNode.getPrefix(), funcNode.getLocalName());
      if (m == null) {
        throw new ELException(MESSAGES.functionNotFound(funcNode.getOutputName()));
      }
      int pcnt = m.getParameterTypes().length;
      if (node.jjtGetNumChildren() != pcnt) {
        throw new ELException(
            MESSAGES.functionWrongParameterCount(
                funcNode.getOutputName(), pcnt, node.jjtGetNumChildren()));
      }
    } else if (node instanceof AstIdentifier && this.varMapper != null) {
      String variable = ((AstIdentifier) node).getImage();

      // simply capture it
      this.varMapper.resolveVariable(variable);
    }
  }
コード例 #2
0
  /*
   * (non-Javadoc)
   *
   * @see com.sun.el.parser.NodeVisitor#visit(com.sun.el.parser.Node)
   */
  public void visit(Node node) throws ELException {
    if (node instanceof AstFunction) {

      AstFunction funcNode = (AstFunction) node;

      if (this.fnMapper == null) {
        throw new ELException(MessageFactory.get("error.fnMapper.null"));
      }
      Method m = fnMapper.resolveFunction(funcNode.getPrefix(), funcNode.getLocalName());
      if (m == null) {
        throw new ELException(
            MessageFactory.get("error.fnMapper.method", funcNode.getOutputName()));
      }
      int pcnt = m.getParameterTypes().length;
      if (node.jjtGetNumChildren() != pcnt) {
        throw new ELException(
            MessageFactory.get(
                "error.fnMapper.paramcount",
                funcNode.getOutputName(),
                "" + pcnt,
                "" + node.jjtGetNumChildren()));
      }
    } else if (node instanceof AstIdentifier && this.varMapper != null) {
      String variable = ((AstIdentifier) node).getImage();

      // simply capture it
      this.varMapper.resolveVariable(variable);
    }
  }