Package com.sun.el.parser

Examples of com.sun.el.parser.Node


  private boolean processingNot(AstNot node, StringBuffer sbMain,
      CompilationContext componentBean) {
    boolean returnValue = false;
    StringBuffer sb1 = new StringBuffer();
   
    Node node1 = node.jjtGetChild(0);

    if (null != node1) {
      if (!(returnValue = processingNode(node1, sb1,
          componentBean))) {
        log.error("Error processing node1: "
            + node1.getImage());
      }
    }
   
    if (returnValue) {
      sbMain.append(" ( ! ");
View Full Code Here


    if (node instanceof AstTrue) {
      sb.append(" true ");
      return returnValue;
    }
   
    Node node1 = node.jjtGetChild(0);

    if (node1 != null) {
      if (!(returnValue &= processingNode(node1, sb1,
          componentBean))) {
        log.error("Error processing node1: "
            + node1.getImage());
      }
    }
   
    Node node2 = node.jjtGetChild(1);

    if (null != node2) {
      if (!(returnValue &= processingNode(node2, sb2,
          componentBean))) {
        log.error("Error processing node2: "
            + node2.getImage());
      }
    }
   
    if (returnValue) {
      sb.append(" ( ");
View Full Code Here

    StringBuffer sb1 = new StringBuffer();
    StringBuffer sb2 = new StringBuffer();

    boolean returnValue = true;

    Node node1 = node.jjtGetChild(0);

    if (node1 != null) {
      if (!(returnValue &= processingNode(node1, sb1,
          componentBean))) {
        log.error("Error processing node1: "
            + node1.getImage());
      }
    }
   
    Node node2 = node.jjtGetChild(1);

    if (null != node2) {
      if (!(returnValue &= processingNode(node2, sb2,
          componentBean))) {
        log.error("Error processing node2: "
            + node2.getImage());
      }
    }

    if (returnValue) {
      sb.append(" ( ");
View Full Code Here

     
      sb.append(node.getLocalName());
      sb.append("(");
      int numChildren = node.jjtGetNumChildren();
      for (int i = 0; i < numChildren; i++) {
        Node childNode = node.jjtGetChild(i);
        StringBuffer buf = new StringBuffer();
        processingNode(childNode, buf, componentBean);
        if (i != 0) {
          sb.append(",");
        }
        sb.append(buf);
      }
      sb.append(")");
    } else {
      String functionName = node.getOutputName();
      if (this.functionsMap.containsKey(functionName)) {
        sb.append(this.functionsMap.get(functionName));
        sb.append("(");
        int numChildren = node.jjtGetNumChildren();
        for (int i = 0; i < numChildren; i++) {
          Node childNode = node.jjtGetChild(i);
          StringBuffer buf = new StringBuffer();
          processingNode(childNode, buf, componentBean);
          if (i != 0) {
            sb.append(",");
          }
View Full Code Here

   * @return
   */
  private String processingBracketSuffix(AstBracketSuffix basketSuffix,
      CompilationContext componentBean) {
    StringBuffer sb = new StringBuffer();
    Node node = basketSuffix.jjtGetChild(0);
    if (node instanceof AstIdentifier) {
      processingIdentifier((AstIdentifier) node, sb, componentBean);
    } else if (node instanceof AstInteger) {
      // sb.append("new Integer(");
      sb.append(node.getImage());
      // sb.append(")");
    } else if (node instanceof AstString) {
      AstString stringNode = (AstString) node;
      sb.append("\"");
      sb.append(stringNode.getString());
      sb.append("\"");
    } else {
      sb.append("\"");
      sb.append(node.getImage());
      sb.append("\"");
    }
    return sb.toString();
  }
View Full Code Here

    String lastVariableType = null;
    List<String> names = new ArrayList<String>();

    for (int i = 0; i < node.jjtGetNumChildren(); i++) {
      StringBuffer sb1 = new StringBuffer();
      Node subChild = node.jjtGetChild(i);

      if (subChild instanceof AstIdentifier) {
        String variableName = subChild.getImage();
        if (componentBean.containsVariable(variableName)) {
          lastVariableType = componentBean.getVariableType(
              variableName).getName();
          names.add(variableName);
        } else {
          processingIdentifier((AstIdentifier) subChild, sb1,
              componentBean);
        }
      } else if (subChild instanceof AstDotSuffix) {
        String propertyName = subChild.getImage();
        log.debug("Object: " + lastVariableType
            + ", property: " + propertyName);

        if (lastVariableType != null) {
          try {

            Class<?> clazz = componentBean.loadClass(lastVariableType);

            PropertyDescriptor propertyDescriptor = getPropertyDescriptor(
                clazz, propertyName, componentBean);

            if (propertyDescriptor == null) {
              throw new PropertyNotFoundException("property: "
                  + propertyName + " not found in class: "
                  + lastVariableType);
            }

            log.debug("propertyObject: "
                + propertyDescriptor.getPropertyType()
                    .getName());
            StringBuffer tmpbuf = new StringBuffer();
            tmpbuf.append(propertyDescriptor.getReadMethod()
                .getName());
            tmpbuf.append("()");
            names.add(tmpbuf.toString());

            lastVariableType = propertyDescriptor.getPropertyType()
                .getName();
          } catch (ClassNotFoundException e) {
              log.error(e.getLocalizedMessage(), e);
          }

        } else {

          sb1.append("getProperty(");
          sb1.append(lastIndexValue);
          sb1.append(",");
          sb1.append("\"");
          sb1.append(subChild.getImage());
          sb1.append("\")");
        }
      } else if (subChild instanceof AstBracketSuffix) {
        String bracketSuffix = processingBracketSuffix(
            (AstBracketSuffix) subChild, componentBean);
View Full Code Here

     * @see javax.el.MethodExpression#getMethodInfo(javax.el.ELContext)
     */
    public MethodInfo getMethodInfo(ELContext context)
            throws PropertyNotFoundException, MethodNotFoundException,
            ELException {
        Node n = this.getNode();
        EvaluationContext ctx = new EvaluationContext(context, this.fnMapper,
                this.varMapper);
        return n.getMethodInfo(ctx, this.paramTypes);
    }
View Full Code Here

            this.varMapper = new VariableMapperFactory(ctxVar);
        }
    }

    public final static Node createNode(String expr) throws ELException {
        Node n = createNodeInternal(expr);
        return n;
    }
View Full Code Here

            throws ELException {
        if (expr == null) {
            throw new ELException(MessageFactory.get("error.null"));
        }

        Node n = cache.get(expr);
        if (n == null) {
            try {
                n = (new ELParser(
                        new com.sun.el.parser.ELParserTokenManager(
                            new com.sun.el.parser.SimpleCharStream(
                                new StringReader(expr),1, 1, expr.length()+1))))
                        .CompositeExpression();

                // validate composite expression
                if (n instanceof AstCompositeExpression) {
                    int numChildren = n.jjtGetNumChildren();
                    if (numChildren == 1) {
                        n = n.jjtGetChild(0);
                    } else {
                        Class type = null;
                        Node child = null;
                        for (int i = 0; i < numChildren; i++) {
                            child = n.jjtGetChild(i);
                            if (child instanceof AstLiteralExpression)
                                continue;
                            if (type == null)
                                type = child.getClass();
                            else {
                                if (!type.equals(child.getClass())) {
                                    throw new ELException(MessageFactory.get(
                                            "error.mixed", expr));
                                }
                            }
                        }
View Full Code Here

            this.varMapper = ((VariableMapperFactory) this.varMapper).create();
        }
    }

    private Node build() throws ELException {
        Node n = createNodeInternal(this.expression);
        this.prepare(n);
        if (n instanceof AstDeferredExpression
                || n instanceof AstDynamicExpression) {
            n = n.jjtGetChild(0);
        }
        return n;
    }
View Full Code Here

TOP

Related Classes of com.sun.el.parser.Node

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.