Package org.springframework.expression.spel

Examples of org.springframework.expression.spel.SpelNode


  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);
    }
  }
View Full Code Here


   * created.
   */
  private void checkIfConstant() {
    boolean isConstant = true;
    for (int c = 0, max = getChildCount(); c < max; c++) {
      SpelNode child = getChild(c);
      if (!(child instanceof Literal)) {
        if (child instanceof InlineList) {
          InlineList inlineList = (InlineList) child;
          if (!inlineList.isConstant()) {
            isConstant = false;
          }
        } else {
          isConstant = false;
        }
      }
    }
    if (isConstant) {
      List<Object> constantList = new ArrayList<Object>();
      int childcount = getChildCount();
      for (int c = 0; c < childcount; c++) {
        SpelNode child = getChild(c);
        if ((child instanceof Literal)) {
          constantList.add(((Literal) child).getLiteralValue().getValue());
        } else if (child instanceof InlineList) {
          constantList.add(((InlineList) child).getConstantValue());
        }
View Full Code Here

  }

  @Test
  public void positionalInformation() throws EvaluationException, ParseException {
    SpelExpression expr = new SpelExpressionParser().parseRaw("true and true or false");
    SpelNode rootAst = expr.getAST();
    OpOr operatorOr = (OpOr) rootAst;
    OpAnd operatorAnd = (OpAnd) operatorOr.getLeftOperand();
    SpelNode rightOrOperand = operatorOr.getRightOperand();

    // check position for final 'false'
    assertEquals(17, rightOrOperand.getStartPosition());
    assertEquals(22, rightOrOperand.getEndPosition());

    // check position for first 'true'
    assertEquals(0, operatorAnd.getLeftOperand().getStartPosition());
    assertEquals(4, operatorAnd.getLeftOperand().getEndPosition());
View Full Code Here

   * created.
   */
  private void checkIfConstant() {
    boolean isConstant = true;
    for (int c = 0, max = getChildCount(); c < max; c++) {
      SpelNode child = getChild(c);
      if (!(child instanceof Literal)) {
        if (child instanceof InlineList) {
          InlineList inlineList = (InlineList) child;
          if (!inlineList.isConstant()) {
            isConstant = false;
          }
        } else {
          isConstant = false;
        }
      }
    }
    if (isConstant) {
      List<Object> constantList = new ArrayList<Object>();
      int childcount = getChildCount();
      for (int c = 0; c < childcount; c++) {
        SpelNode child = getChild(c);
        if ((child instanceof Literal)) {
          constantList.add(((Literal) child).getLiteralValue().getValue());
        } else if (child instanceof InlineList) {
          constantList.add(((InlineList) child).getConstantValue());
        }
View Full Code Here

  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);
    }
  }
View Full Code Here

   * created.
   */
  private void checkIfConstant() {
    boolean isConstant = true;
    for (int c = 0, max = getChildCount(); c < max; c++) {
      SpelNode child = getChild(c);
      if (!(child instanceof Literal)) {
        if (child instanceof InlineList) {
          InlineList inlineList = (InlineList) child;
          if (!inlineList.isConstant()) {
            isConstant = false;
          }
        }
        else {
          isConstant = false;
        }
      }
    }
    if (isConstant) {
      List<Object> constantList = new ArrayList<Object>();
      int childcount = getChildCount();
      for (int c = 0; c < childcount; c++) {
        SpelNode child = getChild(c);
        if ((child instanceof Literal)) {
          constantList.add(((Literal) child).getLiteralValue().getValue());
        }
        else if (child instanceof InlineList) {
          constantList.add(((InlineList) child).getConstantValue());
View Full Code Here

      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);
    }
  }
View Full Code Here

   * This will speed up later getValue calls and reduce the amount of garbage created.
   */
  private void checkIfConstant() {
    boolean isConstant = true;
    for (int c = 0, max = getChildCount(); c < max; c++) {
      SpelNode child = getChild(c);
      if (!(child instanceof Literal)) {
        if (child instanceof InlineList) {
          InlineList inlineList = (InlineList) child;
          if (!inlineList.isConstant()) {
            isConstant = false;
            break;
          }
        }
        else if (child instanceof InlineMap) {
          InlineMap inlineMap = (InlineMap) child;
          if (!inlineMap.isConstant()) {
            isConstant = false;
            break;
          }
        }
        else if (!((c%2)==0 && (child instanceof PropertyOrFieldReference))) {         
          isConstant = false;
          break;
        }
      }
    }
    if (isConstant) {
      Map<Object,Object> constantMap = new LinkedHashMap<Object,Object>();     
      int childCount = getChildCount();
      for (int c = 0; c < childCount; c++) {
        SpelNode keyChild = getChild(c++);
        SpelNode valueChild = getChild(c);
        Object key = null;
        Object value = null;
        if (keyChild instanceof Literal) {
          key = ((Literal) keyChild).getLiteralValue().getValue();
        }
View Full Code Here

    else {
      Map<Object, Object> returnValue = new LinkedHashMap<Object, Object>();
      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);
View Full Code Here

TOP

Related Classes of org.springframework.expression.spel.SpelNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.