Java源码示例:org.springframework.expression.common.ExpressionUtils

示例1
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);
	}
}
 
示例2
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);
	}
}
 
示例3
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);
	}
}
 
示例4
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);
	}
}
 
示例5
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);
	}
}
 
示例6
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);
	}
}
 
示例7
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);
	}
}
 
示例8
private void populateIntArray(ExpressionState state, Object newArray, TypeConverter typeConverter,
		InlineList initializer) {

	int[] newIntArray = (int[]) newArray;
	for (int i = 0; i < newIntArray.length; i++) {
		TypedValue typedValue = initializer.getChild(i).getTypedValue(state);
		newIntArray[i] = ExpressionUtils.toInt(typeConverter, typedValue);
	}
}
 
示例9
@SuppressWarnings("unchecked")
@Override
@Nullable
public <T> T getValue(@Nullable Class<T> expectedResultType) throws EvaluationException {
	if (this.compiledAst != null) {
		try {
			EvaluationContext context = getEvaluationContext();
			Object result = this.compiledAst.getValue(context.getRootObject().getValue(), context);
			if (expectedResultType == null) {
				return (T) result;
			}
			else {
				return ExpressionUtils.convertTypedValue(
						getEvaluationContext(), new TypedValue(result), expectedResultType);
			}
		}
		catch (Throwable ex) {
			// If running in mixed mode, revert to interpreted
			if (this.configuration.getCompilerMode() == SpelCompilerMode.MIXED) {
				this.interpretedCount.set(0);
				this.compiledAst = null;
			}
			else {
				// Running in SpelCompilerMode.immediate mode - propagate exception to caller
				throw new SpelEvaluationException(ex, SpelMessage.EXCEPTION_RUNNING_COMPILED_EXPRESSION);
			}
		}
	}

	ExpressionState expressionState = new ExpressionState(getEvaluationContext(), this.configuration);
	TypedValue typedResultValue = this.ast.getTypedValue(expressionState);
	checkCompile(expressionState);
	return ExpressionUtils.convertTypedValue(
			expressionState.getEvaluationContext(), typedResultValue, expectedResultType);
}
 
示例10
@SuppressWarnings("unchecked")
@Override
@Nullable
public <T> T getValue(Object rootObject, @Nullable Class<T> expectedResultType) throws EvaluationException {
	if (this.compiledAst != null) {
		try {
			Object result = this.compiledAst.getValue(rootObject, getEvaluationContext());
			if (expectedResultType == null) {
				return (T)result;
			}
			else {
				return ExpressionUtils.convertTypedValue(
						getEvaluationContext(), new TypedValue(result), expectedResultType);
			}
		}
		catch (Throwable ex) {
			// If running in mixed mode, revert to interpreted
			if (this.configuration.getCompilerMode() == SpelCompilerMode.MIXED) {
				this.interpretedCount.set(0);
				this.compiledAst = null;
			}
			else {
				// Running in SpelCompilerMode.immediate mode - propagate exception to caller
				throw new SpelEvaluationException(ex, SpelMessage.EXCEPTION_RUNNING_COMPILED_EXPRESSION);
			}
		}
	}

	ExpressionState expressionState =
			new ExpressionState(getEvaluationContext(), toTypedValue(rootObject), this.configuration);
	TypedValue typedResultValue = this.ast.getTypedValue(expressionState);
	checkCompile(expressionState);
	return ExpressionUtils.convertTypedValue(
			expressionState.getEvaluationContext(), typedResultValue, expectedResultType);
}
 
示例11
@SuppressWarnings("unchecked")
@Override
@Nullable
public <T> T getValue(EvaluationContext context, @Nullable Class<T> expectedResultType) throws EvaluationException {
	Assert.notNull(context, "EvaluationContext is required");

	if (this.compiledAst != null) {
		try {
			Object result = this.compiledAst.getValue(context.getRootObject().getValue(), context);
			if (expectedResultType != null) {
				return ExpressionUtils.convertTypedValue(context, new TypedValue(result), expectedResultType);
			}
			else {
				return (T) result;
			}
		}
		catch (Throwable ex) {
			// If running in mixed mode, revert to interpreted
			if (this.configuration.getCompilerMode() == SpelCompilerMode.MIXED) {
				this.interpretedCount.set(0);
				this.compiledAst = null;
			}
			else {
				// Running in SpelCompilerMode.immediate mode - propagate exception to caller
				throw new SpelEvaluationException(ex, SpelMessage.EXCEPTION_RUNNING_COMPILED_EXPRESSION);
			}
		}
	}

	ExpressionState expressionState = new ExpressionState(context, this.configuration);
	TypedValue typedResultValue = this.ast.getTypedValue(expressionState);
	checkCompile(expressionState);
	return ExpressionUtils.convertTypedValue(context, typedResultValue, expectedResultType);
}
 
示例12
@SuppressWarnings("unchecked")
@Override
@Nullable
public <T> T getValue(EvaluationContext context, Object rootObject, @Nullable Class<T> expectedResultType)
		throws EvaluationException {

	Assert.notNull(context, "EvaluationContext is required");

	if (this.compiledAst != null) {
		try {
			Object result = this.compiledAst.getValue(rootObject, context);
			if (expectedResultType != null) {
				return ExpressionUtils.convertTypedValue(context, new TypedValue(result), expectedResultType);
			}
			else {
				return (T) result;
			}
		}
		catch (Throwable ex) {
			// If running in mixed mode, revert to interpreted
			if (this.configuration.getCompilerMode() == SpelCompilerMode.MIXED) {
				this.interpretedCount.set(0);
				this.compiledAst = null;
			}
			else {
				// Running in SpelCompilerMode.immediate mode - propagate exception to caller
				throw new SpelEvaluationException(ex, SpelMessage.EXCEPTION_RUNNING_COMPILED_EXPRESSION);
			}
		}
	}

	ExpressionState expressionState = new ExpressionState(context, toTypedValue(rootObject), this.configuration);
	TypedValue typedResultValue = this.ast.getTypedValue(expressionState);
	checkCompile(expressionState);
	return ExpressionUtils.convertTypedValue(context, typedResultValue, expectedResultType);
}
 
示例13
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);
	}
}
 
示例14
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);
	}
}
 
示例15
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);
	}
}
 
示例16
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);
	}
}
 
示例17
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);
	}
}
 
示例18
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);
	}
}
 
示例19
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);
	}
}
 
示例20
private void populateIntArray(ExpressionState state, Object newArray, TypeConverter typeConverter,
		InlineList initializer) {

	int[] newIntArray = (int[]) newArray;
	for (int i = 0; i < newIntArray.length; i++) {
		TypedValue typedValue = initializer.getChild(i).getTypedValue(state);
		newIntArray[i] = ExpressionUtils.toInt(typeConverter, typedValue);
	}
}
 
示例21
@SuppressWarnings("unchecked")
@Override
@Nullable
public <T> T getValue(@Nullable Class<T> expectedResultType) throws EvaluationException {
	if (this.compiledAst != null) {
		try {
			EvaluationContext context = getEvaluationContext();
			Object result = this.compiledAst.getValue(context.getRootObject().getValue(), context);
			if (expectedResultType == null) {
				return (T) result;
			}
			else {
				return ExpressionUtils.convertTypedValue(
						getEvaluationContext(), new TypedValue(result), expectedResultType);
			}
		}
		catch (Throwable ex) {
			// If running in mixed mode, revert to interpreted
			if (this.configuration.getCompilerMode() == SpelCompilerMode.MIXED) {
				this.interpretedCount = 0;
				this.compiledAst = null;
			}
			else {
				// Running in SpelCompilerMode.immediate mode - propagate exception to caller
				throw new SpelEvaluationException(ex, SpelMessage.EXCEPTION_RUNNING_COMPILED_EXPRESSION);
			}
		}
	}

	ExpressionState expressionState = new ExpressionState(getEvaluationContext(), this.configuration);
	TypedValue typedResultValue = this.ast.getTypedValue(expressionState);
	checkCompile(expressionState);
	return ExpressionUtils.convertTypedValue(
			expressionState.getEvaluationContext(), typedResultValue, expectedResultType);
}
 
示例22
@SuppressWarnings("unchecked")
@Override
@Nullable
public <T> T getValue(Object rootObject, @Nullable Class<T> expectedResultType) throws EvaluationException {
	if (this.compiledAst != null) {
		try {
			Object result = this.compiledAst.getValue(rootObject, getEvaluationContext());
			if (expectedResultType == null) {
				return (T)result;
			}
			else {
				return ExpressionUtils.convertTypedValue(
						getEvaluationContext(), new TypedValue(result), expectedResultType);
			}
		}
		catch (Throwable ex) {
			// If running in mixed mode, revert to interpreted
			if (this.configuration.getCompilerMode() == SpelCompilerMode.MIXED) {
				this.interpretedCount = 0;
				this.compiledAst = null;
			}
			else {
				// Running in SpelCompilerMode.immediate mode - propagate exception to caller
				throw new SpelEvaluationException(ex, SpelMessage.EXCEPTION_RUNNING_COMPILED_EXPRESSION);
			}
		}
	}

	ExpressionState expressionState =
			new ExpressionState(getEvaluationContext(), toTypedValue(rootObject), this.configuration);
	TypedValue typedResultValue = this.ast.getTypedValue(expressionState);
	checkCompile(expressionState);
	return ExpressionUtils.convertTypedValue(
			expressionState.getEvaluationContext(), typedResultValue, expectedResultType);
}
 
示例23
@SuppressWarnings("unchecked")
@Override
@Nullable
public <T> T getValue(EvaluationContext context, @Nullable Class<T> expectedResultType) throws EvaluationException {
	Assert.notNull(context, "EvaluationContext is required");

	if (this.compiledAst != null) {
		try {
			Object result = this.compiledAst.getValue(context.getRootObject().getValue(), context);
			if (expectedResultType != null) {
				return ExpressionUtils.convertTypedValue(context, new TypedValue(result), expectedResultType);
			}
			else {
				return (T) result;
			}
		}
		catch (Throwable ex) {
			// If running in mixed mode, revert to interpreted
			if (this.configuration.getCompilerMode() == SpelCompilerMode.MIXED) {
				this.interpretedCount = 0;
				this.compiledAst = null;
			}
			else {
				// Running in SpelCompilerMode.immediate mode - propagate exception to caller
				throw new SpelEvaluationException(ex, SpelMessage.EXCEPTION_RUNNING_COMPILED_EXPRESSION);
			}
		}
	}

	ExpressionState expressionState = new ExpressionState(context, this.configuration);
	TypedValue typedResultValue = this.ast.getTypedValue(expressionState);
	checkCompile(expressionState);
	return ExpressionUtils.convertTypedValue(context, typedResultValue, expectedResultType);
}
 
示例24
@SuppressWarnings("unchecked")
@Override
@Nullable
public <T> T getValue(EvaluationContext context, Object rootObject, @Nullable Class<T> expectedResultType)
		throws EvaluationException {

	Assert.notNull(context, "EvaluationContext is required");

	if (this.compiledAst != null) {
		try {
			Object result = this.compiledAst.getValue(rootObject, context);
			if (expectedResultType != null) {
				return ExpressionUtils.convertTypedValue(context, new TypedValue(result), expectedResultType);
			}
			else {
				return (T) result;
			}
		}
		catch (Throwable ex) {
			// If running in mixed mode, revert to interpreted
			if (this.configuration.getCompilerMode() == SpelCompilerMode.MIXED) {
				this.interpretedCount = 0;
				this.compiledAst = null;
			}
			else {
				// Running in SpelCompilerMode.immediate mode - propagate exception to caller
				throw new SpelEvaluationException(ex, SpelMessage.EXCEPTION_RUNNING_COMPILED_EXPRESSION);
			}
		}
	}

	ExpressionState expressionState = new ExpressionState(context, toTypedValue(rootObject), this.configuration);
	TypedValue typedResultValue = this.ast.getTypedValue(expressionState);
	checkCompile(expressionState);
	return ExpressionUtils.convertTypedValue(context, typedResultValue, expectedResultType);
}
 
示例25
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);
	}
}
 
示例26
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);
	}
}
 
示例27
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);
	}
}
 
示例28
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);
	}
}
 
示例29
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);
	}
}
 
示例30
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);
	}
}