本文整理汇总了Java中org.springframework.expression.TypedValue类的典型用法代码示例。如果您正苦于以下问题:Java TypedValue类的具体用法?Java TypedValue怎么用?Java TypedValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TypedValue类属于org.springframework.expression包,在下文中一共展示了TypedValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例2: getValueInternal
import org.springframework.expression.TypedValue; //导入依赖的package包/类
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
BeanResolver beanResolver = state.getEvaluationContext().getBeanResolver();
if (beanResolver==null) {
throw new SpelEvaluationException(getStartPosition(),
SpelMessage.NO_BEAN_RESOLVER_REGISTERED, this.beanname);
}
try {
TypedValue bean = new TypedValue(beanResolver.resolve(
state.getEvaluationContext(), this.beanname));
return bean;
}
catch (AccessException ae) {
throw new SpelEvaluationException( getStartPosition(), ae, SpelMessage.EXCEPTION_DURING_BEAN_RESOLUTION,
this.beanname, ae.getMessage());
}
}
示例3: 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()));
}
示例4: execute
import org.springframework.expression.TypedValue; //导入依赖的package包/类
@Override
public TypedValue execute(EvaluationContext context, Object... arguments) throws AccessException {
try {
if (arguments != null) {
ReflectionHelper.convertArguments(context.getTypeConverter(), arguments, this.ctor, this.varargsPosition);
}
if (this.ctor.isVarArgs()) {
arguments = ReflectionHelper.setupArgumentsForVarargsInvocation(this.ctor.getParameterTypes(), arguments);
}
ReflectionUtils.makeAccessible(this.ctor);
return new TypedValue(this.ctor.newInstance(arguments));
}
catch (Exception ex) {
throw new AccessException("Problem invoking constructor: " + this.ctor, ex);
}
}
示例5: execute
import org.springframework.expression.TypedValue; //导入依赖的package包/类
@Override
public TypedValue execute(EvaluationContext context, Object target, Object... arguments) throws AccessException {
try {
if (arguments != null) {
ReflectionHelper.convertArguments(context.getTypeConverter(), arguments, this.method, this.varargsPosition);
}
if (this.method.isVarArgs()) {
arguments = ReflectionHelper.setupArgumentsForVarargsInvocation(this.method.getParameterTypes(), arguments);
}
ReflectionUtils.makeAccessible(this.method);
Object value = this.method.invoke(target, arguments);
return new TypedValue(value, new TypeDescriptor(new MethodParameter(this.method, -1)).narrow(value));
}
catch (Exception ex) {
throw new AccessException("Problem invoking method: " + this.method, ex);
}
}
示例6: execute
import org.springframework.expression.TypedValue; //导入依赖的package包/类
public TypedValue execute(Martini martini, String category) {
Collection<MartiniTag> tags = martini.getTags();
boolean evaluation = false;
for (Iterator<MartiniTag> i = tags.iterator(); !evaluation && i.hasNext(); ) {
MartiniTag tag = i.next();
evaluation = categories.isMatch(category, tag);
}
return new TypedValue(evaluation);
}
示例7: toByte
import org.springframework.expression.TypedValue; //导入依赖的package包/类
/**
* Attempt to convert a typed value to a byte using the supplied type converter.
*/
public static byte toByte(TypeConverter typeConverter, TypedValue typedValue) {
return (Byte) typeConverter.convertValue(typedValue.getValue(), typedValue.getTypeDescriptor(),
TypeDescriptor.valueOf(Byte.class));
}
示例8: getValueInternal
import org.springframework.expression.TypedValue; //导入依赖的package包/类
/**
* Implements getValue() - delegating to the code for building an array or a simple type.
*/
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
if (this.isArrayConstructor) {
return createArray(state);
}
else {
return createNewInstance(state);
}
}
示例9: populateByteArray
import org.springframework.expression.TypedValue; //导入依赖的package包/类
private void populateByteArray(ExpressionState state, Object newArray, TypeConverter typeConverter,
InlineList initializer) {
byte[] newByteArray = (byte[]) newArray;
for (int i = 0; i < newByteArray.length; i++) {
TypedValue typedValue = initializer.getChild(i).getTypedValue(state);
newByteArray[i] = ExpressionUtils.toByte(typeConverter, typedValue);
}
}
示例10: populateFloatArray
import org.springframework.expression.TypedValue; //导入依赖的package包/类
private void populateFloatArray(ExpressionState state, Object newArray, TypeConverter typeConverter,
InlineList initializer) {
float[] newFloatArray = (float[]) newArray;
for (int i = 0; i < newFloatArray.length; i++) {
TypedValue typedValue = initializer.getChild(i).getTypedValue(state);
newFloatArray[i] = ExpressionUtils.toFloat(typeConverter, typedValue);
}
}
示例11: populateDoubleArray
import org.springframework.expression.TypedValue; //导入依赖的package包/类
private void populateDoubleArray(ExpressionState state, Object newArray, TypeConverter typeConverter,
InlineList initializer) {
double[] newDoubleArray = (double[]) newArray;
for (int i = 0; i < newDoubleArray.length; i++) {
TypedValue typedValue = initializer.getChild(i).getTypedValue(state);
newDoubleArray[i] = ExpressionUtils.toDouble(typeConverter, typedValue);
}
}
示例12: populateShortArray
import org.springframework.expression.TypedValue; //导入依赖的package包/类
private void populateShortArray(ExpressionState state, Object newArray,
TypeConverter typeConverter, InlineList initializer) {
short[] newShortArray = (short[]) newArray;
for (int i = 0; i < newShortArray.length; i++) {
TypedValue typedValue = initializer.getChild(i).getTypedValue(state);
newShortArray[i] = ExpressionUtils.toShort(typeConverter, typedValue);
}
}
示例13: populateLongArray
import org.springframework.expression.TypedValue; //导入依赖的package包/类
private void populateLongArray(ExpressionState state, Object newArray, TypeConverter typeConverter,
InlineList initializer) {
long[] newLongArray = (long[]) newArray;
for (int i = 0; i < newLongArray.length; i++) {
TypedValue typedValue = initializer.getChild(i).getTypedValue(state);
newLongArray[i] = ExpressionUtils.toLong(typeConverter, typedValue);
}
}
示例14: populateCharArray
import org.springframework.expression.TypedValue; //导入依赖的package包/类
private void populateCharArray(ExpressionState state, Object newArray, TypeConverter typeConverter,
InlineList initializer) {
char[] newCharArray = (char[]) newArray;
for (int i = 0; i < newCharArray.length; i++) {
TypedValue typedValue = initializer.getChild(i).getTypedValue(state);
newCharArray[i] = ExpressionUtils.toChar(typeConverter, typedValue);
}
}
示例15: populateBooleanArray
import org.springframework.expression.TypedValue; //导入依赖的package包/类
private void populateBooleanArray(ExpressionState state, Object newArray, TypeConverter typeConverter,
InlineList initializer) {
boolean[] newBooleanArray = (boolean[]) newArray;
for (int i = 0; i < newBooleanArray.length; i++) {
TypedValue typedValue = initializer.getChild(i).getTypedValue(state);
newBooleanArray[i] = ExpressionUtils.toBoolean(typeConverter, typedValue);
}
}