Package org.springframework.expression

Examples of org.springframework.expression.AccessException


          try {
            Date parsedDate = fromFormat.parse((String) arguments[1]);
            return new TypedValue(format.format(parsedDate));
          } catch (ParseException e) {
            throw new AccessException("Unable to format", e);
          }

      }

      return new TypedValue(format.format((Long)arguments[1]));
    }
    throw new AccessException("Unable to format");
  }
View Full Code Here


        Object[] ranges = ((List<?>) arguments[1]).toArray(new Object[0]);
        int searchIndex = Arrays.binarySearch(ranges, arguments[0]);
        return new TypedValue(ranges[Math.min(searchIndex < 0 ? -searchIndex - 1 : searchIndex, ranges.length - 1)]
            + "_range");
      } catch (Exception e) {
        throw new AccessException("Error finding range", e);
      }
    }
    throw new AccessException("Argument " + arguments[1] + " not a List");
  }
View Full Code Here

    if (arguments[1] instanceof Integer) {
      try {
        Integer buckets = ((Integer)arguments[1]);
        return new TypedValue(Math.abs(arguments[0].hashCode()) % buckets + "_hash");
      } catch (Exception e) {
        throw new AccessException("Error creating hash", e);
      }
    }
    throw new AccessException("Argument " + arguments[1] + " not an Integer");
  }
View Full Code Here

    if (argumentTypes.size() == 1) {
      return new DateFormatMethodExecutor("timestamp");
    } else if (argumentTypes.size() == 2 || argumentTypes.size()==3) {
      return new DateFormatMethodExecutor(null);
    } else {
      throw new AccessException("Too many or missing arguments");
    }
  }
View Full Code Here

            return new TypedValue(sublist.get(0) + "_list");
          }
        }
      }
    } else {
      throw new AccessException("Argument " + arguments[1] + " not a List");
    }
    // we didn't match anything, return default partition as 'list'
    return new TypedValue("list");
  }
View Full Code Here

    if (target instanceof Message<?>) {
      Map<?, ?> map = ((Message<?>)target).getHeaders();
      SimpleDateFormat format = new SimpleDateFormat((String)arguments[0]);
      return new TypedValue(format.format(map.get(getKey())));
    }
    throw new AccessException("Unable to format");
  }
View Full Code Here

        return new TypedValue(((Message<?>) target).getHeaders());
      } else {
        return new TypedValue(((Message<?>) target).getHeaders().get(name));
      }
    }
    throw new AccessException("Unable to read " + target + " using " + name);
  }
View Full Code Here

    return false;
  }

  @Override
  public void write(EvaluationContext context, Object target, String name, Object newValue) throws AccessException {
    throw new AccessException("Write not supported on default");
  }
View Full Code Here

    if (argumentTypes.size() == 1) {
      return new MessageDateFormatMethodExecutor("timestamp");
    } else if (argumentTypes.size() == 2 || argumentTypes.size()==3) {
      return new MessageDateFormatMethodExecutor();
    } else {
      throw new AccessException("Too many or missing arguments");
    }
  }
View Full Code Here

    @Override
    @SuppressWarnings("unchecked")
    public TypedValue read(final EvaluationContext context, final Object target, final String name)
            throws AccessException {
        if (target == null) {
            throw new AccessException("Cannot read property of null target");
        }
        if (!(target instanceof VariablesMap)) {
            // This can happen simply because we're applying the same
            // AST tree on a different class (Spring internally caches property accessors).
            // So this exception might be considered "normal" by Spring AST evaluator and
            // just use it to refresh the property accessor cache.
            throw new AccessException("Cannot read target of class " + target.getClass().getName());
        }
        return new TypedValue(((VariablesMap<String,?>)target).get(name));
    }
View Full Code Here

TOP

Related Classes of org.springframework.expression.AccessException

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.