Package com.caucho.xpath

Examples of com.caucho.xpath.Env


  public static Object evalObject(PageContextImpl pageContext,
          com.caucho.xpath.Expr select)
    throws XPathException, JspException
  {
    try {
      Env env = XPath.createEnv();
      env.setVarEnv(pageContext.getVarEnv());
     
      Node node = pageContext.getNodeEnv();
     
      Object value = select.evalObject(node, env);

      env.free();

      return value;
    } catch (javax.el.ELException e) {
      throw new JspException(e);
    }
View Full Code Here


  public int doStartTag()
    throws JspException
  {
    try {
      PageContextImpl pageContext = (PageContextImpl) this.pageContext;
      Env env = XPath.createEnv();
      env.setVarEnv(pageContext.getVarEnv());
     
      _oldEnv = pageContext.getNodeEnv();
      Object obj = _select.evalObject(_oldEnv, env);

      env.free();

      if (obj == null)
        return SKIP_BODY;

      if (obj instanceof Iterator)
View Full Code Here

    addFunction("document", new DocumentFun(transformer));
    DocumentFun docFun = new DocumentFun(transformer);
    docFun.setHtml(true);
    addFunction("html_document", docFun);

    Env env = XPath.createEnv();
    env.setFunctions(_funs);
    StylesheetEnv ssEnv = new StylesheetEnv();
    ssEnv.setPath(getPath());
    env.setStylesheetEnv(ssEnv);

    out.disableEscaping(_defaultDisableEscaping);

    if (_strip != null && ! _strip.isEmpty()) {
      stripSpaces(xml);
View Full Code Here

      JspWriter out = pageContext.getOut();

      Node node = pageContext.getNodeEnv();

      Env env = XPath.createEnv();
      env.setVarEnv(pageContext.getVarEnv());

      String value = _select.evalString(node, env);

      env.free();

      if (_escapeXml)
        com.caucho.el.Expr.toStreamEscaped(out, value);
      else
        out.print(value);
View Full Code Here

    // Match patterns need to use a more complicated test.
    if (! (env instanceof Env))
      throw new RuntimeException(String.valueOf(env));
   
    Env globalEnv = (Env) env;
    boolean oldMorePositions = globalEnv.setMorePositions(true);
    int oldIndex = globalEnv.setPositionIndex(0);
    try {
      for (int i = 0; globalEnv.hasMorePositions(); i++) {
        globalEnv.setPositionIndex(i);
        globalEnv.setMorePositions(false);

        if (_expr.isNumber()) {
          double test = _expr.evalNumber(node, env);
          double position = _parent.position(node, globalEnv,
               _parent.copyPosition());

          if (position == test)
            return true;
        }
  else if (_expr.isBoolean()) {
    if (_expr.evalBoolean(node, env))
      return true;
  }
  else {
    Object value = _expr.evalObject(node, env);

    if (value instanceof Number) {
      double test = ((Number) value).doubleValue();
      double position = _parent.position(node, globalEnv,
                 _parent.copyPosition());

      if (position == test)
        return true;
    }
    else if (Expr.toBoolean(value))
      return true;
  }
      }

      return false;
    } finally {
      globalEnv.setPositionIndex(oldIndex);
      globalEnv.setMorePositions(oldMorePositions);
    }
  }
View Full Code Here

    // Match patterns need to use a more complicated test.
    if (! (env instanceof Env))
      throw new RuntimeException(String.valueOf(env));
   
    Env globalEnv = (Env) env;
    boolean oldMorePositions = globalEnv.setMorePositions(true);
    int oldIndex = globalEnv.setPositionIndex(0);
    try {
      for (int i = 0; globalEnv.hasMorePositions(); i++) {
        globalEnv.setPositionIndex(i);
        globalEnv.setMorePositions(false);

        if (_expr.isNumber()) {
          double test = _expr.evalNumber(node, env);
          double position = _parent.position(node, globalEnv,
                                             _parent.copyPosition());

          if (position == test)
            return true;
        }
        else if (_expr.isBoolean()) {
          if (_expr.evalBoolean(node, env))
            return true;
        }
        else {
          Object value = _expr.evalObject(node, env);

          if (value instanceof Number) {
            double test = ((Number) value).doubleValue();
            double position = _parent.position(node, globalEnv,
                                               _parent.copyPosition());

            if (position == test)
              return true;
          }
          else if (Expr.toBoolean(value))
            return true;
        }
      }

      return false;
    } finally {
      globalEnv.setPositionIndex(oldIndex);
      globalEnv.setMorePositions(oldMorePositions);
    }
  }
View Full Code Here

TOP

Related Classes of com.caucho.xpath.Env

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.