當前位置: 首頁>>代碼示例>>Java>>正文


Java ValueExpression類代碼示例

本文整理匯總了Java中javax.el.ValueExpression的典型用法代碼示例。如果您正苦於以下問題:Java ValueExpression類的具體用法?Java ValueExpression怎麽用?Java ValueExpression使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ValueExpression類屬於javax.el包,在下文中一共展示了ValueExpression類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: bug56185

import javax.el.ValueExpression; //導入依賴的package包/類
@Test
public void bug56185() {
    ExpressionFactory factory = ExpressionFactory.newInstance();
    ELContext context = new ELContextImpl();

    TesterBeanC beanC = new TesterBeanC();
    ValueExpression var =
        factory.createValueExpression(beanC, TesterBeanC.class);
    context.getVariableMapper().setVariable("myBean", var);

    ValueExpression ve = factory.createValueExpression(context,
        "${(myBean.int1 > 1 and myBean.myBool) or "+
        "((myBean.myBool or myBean.myBool1) and myBean.int1 > 1)}",
        Boolean.class);
    assertEquals(Boolean.FALSE, ve.getValue(context));
    beanC.setInt1(2);
    beanC.setMyBool1(true);
    assertEquals(Boolean.TRUE, ve.getValue(context));
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:20,代碼來源:TestELParser.java

示例2: testBug51544Direct

import javax.el.ValueExpression; //導入依賴的package包/類
/**
 * Test using list directly as variable.
 */
@Test
public void testBug51544Direct() throws Exception {
    ExpressionFactory factory = ExpressionFactory.newInstance();
    ELContext context = new ELContextImpl();

    List<?> list = Collections.emptyList();

    ValueExpression var =
        factory.createValueExpression(list, List.class);
    context.getVariableMapper().setVariable("list", var);

    ValueExpression ve = factory.createValueExpression(
            context, "${list.size()}", Integer.class);

    Integer result = (Integer) ve.getValue(context);
    assertEquals(Integer.valueOf(0), result);
}
 
開發者ID:sunmingshuai,項目名稱:apache-tomcat-7.0.73-with-comment,代碼行數:21,代碼來源:TestValueExpressionImpl.java

示例3: getValueExpression

import javax.el.ValueExpression; //導入依賴的package包/類
/**
 * Given a ValueBinding <code>binding</code>, return a ValueExpression.
 * The returned ValueExpression will implement StateHolder and Serializable interfaces if
 * <code>ve</code> implements these interfaces.
 * @param binding  The ValueBinding
 * @return a ValueExpression equivalent to the ValueBinding
 */
public static ValueExpression getValueExpression(ValueBinding binding)
{
  // if we previously wrapped a ValueExpression, unwrap it and return it, otherwise create the
  // correct subclass of ValueBindingValueExpression
  if (binding instanceof ValueExpressionValueBinding)
    return ((ValueExpressionValueBinding)binding).getValueExpression();
  else if (binding instanceof StateHolder)
  {
    if (binding instanceof Serializable)
      return new SerializableStateHolderValueBindingValueExpression(binding);
    else
      return new StateHolderValueBindingValueExpression(binding);      
  }
  else if (binding instanceof Serializable)
  {
    return new SerializableValueBindingValueExpression(binding);
  }
  else
  {
    return new ValueBindingValueExpression(binding);      
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:30,代碼來源:ValueBindingValueExpression.java

示例4: parseExpression

import javax.el.ValueExpression; //導入依賴的package包/類
@Override
public Expression parseExpression(String expression,
        @SuppressWarnings("rawtypes") // API does not use generics
        Class expectedType,
        FunctionMapper fMapper) throws ELException {
    try {
        ELContextImpl ctx =
            new ELContextImpl(ELContextImpl.getDefaultResolver());
        if (fMapper != null) {
            ctx.setFunctionMapper(new FunctionMapperImpl(fMapper));
        }
        ValueExpression ve = this.factory.createValueExpression(ctx, expression, expectedType);
        return new ExpressionImpl(ve);
    } catch (javax.el.ELException e) {
        throw new ELParseException(e.getMessage());
    }
}
 
開發者ID:sunmingshuai,項目名稱:apache-tomcat-7.0.73-with-comment,代碼行數:18,代碼來源:ExpressionEvaluatorImpl.java

示例5: getType

import javax.el.ValueExpression; //導入依賴的package包/類
@Override
public Class<?> getType(EvaluationContext ctx) throws ELException {
    VariableMapper varMapper = ctx.getVariableMapper();
    if (varMapper != null) {
        ValueExpression expr = varMapper.resolveVariable(this.image);
        if (expr != null) {
            return expr.getType(ctx.getELContext());
        }
    }
    ctx.setPropertyResolved(false);
    Class<?> result = ctx.getELResolver().getType(ctx, null, this.image);
    if (!ctx.isPropertyResolved()) {
        throw new PropertyNotFoundException(MessageFactory.get(
                "error.resolver.unhandled.null", this.image));
    }
    return result;
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:18,代碼來源:AstIdentifier.java

示例6: put

import javax.el.ValueExpression; //導入依賴的package包/類
@Override
public Object put(
  PropertyKey key,
  Object      value)
{
  Object retValue = super.put(key, value);
  if (_createDeltas())
  {
    if (key.getMutable().isAtLeastSometimesMutable() || !_equals(value, retValue))
      _deltas.put(key, value);
  }
  else if (key.getMutable().isAtLeastSometimesMutable() && !(value instanceof ValueExpression))
  {
    _getMutableTracker(true).addProperty(key);
  }

  if (key.isPartialStateHolder())
  {
    _getPartialStateHolderTracker(true).addProperty(key);
  }

  return retValue;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:24,代碼來源:PropertyArrayMap.java

示例7: isReadOnly

import javax.el.ValueExpression; //導入依賴的package包/類
@Override
public boolean isReadOnly(EvaluationContext ctx) throws ELException {
    VariableMapper varMapper = ctx.getVariableMapper();
    if (varMapper != null) {
        ValueExpression expr = varMapper.resolveVariable(this.image);
        if (expr != null) {
            return expr.isReadOnly(ctx.getELContext());
        }
    }
    ctx.setPropertyResolved(false);
    boolean result = ctx.getELResolver().isReadOnly(ctx, null, this.image);
    if (!ctx.isPropertyResolved()) {
        throw new PropertyNotFoundException(MessageFactory.get(
                "error.resolver.unhandled.null", this.image));
    }
    return result;
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:18,代碼來源:AstIdentifier.java

示例8: getValueReference

import javax.el.ValueExpression; //導入依賴的package包/類
@Override
public ValueReference getValueReference(EvaluationContext ctx) {
	VariableMapper varMapper = ctx.getVariableMapper();

	if (varMapper == null) {
		return null;
	}

	ValueExpression expr = varMapper.resolveVariable(this.image);

	if (expr == null) {
		return null;
	}

	return expr.getValueReference(ctx);
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:17,代碼來源:AstIdentifier.java

示例9: put

import javax.el.ValueExpression; //導入依賴的package包/類
@Override
public Object put(
  PropertyKey key,
  Object      value)
{
  Object retValue = super.put(key, value);
  if (_createDeltas())
  {
    
    if ( key.getMutable().isAtLeastSometimesMutable() || !_equals(value, retValue))
      _deltas.put(key, value);
  }
  else if (key.getMutable().isAtLeastSometimesMutable() && !(value instanceof ValueExpression))
  {
    _getMutableTracker(true).addProperty(key);
  }
  
  if (key.isPartialStateHolder())
  {
    _getPartialStateHolderTracker(true).addProperty(key);
  }

  return retValue;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:25,代碼來源:PropertyHashMap.java

示例10: testGetValueReference

import javax.el.ValueExpression; //導入依賴的package包/類
@Test
public void testGetValueReference() {
    ExpressionFactory factory = ExpressionFactory.newInstance();
    ELContext context = new ELContextImpl();

    TesterBeanB beanB = new TesterBeanB();
    beanB.setName("Tomcat");
    ValueExpression var =
        factory.createValueExpression(beanB, TesterBeanB.class);
    context.getVariableMapper().setVariable("beanB", var);

    ValueExpression ve = factory.createValueExpression(
            context, "${beanB.name}", String.class);

    // First check the basics work
    String result = (String) ve.getValue(context);
    assertEquals("Tomcat", result);

    // Now check the value reference
    ValueReference vr = ve.getValueReference(context);
    assertNotNull(vr);

    assertEquals(beanB, vr.getBase());
    assertEquals("name", vr.getProperty());
}
 
開發者ID:sunmingshuai,項目名稱:apache-tomcat-7.0.73-with-comment,代碼行數:26,代碼來源:TestValueExpressionImpl.java

示例11: parseExpression

import javax.el.ValueExpression; //導入依賴的package包/類
@Override
public Expression parseExpression(String expression, @SuppressWarnings("rawtypes") // API
																					// does
																					// not
																					// use
																					// generics
Class expectedType, FunctionMapper fMapper) throws ELException {
	try {
		ELContextImpl ctx = new ELContextImpl(ELContextImpl.getDefaultResolver());
		if (fMapper != null) {
			ctx.setFunctionMapper(new FunctionMapperImpl(fMapper));
		}
		ValueExpression ve = this.factory.createValueExpression(ctx, expression, expectedType);
		return new ExpressionImpl(ve);
	} catch (javax.el.ELException e) {
		throw new ELParseException(e.getMessage());
	}
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:19,代碼來源:ExpressionEvaluatorImpl.java

示例12: testJavaKeyWordSuffix

import javax.el.ValueExpression; //導入依賴的package包/類
@Test
public void testJavaKeyWordSuffix() {
    ExpressionFactory factory = ExpressionFactory.newInstance();
    ELContext context = new ELContextImpl();

    TesterBeanA beanA = new TesterBeanA();
    beanA.setInt("five");
    ValueExpression var =
        factory.createValueExpression(beanA, TesterBeanA.class);
    context.getVariableMapper().setVariable("beanA", var);

    // Should fail
    Exception e = null;
    try {
        factory.createValueExpression(context, "${beanA.int}",
                String.class);
    } catch (ELException ele) {
        e = ele;
    }
    assertNotNull(e);
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:22,代碼來源:TestELParser.java

示例13: setValueExpression

import javax.el.ValueExpression; //導入依賴的package包/類
@Override
public void setValueExpression(String name,
                               ValueExpression expression)
{
  if (name == null)
    throw new NullPointerException();

  if ((expression != null) && expression.isLiteralText())
  {
    ELContext context =
        FacesContext.getCurrentInstance().getELContext();
    getAttributes().put(name, expression.getValue(context));
  }
  else
  {
    PropertyKey key = getPropertyKey(name);
    getFacesBean().setValueExpression(key, expression);
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:20,代碼來源:UIXComponentBase.java

示例14: doTestBug56179

import javax.el.ValueExpression; //導入依賴的package包/類
private void doTestBug56179(int parenthesesCount, String innerExpr) {
    ExpressionFactory factory = ExpressionFactory.newInstance();
    ELContext context = new ELContextImpl();

    ValueExpression var =
        factory.createValueExpression(Boolean.TRUE, Boolean.class);
    context.getVariableMapper().setVariable("test", var);

    StringBuilder expr = new StringBuilder();
    expr.append("${");
    for (int i = 0; i < parenthesesCount; i++) {
        expr.append("(");
    }
    expr.append(innerExpr);
    for (int i = 0; i < parenthesesCount; i++) {
        expr.append(")");
    }
    expr.append("}");
    ValueExpression ve = factory.createValueExpression(
            context, expr.toString(), String.class);

    String result = (String) ve.getValue(context);
    assertEquals("true", result);
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:25,代碼來源:TestELParser.java

示例15: testExpression

import javax.el.ValueExpression; //導入依賴的package包/類
private void testExpression(String expression, String expected) {
    ExpressionFactory factory = ExpressionFactory.newInstance();
    ELContext context = new ELContextImpl();

    ValueExpression ve = factory.createValueExpression(
            context, expression, String.class);

    String result = (String) ve.getValue(context);
    assertEquals(expected, result);
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:11,代碼來源:TestELParser.java


注:本文中的javax.el.ValueExpression類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。