Java Code Examples for org.springframework.expression.spel.SpelMessage#INDEXING_NOT_SUPPORTED_FOR_TYPE

The following examples show how to use org.springframework.expression.spel.SpelMessage#INDEXING_NOT_SUPPORTED_FOR_TYPE . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-analysis-note   File: Indexer.java    License: MIT License 6 votes vote down vote up
@Override
public void setValue(@Nullable Object newValue) {
	growCollectionIfNecessary();
	if (this.collection instanceof List) {
		List list = (List) this.collection;
		if (this.collectionEntryDescriptor.getElementTypeDescriptor() != null) {
			newValue = this.typeConverter.convertValue(newValue, TypeDescriptor.forObject(newValue),
					this.collectionEntryDescriptor.getElementTypeDescriptor());
		}
		list.set(this.index, newValue);
	}
	else {
		throw new SpelEvaluationException(getStartPosition(), SpelMessage.INDEXING_NOT_SUPPORTED_FOR_TYPE,
				this.collectionEntryDescriptor.toString());
	}
}
 
Example 2
Source Project: java-technology-stack   File: Indexer.java    License: MIT License 6 votes vote down vote up
@Override
public void setValue(@Nullable Object newValue) {
	growCollectionIfNecessary();
	if (this.collection instanceof List) {
		List list = (List) this.collection;
		if (this.collectionEntryDescriptor.getElementTypeDescriptor() != null) {
			newValue = this.typeConverter.convertValue(newValue, TypeDescriptor.forObject(newValue),
					this.collectionEntryDescriptor.getElementTypeDescriptor());
		}
		list.set(this.index, newValue);
	}
	else {
		throw new SpelEvaluationException(getStartPosition(), SpelMessage.INDEXING_NOT_SUPPORTED_FOR_TYPE,
				this.collectionEntryDescriptor.toString());
	}
}
 
Example 3
Source Project: lams   File: Indexer.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void setValue(Object newValue) {
	growCollectionIfNecessary();
	if (this.collection instanceof List) {
		List list = (List) this.collection;
		if (this.collectionEntryDescriptor.getElementTypeDescriptor() != null) {
			newValue = this.typeConverter.convertValue(newValue, TypeDescriptor.forObject(newValue),
					this.collectionEntryDescriptor.getElementTypeDescriptor());
		}
		list.set(this.index, newValue);
	}
	else {
		throw new SpelEvaluationException(getStartPosition(), SpelMessage.INDEXING_NOT_SUPPORTED_FOR_TYPE,
				this.collectionEntryDescriptor.toString());
	}
}
 
Example 4
Source Project: spring4-understanding   File: Indexer.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void setValue(Object newValue) {
	growCollectionIfNecessary();
	if (this.collection instanceof List) {
		List list = (List) this.collection;
		if (this.collectionEntryDescriptor.getElementTypeDescriptor() != null) {
			newValue = this.typeConverter.convertValue(newValue, TypeDescriptor.forObject(newValue),
					this.collectionEntryDescriptor.getElementTypeDescriptor());
		}
		list.set(this.index, newValue);
	}
	else {
		throw new SpelEvaluationException(getStartPosition(), SpelMessage.INDEXING_NOT_SUPPORTED_FOR_TYPE,
				this.collectionEntryDescriptor.toString());
	}
}
 
Example 5
Source Project: spring-analysis-note   File: Indexer.java    License: MIT License 4 votes vote down vote up
@Override
public void setValue(@Nullable Object newValue) {
	throw new SpelEvaluationException(getStartPosition(), SpelMessage.INDEXING_NOT_SUPPORTED_FOR_TYPE,
			this.typeDescriptor.toString());
}
 
Example 6
Source Project: java-technology-stack   File: Indexer.java    License: MIT License 4 votes vote down vote up
@Override
public void setValue(@Nullable Object newValue) {
	throw new SpelEvaluationException(getStartPosition(), SpelMessage.INDEXING_NOT_SUPPORTED_FOR_TYPE,
			this.typeDescriptor.toString());
}
 
Example 7
Source Project: lams   File: Indexer.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public TypedValue getValue() {
	Class<?> targetObjectRuntimeClass = getObjectClass(this.targetObject);
	try {
		if (Indexer.this.cachedReadName != null && Indexer.this.cachedReadName.equals(this.name) &&
				Indexer.this.cachedReadTargetType != null &&
				Indexer.this.cachedReadTargetType.equals(targetObjectRuntimeClass)) {
			// It is OK to use the cached accessor
			return Indexer.this.cachedReadAccessor.read(this.evaluationContext, this.targetObject, this.name);
		}
		List<PropertyAccessor> accessorsToTry = AstUtils.getPropertyAccessorsToTry(
				targetObjectRuntimeClass, this.evaluationContext.getPropertyAccessors());
		if (accessorsToTry != null) {
			for (PropertyAccessor accessor : accessorsToTry) {
				if (accessor.canRead(this.evaluationContext, this.targetObject, this.name)) {
					if (accessor instanceof ReflectivePropertyAccessor) {
						accessor = ((ReflectivePropertyAccessor) accessor).createOptimalAccessor(
								this.evaluationContext, this.targetObject, this.name);
					}
					Indexer.this.cachedReadAccessor = accessor;
					Indexer.this.cachedReadName = this.name;
					Indexer.this.cachedReadTargetType = targetObjectRuntimeClass;
					if (accessor instanceof ReflectivePropertyAccessor.OptimalPropertyAccessor) {
						ReflectivePropertyAccessor.OptimalPropertyAccessor optimalAccessor =
								(ReflectivePropertyAccessor.OptimalPropertyAccessor) accessor;
						Member member = optimalAccessor.member;
						Indexer.this.exitTypeDescriptor = CodeFlow.toDescriptor(member instanceof Method ?
								((Method) member).getReturnType() : ((Field) member).getType());
					}
					return accessor.read(this.evaluationContext, this.targetObject, this.name);
				}
			}
		}
	}
	catch (AccessException ex) {
		throw new SpelEvaluationException(getStartPosition(), ex, SpelMessage.INDEXING_NOT_SUPPORTED_FOR_TYPE,
				this.targetObjectTypeDescriptor.toString());
	}
	throw new SpelEvaluationException(getStartPosition(), SpelMessage.INDEXING_NOT_SUPPORTED_FOR_TYPE,
			this.targetObjectTypeDescriptor.toString());
}
 
Example 8
Source Project: lams   File: Indexer.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public void setValue(Object newValue) {
	throw new SpelEvaluationException(getStartPosition(), SpelMessage.INDEXING_NOT_SUPPORTED_FOR_TYPE,
			this.typeDescriptor.toString());
}
 
Example 9
Source Project: spring4-understanding   File: Indexer.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public TypedValue getValue() {
	Class<?> targetObjectRuntimeClass = getObjectClass(this.targetObject);
	try {
		if (Indexer.this.cachedReadName != null && Indexer.this.cachedReadName.equals(this.name) &&
				Indexer.this.cachedReadTargetType != null &&
				Indexer.this.cachedReadTargetType.equals(targetObjectRuntimeClass)) {
			// It is OK to use the cached accessor
			return Indexer.this.cachedReadAccessor.read(this.evaluationContext, this.targetObject, this.name);
		}
		List<PropertyAccessor> accessorsToTry = AstUtils.getPropertyAccessorsToTry(
				targetObjectRuntimeClass, this.evaluationContext.getPropertyAccessors());
		if (accessorsToTry != null) {
			for (PropertyAccessor accessor : accessorsToTry) {
				if (accessor.canRead(this.evaluationContext, this.targetObject, this.name)) {
					if (accessor instanceof ReflectivePropertyAccessor) {
						accessor = ((ReflectivePropertyAccessor) accessor).createOptimalAccessor(
								this.evaluationContext, this.targetObject, this.name);
					}
					Indexer.this.cachedReadAccessor = accessor;
					Indexer.this.cachedReadName = this.name;
					Indexer.this.cachedReadTargetType = targetObjectRuntimeClass;
					if (accessor instanceof ReflectivePropertyAccessor.OptimalPropertyAccessor) {
						ReflectivePropertyAccessor.OptimalPropertyAccessor optimalAccessor =
								(ReflectivePropertyAccessor.OptimalPropertyAccessor) accessor;
						Member member = optimalAccessor.member;
						Indexer.this.exitTypeDescriptor = CodeFlow.toDescriptor(member instanceof Method ?
								((Method) member).getReturnType() : ((Field) member).getType());
					}
					return accessor.read(this.evaluationContext, this.targetObject, this.name);
				}
			}
		}
	}
	catch (AccessException ex) {
		throw new SpelEvaluationException(getStartPosition(), ex, SpelMessage.INDEXING_NOT_SUPPORTED_FOR_TYPE,
				this.targetObjectTypeDescriptor.toString());
	}
	throw new SpelEvaluationException(getStartPosition(), SpelMessage.INDEXING_NOT_SUPPORTED_FOR_TYPE,
			this.targetObjectTypeDescriptor.toString());
}
 
Example 10
Source Project: spring4-understanding   File: Indexer.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void setValue(Object newValue) {
	throw new SpelEvaluationException(getStartPosition(), SpelMessage.INDEXING_NOT_SUPPORTED_FOR_TYPE,
			this.typeDescriptor.toString());
}