Package org.springframework.expression.spel

Examples of org.springframework.expression.spel.SpelEvaluationException


      }
      return new TypedValue(String.valueOf(this.target.charAt(this.index)));
    }

    public void setValue(Object newValue) {
      throw new SpelEvaluationException(getStartPosition(), SpelMessage.INDEXING_NOT_SUPPORTED_FOR_TYPE,
          this.td.toString());
    }
View Full Code Here


  @Override
  public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException {
    try {
      Boolean value = children[0].getValue(state, Boolean.class);
      if (value == null) {
        throw new SpelEvaluationException(SpelMessage.TYPE_CONVERSION_ERROR, "null", "boolean");
      }
      return BooleanTypedValue.forValue(!value);
    }
    catch (SpelEvaluationException see) {
      see.setPosition(getChild(0).getStartPosition());
View Full Code Here

    }
  }

  private void assertValueNotNull(Boolean value) {
    if (value == null) {
      throw new SpelEvaluationException(SpelMessage.TYPE_CONVERSION_ERROR, "null", "boolean");
    }
  }
View Full Code Here

    }
  }

  private void assertValueNotNull(Boolean value) {
    if (value == null) {
      throw new SpelEvaluationException(SpelMessage.TYPE_CONVERSION_ERROR, "null", "boolean");
    }
  }
View Full Code Here

      try {
        newValue = state.operate(Operation.SUBTRACT, returnValue.getValue(), 1);
      } catch (SpelEvaluationException see) {
        if (see.getMessageCode()==SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES) {
          // This means the operand is not decrementable
          throw new SpelEvaluationException(operand.getStartPosition(),SpelMessage.OPERAND_NOT_DECREMENTABLE,operand.toStringAST());
        } else {
          throw see;
        }
      }
    }

    // set the new value
    try {
      lvalue.setValue(newValue.getValue());
    } catch (SpelEvaluationException see) {
      // if unable to set the value the operand is not writable (e.g. 1-- )
      if (see.getMessageCode()==SpelMessage.SETVALUE_NOT_SUPPORTED) {
        throw new SpelEvaluationException(operand.getStartPosition(),SpelMessage.OPERAND_NOT_DECREMENTABLE);
      } else {
        throw see;
      }
    }
View Full Code Here

      try {
        newValue = state.operate(Operation.ADD, returnValue.getValue(), 1);
      } catch (SpelEvaluationException see) {
        if (see.getMessageCode()==SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES) {
          // This means the operand is not incrementable
          throw new SpelEvaluationException(operand.getStartPosition(),SpelMessage.OPERAND_NOT_INCREMENTABLE,operand.toStringAST());
        } else {
          throw see;
        }
      }
    }

    // set the name value
    try {
      lvalue.setValue(newValue.getValue());
    } catch (SpelEvaluationException see) {
      // if unable to set the value the operand is not writable (e.g. 1++ )
      if (see.getMessageCode()==SpelMessage.SETVALUE_NOT_SUPPORTED) {
        throw new SpelEvaluationException(operand.getStartPosition(),SpelMessage.OPERAND_NOT_INCREMENTABLE);
      } else {
        throw see;
      }
    }
View Full Code Here

              writeProperty(contextObject, eContext, this.name, newList);
              result = readProperty(contextObject, eContext, 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 {
          try {
            if (isWritableProperty(this.name,contextObject,eContext)) {
              Map<?,?> newMap = HashMap.class.newInstance();
              writeProperty(contextObject, eContext, name, newMap);
              result = readProperty(contextObject, eContext, 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 {
        // 'simple' object
        try {
          if (isWritableProperty(this.name,contextObject,eContext)) {
            Object newObject  = result.getTypeDescriptor().getType().newInstance();
            writeProperty(contextObject, eContext, name, newObject);
            result = readProperty(contextObject, eContext, this.name);
          }
        }
        catch (InstantiationException ex) {
          throw new SpelEvaluationException(getStartPosition(), ex,
              SpelMessage.UNABLE_TO_DYNAMICALLY_CREATE_OBJECT, result.getTypeDescriptor().getType());
        }
        catch (IllegalAccessException ex) {
          throw new SpelEvaluationException(getStartPosition(), ex,
              SpelMessage.UNABLE_TO_DYNAMICALLY_CREATE_OBJECT, result.getTypeDescriptor().getType());
        }       
      }
    }
    return result;
View Full Code Here

            return accessor.read(eContext, contextObject.getValue(), name);
          }
        }
      }
      catch (AccessException ae) {
        throw new SpelEvaluationException(ae, SpelMessage.EXCEPTION_DURING_PROPERTY_READ, name, ae.getMessage());
      }
    }
    if (contextObject.getValue() == null) {
      throw new SpelEvaluationException(SpelMessage.PROPERTY_OR_FIELD_NOT_READABLE_ON_NULL, name);
    }
    else {
      throw new SpelEvaluationException(getStartPosition(), SpelMessage.PROPERTY_OR_FIELD_NOT_READABLE, name,
          FormatHelper.formatClassNameForMessage(contextObjectClass));
    }
  }
View Full Code Here

            return;
          }
        }
      }
      catch (AccessException ae) {
        throw new SpelEvaluationException(getStartPosition(), ae, SpelMessage.EXCEPTION_DURING_PROPERTY_WRITE,
            name, ae.getMessage());
      }
    }
    if (contextObject.getValue()==null) {
      throw new SpelEvaluationException(getStartPosition(), SpelMessage.PROPERTY_OR_FIELD_NOT_WRITABLE_ON_NULL, name);
    }
    else {
      throw new SpelEvaluationException(getStartPosition(), SpelMessage.PROPERTY_OR_FIELD_NOT_WRITABLE, name,
          FormatHelper.formatClassNameForMessage(contextObjectClass));
    }
  }
View Full Code Here

          Throwable rootCause = ae.getCause().getCause();
          if (rootCause instanceof RuntimeException) {
            throw (RuntimeException) rootCause;
          } else {
            String typename = (String) this.children[0].getValueInternal(state).getValue();
            throw new SpelEvaluationException(getStartPosition(), rootCause,
                SpelMessage.CONSTRUCTOR_INVOCATION_PROBLEM, typename, FormatHelper
                    .formatMethodForMessage("", argumentTypes));
          }         
        }

        // at this point we know it wasn't a user problem so worth a retry if a better candidate can be found
        this.cachedExecutor = null;
      }
    }

    // either there was no accessor or it no longer exists
    String typename = (String) this.children[0].getValueInternal(state).getValue();
    executorToUse = findExecutorForConstructor(typename, argumentTypes, state);
    try {
      this.cachedExecutor = executorToUse;
      return executorToUse.execute(state.getEvaluationContext(), arguments);
    }
    catch (AccessException ae) {
      throw new SpelEvaluationException(getStartPosition(), ae, SpelMessage.CONSTRUCTOR_INVOCATION_PROBLEM,
          typename, FormatHelper.formatMethodForMessage("", argumentTypes));

    }
  }
View Full Code Here

TOP

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

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.