本文整理匯總了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));
}
示例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);
}
示例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);
}
}
示例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());
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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());
}
示例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());
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}