Package org.springframework.expression

Examples of org.springframework.expression.TypeConverter


          + "." + m.getName(), name);
    }

    // Convert arguments if necessary and remap them for varargs if required
    if (functionArgs != null) {
      TypeConverter converter = state.getEvaluationContext().getTypeConverter();
      ReflectionHelper.convertAllArguments(m.getParameterTypes(), m.isVarArgs(), converter, functionArgs);
    }
    if (m.isVarArgs()) {
      functionArgs = ReflectionHelper.setupArgumentsForVarargsInvocation(m.getParameterTypes(), functionArgs);
    }
View Full Code Here


   * registered type converter.
   * </ol>
   */
  public MethodExecutor resolve(EvaluationContext context, Object targetObject, String name, Class<?>[] argumentTypes) throws AccessException {
    try {
      TypeConverter typeConverter = context.getTypeConverter();
      Class<?> type = (targetObject instanceof Class ? (Class<?>) targetObject : targetObject.getClass());
      Method[] methods = type.getMethods();
      Method closeMatch = null;
      int[] argsToConvert = null;
      boolean multipleOptions = false;
View Full Code Here

   * </ol>
   */
  public ConstructorExecutor resolve(EvaluationContext context, String typename, Class<?>[] argumentTypes)
      throws AccessException {
    try {
      TypeConverter typeConverter = context.getTypeConverter();
      Class<?> type = context.getTypeLocator().findType(typename);
      Constructor[] ctors = type.getConstructors();
      Constructor closeMatch = null;
      int[] argsToConvert = null;
      Constructor matchRequiringConversion = null;
View Full Code Here

    assertEquals(1, prefixes.size());
  }

  @Test
  public void testStandardTypeConverter() throws EvaluationException {
    TypeConverter tc = new StandardTypeConverter();
    tc.convertValue(3, TypeDescriptor.forObject(3), TypeDescriptor.valueOf(Double.class));
  }
View Full Code Here

   * registered type converter.
   * </ol>
   */
  public MethodExecutor resolve(EvaluationContext context, Object targetObject, String name, Class<?>[] argumentTypes) throws AccessException {
    try {
      TypeConverter typeConverter = context.getTypeConverter();
      Class<?> type = (targetObject instanceof Class ? (Class<?>) targetObject : targetObject.getClass());
      Method[] methods = type.getMethods();
     
      // If a filter is registered for this type, call it
      MethodFilter methodfilter = (filters==null?null:filters.get(type));
View Full Code Here

          + "." + method.getName(), name);
    }

    // Convert arguments if necessary and remap them for varargs if required
    if (functionArgs != null) {
      TypeConverter converter = state.getEvaluationContext().getTypeConverter();
      ReflectionHelper.convertAllArguments(converter, functionArgs, method);
    }
    if (method.isVarArgs()) {
      functionArgs = ReflectionHelper.setupArgumentsForVarargsInvocation(method.getParameterTypes(), functionArgs);
    }
View Full Code Here

      for (int i = 0; i < dimensions.length; i++) {
        if (dimensions[i] == null) {
          throw new SpelEvaluationException(getStartPosition(), SpelMessage.MISSING_ARRAY_DIMENSION);
        }
      }
      TypeConverter typeConverter = state.getEvaluationContext().getTypeConverter();

      // Shortcut for 1 dimensional
      if (dimensions.length == 1) {
        TypedValue o = dimensions[0].getTypedValue(state);
        int arraySize = ExpressionUtils.toInt(typeConverter, o);
        newArray = Array.newInstance(componentType, arraySize);
      } else {
        // Multi-dimensional - hold onto your hat!
        int[] dims = new int[dimensions.length];
        for (int d = 0; d < dimensions.length; d++) {
          TypedValue o = dimensions[d].getTypedValue(state);
          dims[d] = ExpressionUtils.toInt(typeConverter, o);
        }
        newArray = Array.newInstance(componentType, dims);
      }
    } else {
      // There is an initializer
      if (dimensions.length > 1) {
        // There is an initializer but this is a multi-dimensional array (e.g. new int[][]{{1,2},{3,4}}) - this
        // is not currently supported
        throw new SpelEvaluationException(getStartPosition(),
            SpelMessage.MULTIDIM_ARRAY_INITIALIZER_NOT_SUPPORTED);
      }
      TypeConverter typeConverter = state.getEvaluationContext().getTypeConverter();
      InlineList initializer = (InlineList) getChild(1);
      // If a dimension was specified, check it matches the initializer length
      if (dimensions[0] != null) {
        TypedValue dValue = dimensions[0].getTypedValue(state);
        int i = ExpressionUtils.toInt(typeConverter, dValue);
View Full Code Here

    }

    argumentConversionOccurred = false;
    // Convert arguments if necessary and remap them for varargs if required
    if (functionArgs != null) {
      TypeConverter converter = state.getEvaluationContext().getTypeConverter();
      argumentConversionOccurred = ReflectionHelper.convertAllArguments(converter, functionArgs, method);
    }
    if (method.isVarArgs()) {
      functionArgs = ReflectionHelper.setupArgumentsForVarargsInvocation(method.getParameterTypes(), functionArgs);
    }
View Full Code Here

      for (SpelNodeImpl dimension : this.dimensions) {
        if (dimension == null) {
          throw new SpelEvaluationException(getStartPosition(), SpelMessage.MISSING_ARRAY_DIMENSION);
        }
      }
      TypeConverter typeConverter = state.getEvaluationContext().getTypeConverter();

      // Shortcut for 1 dimensional
      if (this.dimensions.length == 1) {
        TypedValue o = this.dimensions[0].getTypedValue(state);
        int arraySize = ExpressionUtils.toInt(typeConverter, o);
        newArray = Array.newInstance(componentType, arraySize);
      }
      else {
        // Multi-dimensional - hold onto your hat!
        int[] dims = new int[this.dimensions.length];
        for (int d = 0; d < this.dimensions.length; d++) {
          TypedValue o = this.dimensions[d].getTypedValue(state);
          dims[d] = ExpressionUtils.toInt(typeConverter, o);
        }
        newArray = Array.newInstance(componentType, dims);
      }
    }
    else {
      // There is an initializer
      if (this.dimensions.length > 1) {
        // There is an initializer but this is a multi-dimensional array (e.g. new int[][]{{1,2},{3,4}}) - this
        // is not currently supported
        throw new SpelEvaluationException(getStartPosition(),
            SpelMessage.MULTIDIM_ARRAY_INITIALIZER_NOT_SUPPORTED);
      }
      TypeConverter typeConverter = state.getEvaluationContext().getTypeConverter();
      InlineList initializer = (InlineList) getChild(1);
      // If a dimension was specified, check it matches the initializer length
      if (this.dimensions[0] != null) {
        TypedValue dValue = this.dimensions[0].getTypedValue(state);
        int i = ExpressionUtils.toInt(typeConverter, dValue);
View Full Code Here

  @Override
  public MethodExecutor resolve(EvaluationContext context, Object targetObject, String name,
      List<TypeDescriptor> argumentTypes) throws AccessException {

    try {
      TypeConverter typeConverter = context.getTypeConverter();
      Class<?> type = (targetObject instanceof Class ? (Class<?>) targetObject : targetObject.getClass());
      List<Method> methods = new ArrayList<Method>(Arrays.asList(getMethods(type, targetObject)));

      // If a filter is registered for this type, call it
      MethodFilter filter = (this.filters != null ? this.filters.get(type) : null);
View Full Code Here

TOP

Related Classes of org.springframework.expression.TypeConverter

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.