gpt4 book ai didi

org.zkoss.xel.XelContext.getVariableResolver()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 05:42:40 27 4
gpt4 key购买 nike

本文整理了Java中org.zkoss.xel.XelContext.getVariableResolver()方法的一些代码示例,展示了XelContext.getVariableResolver()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XelContext.getVariableResolver()方法的具体详情如下:
包路径:org.zkoss.xel.XelContext
类名称:XelContext
方法名:getVariableResolver

XelContext.getVariableResolver介绍

[英]Returns the variable resolver, or null if not available.
[中]返回变量解析器,如果不可用,则返回null。

代码示例

代码示例来源:origin: org.zkoss.zk/zkmax

/** Returns the root object.
 */
public static Object getRoot(XelContext ctx) {
  final VariableResolver resolver = ctx.getVariableResolver();
  return resolver != null ? resolver: Expressions.EMPTY_RESOLVER;
}

代码示例来源:origin: org.zkoss.common/zcommon

public VariableResolver getVariableResolver() {
  return _bResolver ? _resolver: _ctx.getVariableResolver();
}
public FunctionMapper getFunctionMapper() {

代码示例来源:origin: org.zkoss.zk/zkmax

/*package*/ XelELContext(XelContext xelc) {
  _xelc = xelc;
  _resolver = new XelELResolver(xelc.getVariableResolver());
}

代码示例来源:origin: org.zkoss.zkforge.el/zcommons-el

public Object resolve(XelContext ctx, Object base, Object name) {
    Object o = ctx.getVariableResolver();
    return (o instanceof VariableResolverX) ?
        ((VariableResolverX)o).resolveVariable(ctx, base, name):
      o != null && base == null && name != null ?
        ((VariableResolver)o).resolveVariable(name.toString()):
      null;
  }
};

代码示例来源:origin: org.zkoss.common/zcommon

public Object evaluate(XelContext ctx) {
  //Test case: B30-1957661.zul where a function mapper is created
  //by zscript so it is different from one page to page
  return _expr.evaluate(ctx.getVariableResolver(), ctx.getFunctionMapper());
}

代码示例来源:origin: org.zkoss.common/zcommon

public Object evaluate(XelContext xelc, String expression,
Class expectedType)
throws XelException {
  return _eval.evaluate(expression, expectedType,
    xelc != null ? xelc.getVariableResolver(): null,
    xelc != null ? xelc.getFunctionMapper(): null);
}

代码示例来源:origin: org.zkoss.common/zcommon

/** Resolves the variable based on the specified context.
 * If the variable resolver ({@link XelContext#getVariableResolver}
 * is an instance of {@link VariableResolverX}, then
 * {@link VariableResolverX#resolveVariable(XelContext,Object,Object)}
 * will be invoked.
 * @param ctx the context. If null, null will be returned.
 * @since 5.0.0
 */
public static Object resolveVariable(XelContext ctx, Object base, Object name) {
  if (ctx != null) {
    VariableResolver resolver = ctx.getVariableResolver();
    if (resolver instanceof VariableResolverX)
      return  ((VariableResolverX)resolver).resolveVariable(ctx, base, name);
    else if (resolver != null && base == null && name != null)
      return resolver.resolveVariable(name.toString());
  }
  return null;
}
/** Resolves the variable based on the specified resolver.

代码示例来源:origin: org.zkoss.common/zweb

private Context(String content, XelContext xelc, Locator loc) {
  this.content = content;
  _resolver = xelc != null ? xelc.getVariableResolver() : null;
  _mapper = new SimpleMapper(xelc != null ? xelc.getFunctionMapper() : null);
  _xelf = Expressions.newExpressionFactory();
  _locator = loc;
  this.nLines = 1;
}

代码示例来源:origin: org.zkoss.zk/zkmax

public Object evaluate(XelContext ctx) {
    final XelMVELResolver resolver =
      new XelMVELResolver(ctx.getVariableResolver());

    if (_frags.length == 1) { //optimize this most common case
      return Classes.coerce(_expected,
        _frags[0] instanceof String ? _frags[0]:
        MVEL.executeExpression(_frags[0], resolver));
    }

    final StringBuffer sb = new StringBuffer(256);
    for (int j = 0; j < _frags.length; ++j) {
      if (_frags[j] instanceof String) {
        sb.append(_frags[j]);
      } else {
        Object val = MVEL.executeExpression(_frags[j], resolver);
        if (val != null)
          sb.append(val);
      }    
    }
    return Classes.coerce(_expected, sb.toString());
  }
}

代码示例来源:origin: org.zkoss.common/zcommon

protected Object resolve(ELContext ctx, Object base, Object property) {
  VariableResolver resolver = _ctx.getVariableResolver();
  if (resolver != null) {
    if (resolver instanceof VariableResolverX) {
      final Object o = ((VariableResolverX)resolver)
        .resolveVariable(_ctx, base, property);
      //in order to call static method, we can't set property as resolved 
      if (o != null) ctx.setPropertyResolved(true);
      // Bug ZK-3021
      if (REFERENCE_BINDING != null && o != null) {
        if (REFERENCE_BINDING.isAssignableFrom(o.getClass())) {
          try {
            return GET_VALUE.invoke(o, new Object[]{null});
          } catch (Exception e) {
            // do nothing.
          }
        }
      }
      return o;
    } else if (base == null && property != null) {
      final Object o = resolver.resolveVariable(property.toString());
      //in order to call static method, we can't set property as resolved
      if (o != null) ctx.setPropertyResolved(true);
      return o;
    }
  }
  return null;
}
public Class<?> getType(ELContext ctx, Object base, Object property)

代码示例来源:origin: org.zkoss.zk/zkmax

public Object evaluate(XelContext ctx, String expression,
Class expectedType)
throws XelException {
  final XelMVELResolver resolver =
    new XelMVELResolver(ctx.getVariableResolver());
  final ParserContext pctx = getParserContext(ctx);
  final List frags = ExpressionFragment.parse(expression);
  if (frags.size() == 1) { //optimize this most common case
    final Object o = frags.get(0);
    return Classes.coerce(expectedType,
      o instanceof String ? o:
        eval(((ExpressionFragment)o).getExpression(), resolver, pctx));
  }
  final StringBuffer sb = new StringBuffer(256);
  for (Iterator it = frags.iterator(); it.hasNext();) {
    final Object o = it.next();
    if (o instanceof String) {
      sb.append(o);
    } else {
      Object val = eval(((ExpressionFragment)o).getExpression(), resolver, pctx);
      if (val != null)
        sb.append(val);
    }    
  }
  return Classes.coerce(expectedType, sb.toString());
}
private

代码示例来源:origin: org.zkoss.common/zcommon

public Object evaluate(XelContext ctx) {
  //Test case: B30-1957661.zul where a function mapper is created
  //by zscript so it is different from one page to page
  //In this case, we cannot reuse parsed expression.
  final FunctionMapper nfm = ctx.getFunctionMapper();
  if (!Objects.equals(_mapper, nfm))
    return new ELFactory().evaluate(ctx, _rawexpr, _expected);
  return _expr.evaluate(ctx.getVariableResolver());
}

代码示例来源:origin: org.zkoss.zk/zkmax

public Object evaluate(XelContext xelc, String expression,
Class expectedType)
throws XelException {
  try {
    return _eval.evaluate(expression, expectedType,
      xelc != null ?
        new XelELResolver(xelc.getVariableResolver()): null,
      xelc != null ?
        new XelELMapper(xelc.getFunctionMapper()): null);
  } catch (ELException ex) {
    throw new XelException("Failed to evaluate "+expression, ex);
  }
}

代码示例来源:origin: org.zkoss.zk/zkmax

public Object evaluate(XelContext ctx) {
  //Test case: B30-1957661.zul where a function mapper is created
  //by zscript so it is different from one page to page
  //In this case, we cannot reuse parsed expression.
  //
  //Note: if nfm is null, we consider it as not-change since DSP
  //doesn't save function mapper when evaluating
  try {
    final FunctionMapper nfm = ctx.getFunctionMapper();
    if (nfm != null && _mapper != nfm)
      return new ApacheELFactory().evaluate(ctx, _rawexpr, _expected);
    final VariableResolver resolver = ctx.getVariableResolver();
    return _expr.evaluate(
      resolver != null ? new XelELResolver(resolver): null);
  } catch (ELException ex) {
    throw new XelException(ex);
  }
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com