当前位置: 首页>>代码示例>>Java>>正文


Java TypedValue.getValue方法代码示例

本文整理汇总了Java中org.springframework.expression.TypedValue.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java TypedValue.getValue方法的具体用法?Java TypedValue.getValue怎么用?Java TypedValue.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.expression.TypedValue的用法示例。


在下文中一共展示了TypedValue.getValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getValueInternal

import org.springframework.expression.TypedValue; //导入方法依赖的package包/类
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
	TypedValue o = state.lookupVariable(this.name);
	if (o == null) {
		throw new SpelEvaluationException(getStartPosition(), SpelMessage.FUNCTION_NOT_DEFINED, this.name);
	}

	// Two possibilities: a lambda function or a Java static method registered as a function
	if (!(o.getValue() instanceof Method)) {
		throw new SpelEvaluationException(SpelMessage.FUNCTION_REFERENCE_CANNOT_BE_INVOKED, this.name, o.getClass());
	}
	try {
		return executeFunctionJLRMethod(state, (Method) o.getValue());
	}
	catch (SpelEvaluationException se) {
		se.setPosition(getStartPosition());
		throw se;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:FunctionReference.java

示例2: getValueInternal

import org.springframework.expression.TypedValue; //导入方法依赖的package包/类
/**
 * Compare the left operand to see it is an instance of the type specified as the
 * right operand. The right operand must be a class.
 * @param state the expression state
 * @return true if the left operand is an instanceof of the right operand, otherwise
 *         false
 * @throws EvaluationException if there is a problem evaluating the expression
 */
@Override
public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException {
	TypedValue left = getLeftOperand().getValueInternal(state);
	TypedValue right = getRightOperand().getValueInternal(state);
	Object leftValue = left.getValue();
	Object rightValue = right.getValue();
	if (leftValue == null) {
		return BooleanTypedValue.FALSE;  // null is not an instanceof anything
	}
	if (rightValue == null || !(rightValue instanceof Class<?>)) {
		throw new SpelEvaluationException(getRightOperand().getStartPosition(),
				SpelMessage.INSTANCEOF_OPERATOR_NEEDS_CLASS_OPERAND,
				(rightValue == null ? "null" : rightValue.getClass().getName()));
	}
	Class<?> rightClass = (Class<?>) rightValue;
	return BooleanTypedValue.forValue(rightClass.isAssignableFrom(leftValue.getClass()));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:OperatorInstanceof.java

示例3: convertTypedValue

import org.springframework.expression.TypedValue; //导入方法依赖的package包/类
/**
 * Determines if there is a type converter available in the specified context and
 * attempts to use it to convert the supplied value to the specified type. Throws an
 * exception if conversion is not possible.
 * @param context the evaluation context that may define a type converter
 * @param typedValue the value to convert and a type descriptor describing it
 * @param targetType the type to attempt conversion to
 * @return the converted value
 * @throws EvaluationException if there is a problem during conversion or conversion
 * of the value to the specified type is not supported
 */
@SuppressWarnings("unchecked")
public static <T> T convertTypedValue(EvaluationContext context, TypedValue typedValue, Class<T> targetType) {
	Object value = typedValue.getValue();
	if (targetType == null) {
		return (T) value;
	}
	if (context != null) {
		return (T) context.getTypeConverter().convertValue(
				value, typedValue.getTypeDescriptor(), TypeDescriptor.valueOf(targetType));
	}
	if (ClassUtils.isAssignableValue(targetType, value)) {
		return (T) value;
	}
	throw new EvaluationException("Cannot convert value '" + value + "' to type '" + targetType.getName() + "'");
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:ExpressionUtils.java

示例4: getValueInternal

import org.springframework.expression.TypedValue; //导入方法依赖的package包/类
/**
 * Evaluate the condition and if not null, return it. If it is null return the other
 * value.
 * @param state the expression state
 * @throws EvaluationException if the condition does not evaluate correctly to a
 *         boolean or there is a problem executing the chosen alternative
 */
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
	TypedValue value = this.children[0].getValueInternal(state);
	if ((value.getValue() != null) && !((value.getValue() instanceof String) &&
			((String) value.getValue()).length() == 0)) {
		return value;
	}
	else {
		return this.children[1].getValueInternal(state);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:Elvis.java

示例5: convertValue

import org.springframework.expression.TypedValue; //导入方法依赖的package包/类
public Object convertValue(TypedValue value, TypeDescriptor targetTypeDescriptor) throws EvaluationException {
	Object val = value.getValue();
	return this.relatedContext.getTypeConverter().convertValue(val, TypeDescriptor.forObject(val), targetTypeDescriptor);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:ExpressionState.java


注:本文中的org.springframework.expression.TypedValue.getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。