|
|
|
@ -97,43 +97,40 @@ public class PropertyOrFieldReference extends SpelNodeImpl { |
|
|
|
if (result.getValue() == null && isAutoGrowNullReferences && |
|
|
|
if (result.getValue() == null && isAutoGrowNullReferences && |
|
|
|
nextChildIs(Indexer.class, PropertyOrFieldReference.class)) { |
|
|
|
nextChildIs(Indexer.class, PropertyOrFieldReference.class)) { |
|
|
|
TypeDescriptor resultDescriptor = result.getTypeDescriptor(); |
|
|
|
TypeDescriptor resultDescriptor = result.getTypeDescriptor(); |
|
|
|
// Creating lists and maps
|
|
|
|
// Create a new collection or map ready for the indexer
|
|
|
|
if ((resultDescriptor.getType().equals(List.class) || resultDescriptor.getType().equals(Map.class))) { |
|
|
|
if (List.class.equals(resultDescriptor.getType())) { |
|
|
|
// Create a new collection or map ready for the indexer
|
|
|
|
try { |
|
|
|
if (resultDescriptor.getType().equals(List.class)) { |
|
|
|
if (isWritableProperty(this.name, contextObject, evalContext)) { |
|
|
|
try { |
|
|
|
List<?> newList = ArrayList.class.newInstance(); |
|
|
|
if (isWritableProperty(this.name, contextObject, evalContext)) { |
|
|
|
writeProperty(contextObject, evalContext, this.name, newList); |
|
|
|
List<?> newList = ArrayList.class.newInstance(); |
|
|
|
result = readProperty(contextObject, evalContext, this.name); |
|
|
|
writeProperty(contextObject, evalContext, this.name, newList); |
|
|
|
|
|
|
|
result = readProperty(contextObject, evalContext, this.name); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (InstantiationException ex) { |
|
|
|
|
|
|
|
throw new SpelEvaluationException(getStartPosition(), ex, |
|
|
|
|
|
|
|
SpelMessage.UNABLE_TO_CREATE_LIST_FOR_INDEXING); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (IllegalAccessException ex) { |
|
|
|
|
|
|
|
throw new SpelEvaluationException(getStartPosition(), ex, |
|
|
|
|
|
|
|
SpelMessage.UNABLE_TO_CREATE_LIST_FOR_INDEXING); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
catch (InstantiationException ex) { |
|
|
|
try { |
|
|
|
throw new SpelEvaluationException(getStartPosition(), ex, |
|
|
|
if (isWritableProperty(this.name,contextObject, evalContext)) { |
|
|
|
SpelMessage.UNABLE_TO_CREATE_LIST_FOR_INDEXING); |
|
|
|
Map<?,?> newMap = HashMap.class.newInstance(); |
|
|
|
} |
|
|
|
writeProperty(contextObject, evalContext, this.name, newMap); |
|
|
|
catch (IllegalAccessException ex) { |
|
|
|
result = readProperty(contextObject, evalContext, this.name); |
|
|
|
throw new SpelEvaluationException(getStartPosition(), ex, |
|
|
|
} |
|
|
|
SpelMessage.UNABLE_TO_CREATE_LIST_FOR_INDEXING); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (InstantiationException ex) { |
|
|
|
} |
|
|
|
throw new SpelEvaluationException(getStartPosition(), ex, |
|
|
|
else if (Map.class.equals(resultDescriptor.getType())) { |
|
|
|
SpelMessage.UNABLE_TO_CREATE_MAP_FOR_INDEXING); |
|
|
|
try { |
|
|
|
} |
|
|
|
if (isWritableProperty(this.name,contextObject, evalContext)) { |
|
|
|
catch (IllegalAccessException ex) { |
|
|
|
Map<?,?> newMap = HashMap.class.newInstance(); |
|
|
|
throw new SpelEvaluationException(getStartPosition(), ex, |
|
|
|
writeProperty(contextObject, evalContext, this.name, newMap); |
|
|
|
SpelMessage.UNABLE_TO_CREATE_MAP_FOR_INDEXING); |
|
|
|
result = readProperty(contextObject, evalContext, this.name); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
catch (InstantiationException ex) { |
|
|
|
|
|
|
|
throw new SpelEvaluationException(getStartPosition(), ex, |
|
|
|
|
|
|
|
SpelMessage.UNABLE_TO_CREATE_MAP_FOR_INDEXING); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (IllegalAccessException ex) { |
|
|
|
|
|
|
|
throw new SpelEvaluationException(getStartPosition(), ex, |
|
|
|
|
|
|
|
SpelMessage.UNABLE_TO_CREATE_MAP_FOR_INDEXING); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
// 'simple' object
|
|
|
|
// 'simple' object
|
|
|
|
|