Package org.zkoss.xel

Examples of org.zkoss.xel.Function


    _second = second;
  }

  //-- FunctionMapper --//
  public Function resolveFunction(String prefix, String name) {
    Function m = _first != null ? _first.resolveFunction(prefix, name): null;
    return m != null ? m:
      _second != null ? _second.resolveFunction(prefix, name): null;
  }
View Full Code Here


    public XelELMapper(FunctionMapper mapper) {
      _mapper = mapper;
    }
    public Method resolveFunction(String prefix, String name) {
      if (_mapper != null) {
        final Function f = _mapper.resolveFunction(prefix, name);
        if (f != null)
          return f.toMethod();
      }
      return null;
    }
View Full Code Here

    }
  }
  public Function getZScriptFunction(String name, Class[] argTypes) {
    for (Iterator it = getLoadedInterpreters().iterator();
    it.hasNext();) {
      Function mtd =
        ((Interpreter)it.next()).getFunction(name, argTypes);
      if (mtd != null)
        return mtd;
    }
    return null;
View Full Code Here

  public Function getZScriptFunction(
  Component comp, String name, Class[] argTypes) {
    for (Iterator it = getLoadedInterpreters().iterator();
    it.hasNext();) {
      final Object ip = it.next();
      Function mtd =
        ip instanceof HierachicalAware ?
        ((HierachicalAware)ip).getFunction(comp, name, argTypes):
        ((Interpreter)ip).getFunction(name, argTypes);
      if (mtd != null)
        return mtd;
View Full Code Here

    _parent = parent;
  }

  //-- FunctionMapper --//
  public Function resolveFunction(String prefix, String name) {
    Function m = super.resolveFunction(prefix, name);
    return m != null ? m:
      _parent != null ? _parent.resolveFunction(prefix, name): null;
  }
View Full Code Here

*/
        return resolveVariable(resolver, (String)_value, ctx);
      }
    } else if (_type == TokenType.FUNCTION) {
      final FunctionMapper mapper = ctx.getFunctionMapper();
      final Function fn = mapper.resolveFunction("", (String)_value);
      if (fn == null) { //cannot find the specified function
        throw new SSErrorXelException(SSError.NAME);
      }
      Object[] args = new Object[getOperands().size()];
      int j = 0;
     
      if ("ISERROR".equals(_value)
        || "ISERR".equals(_value)
        || "ISNA".equals(_value)
        || "ARRAYROW".equals(_value)) { //special function that use error value
        for (final Iterator it=getOperands().iterator(); it.hasNext();) {
          final Token opn = (Token) it.next();
          try {
            final Object arg = opn.evaluate(ctx); //recursive
            args[j++] = arg;
          } catch (SSErrorXelException ex) {
            args[j++] = ex.getSSError();
          }
        }
      } else { //general case, whenever error, throw exception to skip following evaluation.
        for (final Iterator it=getOperands().iterator(); it.hasNext();) {
          final Token opn = (Token) it.next();
          final Object arg = opn.evaluate(ctx); //recursive
          args[j++] = arg;
        }
      }
     
      try {
        return fn.invoke(null, new Object[] {args, ctx});
      } catch (SSErrorXelException ex) {
        throw ex; //throw out again
      } catch (Exception ex) {
ex.printStackTrace();
        throw new SSErrorXelException(SSError.NUM);
View Full Code Here

      } else if (_subtype == TokenSubtype.VAR) { //refer to a variable
        sb.append(_value);
      }
    } else if (_type == TokenType.FUNCTION) {
      final FunctionMapper mapper = ctx.getFunctionMapper();
      final Function fn = mapper.resolveFunction("", (String)_value);
      if (fn == null) { //cannot find the specified function
        sb.append(SSError.NAME);
      } else {
        sb.append(_value).append("(");
        Collection opns = getOperands();
View Full Code Here

   */
  public Function resolveFunction(String arg0, String arg1)
      throws XelException {
    for(final Iterator it=_mappers.iterator(); it.hasNext();) {
      final FunctionMapper mapper = (FunctionMapper) it.next();
      final Function fun = mapper.resolveFunction(arg0, arg1);
      if (fun != null) return fun;
    }
    return null;
  }
View Full Code Here

  }

  @Override
  public Function resolveFunction(String arg0, String arg1) throws XelException {
    for (FunctionMapper mapper : _mappers) {
      final Function fun = mapper.resolveFunction(arg0, arg1);
      if (fun != null) return fun;
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of org.zkoss.xel.Function

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.