/** * Returns the value of the current node. * * @return */ @Nullable public Object getValue() { return node.getValue(state); }
@Override public TypedValue getValueInternal(ExpressionState expressionState) throws EvaluationException { if (this.constant != null) { return this.constant; } else { List<Object> returnValue = new ArrayList<>(); int childCount = getChildCount(); for (int c = 0; c < childCount; c++) { returnValue.add(getChild(c).getValue(expressionState)); } return new TypedValue(returnValue); } }
@Override public TypedValue getValueInternal(ExpressionState expressionState) throws EvaluationException { if (this.constant != null) { return this.constant; } else { Map<Object, Object> returnValue = new LinkedHashMap<>(); int childcount = getChildCount(); for (int c = 0; c < childcount; c++) { // TODO allow for key being PropertyOrFieldReference like Indexer on maps SpelNode keyChild = getChild(c++); Object key = null; if (keyChild instanceof PropertyOrFieldReference) { PropertyOrFieldReference reference = (PropertyOrFieldReference) keyChild; key = reference.getName(); } else { key = keyChild.getValue(expressionState); } Object value = getChild(c).getValue(expressionState); returnValue.put(key, value); } return new TypedValue(returnValue); } }
private void populateReferenceTypeArray(ExpressionState state, Object newArray, TypeConverter typeConverter, InlineList initializer, Class<?> componentType) { TypeDescriptor toTypeDescriptor = TypeDescriptor.valueOf(componentType); Object[] newObjectArray = (Object[]) newArray; for (int i = 0; i < newObjectArray.length; i++) { SpelNode elementNode = initializer.getChild(i); Object arrayEntry = elementNode.getValue(state); newObjectArray[i] = typeConverter.convertValue(arrayEntry, TypeDescriptor.forObject(arrayEntry), toTypeDescriptor); } }
@Override public TypedValue getValueInternal(ExpressionState expressionState) throws EvaluationException { if (this.constant != null) { return this.constant; } else { List<Object> returnValue = new ArrayList<>(); int childCount = getChildCount(); for (int c = 0; c < childCount; c++) { returnValue.add(getChild(c).getValue(expressionState)); } return new TypedValue(returnValue); } }
@Override public TypedValue getValueInternal(ExpressionState expressionState) throws EvaluationException { if (this.constant != null) { return this.constant; } else { Map<Object, Object> returnValue = new LinkedHashMap<>(); int childcount = getChildCount(); for (int c = 0; c < childcount; c++) { // TODO allow for key being PropertyOrFieldReference like Indexer on maps SpelNode keyChild = getChild(c++); Object key = null; if (keyChild instanceof PropertyOrFieldReference) { PropertyOrFieldReference reference = (PropertyOrFieldReference) keyChild; key = reference.getName(); } else { key = keyChild.getValue(expressionState); } Object value = getChild(c).getValue(expressionState); returnValue.put(key, value); } return new TypedValue(returnValue); } }
private void populateReferenceTypeArray(ExpressionState state, Object newArray, TypeConverter typeConverter, InlineList initializer, Class<?> componentType) { TypeDescriptor toTypeDescriptor = TypeDescriptor.valueOf(componentType); Object[] newObjectArray = (Object[]) newArray; for (int i = 0; i < newObjectArray.length; i++) { SpelNode elementNode = initializer.getChild(i); Object arrayEntry = elementNode.getValue(state); newObjectArray[i] = typeConverter.convertValue(arrayEntry, TypeDescriptor.forObject(arrayEntry), toTypeDescriptor); } }
@Test public void theMostBasic() { SpelExpressionParser parser = new SpelExpressionParser(); SpelExpression expr = parser.parseRaw("2"); assertNotNull(expr); assertNotNull(expr.getAST()); assertEquals(2, expr.getValue()); assertEquals(Integer.class, expr.getValueType()); assertEquals(2, expr.getAST().getValue(null)); }
/** * Returns the value of the current node. * * @return */ @Nullable public Object getValue() { return node.getValue(state); }
Object intendedArrayType = getChild(0).getValue(state); if (!(intendedArrayType instanceof String)) { throw new SpelEvaluationException(getChild(0).getStartPosition(),
Object intendedArrayType = getChild(0).getValue(state); if (!(intendedArrayType instanceof String)) { throw new SpelEvaluationException(getChild(0).getStartPosition(),
@Override public TypedValue getValueInternal(ExpressionState expressionState) throws EvaluationException { if (this.constant != null) { return this.constant; } else { List<Object> returnValue = new ArrayList<>(); int childCount = getChildCount(); for (int c = 0; c < childCount; c++) { returnValue.add(getChild(c).getValue(expressionState)); } return new TypedValue(returnValue); } }
@Override public TypedValue getValueInternal(ExpressionState expressionState) throws EvaluationException { if (this.constant != null) { return this.constant; } else { Map<Object, Object> returnValue = new LinkedHashMap<>(); int childcount = getChildCount(); for (int c = 0; c < childcount; c++) { // TODO allow for key being PropertyOrFieldReference like Indexer on maps SpelNode keyChild = getChild(c++); Object key = null; if (keyChild instanceof PropertyOrFieldReference) { PropertyOrFieldReference reference = (PropertyOrFieldReference) keyChild; key = reference.getName(); } else { key = keyChild.getValue(expressionState); } Object value = getChild(c).getValue(expressionState); returnValue.put(key, value); } return new TypedValue(returnValue); } }
private void populateReferenceTypeArray(ExpressionState state, Object newArray, TypeConverter typeConverter, InlineList initializer, Class<?> componentType) { TypeDescriptor toTypeDescriptor = TypeDescriptor.valueOf(componentType); Object[] newObjectArray = (Object[]) newArray; for (int i = 0; i < newObjectArray.length; i++) { SpelNode elementNode = initializer.getChild(i); Object arrayEntry = elementNode.getValue(state); newObjectArray[i] = typeConverter.convertValue(arrayEntry, TypeDescriptor.forObject(arrayEntry), toTypeDescriptor); } }
Object intendedArrayType = getChild(0).getValue(state); if (!(intendedArrayType instanceof String)) { throw new SpelEvaluationException(getChild(0).getStartPosition(),