public TypedValue lookupVariable(String name) { Object value = this.relatedContext.lookupVariable(name); return (value != null ? new TypedValue(value) : TypedValue.NULL); }
public TypedValue lookupVariable(String name) { Object value = this.relatedContext.lookupVariable(name); return (value != null ? new TypedValue(value) : TypedValue.NULL); }
private Object findFilterTarget(String filterTargetName, EvaluationContext ctx, MethodInvocation mi) { Object filterTarget = null; if (filterTargetName.length() > 0) { filterTarget = ctx.lookupVariable(filterTargetName); if (filterTarget == null) { throw new IllegalArgumentException( "Filter target was null, or no argument with name " + filterTargetName + " found in method"); } } else if (mi.getArguments().length == 1) { Object arg = mi.getArguments()[0]; if (arg.getClass().isArray() || arg instanceof Collection<?>) { filterTarget = arg; } if (filterTarget == null) { throw new IllegalArgumentException( "A PreFilter expression was set but the method argument type" + arg.getClass() + " is not filterable"); } } if (filterTarget.getClass().isArray()) { throw new IllegalArgumentException( "Pre-filtering on array types is not supported. " + "Using a Collection will solve this problem"); } return filterTarget; }
private Object findFilterTarget(String filterTargetName, EvaluationContext ctx, MethodInvocation mi) { Object filterTarget = null; if (filterTargetName.length() > 0) { filterTarget = ctx.lookupVariable(filterTargetName); if (filterTarget == null) { throw new IllegalArgumentException( "Filter target was null, or no argument with name " + filterTargetName + " found in method"); } } else if (mi.getArguments().length == 1) { Object arg = mi.getArguments()[0]; if (arg.getClass().isArray() || arg instanceof Collection<?>) { filterTarget = arg; } if (filterTarget == null) { throw new IllegalArgumentException( "A PreFilter expression was set but the method argument type" + arg.getClass() + " is not filterable"); } } if (filterTarget.getClass().isArray()) { throw new IllegalArgumentException( "Pre-filtering on array types is not supported. " + "Using a Collection will solve this problem"); } return filterTarget; }
@Override public Object lookupVariable(String name) { return this.delegate.lookupVariable(name); } }
public Object lookupVariable(String name) { Object result = delegate.lookupVariable(name); if (result == null) { result = pageContext.findAttribute(name); } return result; } }
public Object lookupVariable(String name) { Object result = delegate.lookupVariable(name); if (result == null) { result = pageContext.findAttribute(name); } return result; } }
public TypedValue lookupVariable(String name) { Object value = this.relatedContext.lookupVariable(name); return (value != null ? new TypedValue(value) : TypedValue.NULL); }
private String inspectFunctions(EvaluationContext context) { StringBuilder message = new StringBuilder(); Set<String> names = new HashSet<>(functions.size()); message.append("Registered functions: \n"); for (Method function : functions) { names.add(function.getName()); } for (String name : names) { Object obj = context.lookupVariable(name); if (obj instanceof Method) { message.append(" #").append(name).append(" -> ").append(obj).append('\n'); } } return message.toString(); } }
private Object findFilterTarget(String filterTargetName, EvaluationContext ctx, MethodInvocation mi) { Object filterTarget = null; if (filterTargetName.length() > 0) { filterTarget = ctx.lookupVariable(filterTargetName); if (filterTarget == null) { throw new IllegalArgumentException("Filter target was null, or no argument with name " + filterTargetName + " found in method"); } } else if (mi.getArguments().length == 1) { Object arg = mi.getArguments()[0]; if (arg.getClass().isArray() || arg instanceof Collection<?>) { filterTarget = arg; } if (filterTarget == null) { throw new IllegalArgumentException("A PreFilter expression was set but the method argument type" + arg.getClass() + " is not filterable"); } } if (filterTarget.getClass().isArray()) { throw new IllegalArgumentException("Pre-filtering on array types is not supported. " + "Using a Collection will solve this problem"); } return filterTarget; }
/** * Return the thread local cached resolver and if not present * use the provided {@link EvaluationContext} to determine whether * a {@link ParameterResolver} is accessible, with the well known * reference {@literal "resolver"}. The thread local cached resolver * takes precedence as it is considered to be more correct than * the set-once EvaluationContext resolver. * * @param ctx the context that holds the appropriate * {@link ParameterResolver} * @return either a {@link ParameterResolver} on the context or * a thread local version */ protected ParameterResolver getParamResolver(EvaluationContext ctx) { ParameterResolver resolver = getResolver(); if (resolver == null) { Object oResolver = ctx.lookupVariable("resolver"); if (oResolver instanceof ParameterResolver) { resolver = (ParameterResolver) oResolver; } } return resolver; }
private Object findFilterTarget(String filterTargetName, EvaluationContext ctx, MethodInvocation mi) { Object filterTarget = null; if (filterTargetName.length() > 0) { filterTarget = ctx.lookupVariable(filterTargetName); if (filterTarget == null) { throw new IllegalArgumentException( "Filter target was null, or no argument with name " + filterTargetName + " found in method"); } } else if (mi.getArguments().length == 1) { Object arg = mi.getArguments()[0]; if (arg.getClass().isArray() || arg instanceof Collection<?>) { filterTarget = arg; } if (filterTarget == null) { throw new IllegalArgumentException( "A PreFilter expression was set but the method argument type" + arg.getClass() + " is not filterable"); } } if (filterTarget.getClass().isArray()) { throw new IllegalArgumentException( "Pre-filtering on array types is not supported. " + "Using a Collection will solve this problem"); } return filterTarget; }
public Object lookupVariable(final String name) { if (this.expressionObjects != null && this.expressionObjects.containsObject(name)) { final Object result = this.expressionObjects.getObject(name); if (result != null) { // We need to first check if we are in a restricted environment. If so, restrict access to the request. if (this.requestParametersRestricted && (StandardExpressionObjectFactory.REQUEST_EXPRESSION_OBJECT_NAME.equals(name) || StandardExpressionObjectFactory.HTTP_SERVLET_REQUEST_EXPRESSION_OBJECT_NAME.equals(name))) { return RestrictedRequestAccessUtils.wrapRequestObject(result); } return result; } } if (this.additionalVariables != null && this.additionalVariables.containsKey(name)) { final Object result = this.additionalVariables.get(name); if (result != null) { return result; } } // fall back to delegate return this.delegate.lookupVariable(name); }
public Object lookupVariable(final String name) { if (this.expressionObjects != null && this.expressionObjects.containsObject(name)) { final Object result = this.expressionObjects.getObject(name); if (result != null) { // We need to first check if we are in a restricted environment. If so, restrict access to the request. if (this.requestParametersRestricted && (StandardExpressionObjectFactory.REQUEST_EXPRESSION_OBJECT_NAME.equals(name) || StandardExpressionObjectFactory.HTTP_SERVLET_REQUEST_EXPRESSION_OBJECT_NAME.equals(name))) { return RestrictedRequestAccessUtils.wrapRequestObject(result); } return result; } } if (this.additionalVariables != null && this.additionalVariables.containsKey(name)) { final Object result = this.additionalVariables.get(name); if (result != null) { return result; } } // fall back to delegate return this.delegate.lookupVariable(name); }
public Object lookupVariable(final String name) { if (this.expressionObjects != null && this.expressionObjects.containsObject(name)) { final Object result = this.expressionObjects.getObject(name); if (result != null) { // We need to first check if we are in a restricted environment. If so, restrict access to the request. if (this.requestParametersRestricted && (StandardExpressionObjectFactory.REQUEST_EXPRESSION_OBJECT_NAME.equals(name) || StandardExpressionObjectFactory.HTTP_SERVLET_REQUEST_EXPRESSION_OBJECT_NAME.equals(name))) { return RestrictedRequestAccessUtils.wrapRequestObject(result); } return result; } } if (this.additionalVariables != null && this.additionalVariables.containsKey(name)) { final Object result = this.additionalVariables.get(name); if (result != null) { return result; } } // fall back to delegate return this.delegate.lookupVariable(name); }
public Object lookupVariable(final String name) { if (this.expressionObjects != null && this.expressionObjects.containsObject(name)) { final Object result = this.expressionObjects.getObject(name); if (result != null) { // We need to first check if we are in a restricted environment. If so, restrict access to the request. if (this.requestParametersRestricted && (StandardExpressionObjectFactory.REQUEST_EXPRESSION_OBJECT_NAME.equals(name) || StandardExpressionObjectFactory.HTTP_SERVLET_REQUEST_EXPRESSION_OBJECT_NAME.equals(name))) { return RestrictedRequestAccessUtils.wrapRequestObject(result); } return result; } } if (this.additionalVariables != null && this.additionalVariables.containsKey(name)) { final Object result = this.additionalVariables.get(name); if (result != null) { return result; } } // fall back to delegate return this.delegate.lookupVariable(name); }
public Object lookupVariable(final String name) { if (this.expressionObjects != null && this.expressionObjects.containsObject(name)) { final Object result = this.expressionObjects.getObject(name); if (result != null) { // We need to first check if we are in a restricted environment. If so, restrict access to the request. if (this.requestParametersRestricted && (StandardExpressionObjectFactory.REQUEST_EXPRESSION_OBJECT_NAME.equals(name) || StandardExpressionObjectFactory.HTTP_SERVLET_REQUEST_EXPRESSION_OBJECT_NAME.equals(name))) { return RestrictedRequestAccessUtils.wrapRequestObject(result); } return result; } } if (this.additionalVariables != null && this.additionalVariables.containsKey(name)) { final Object result = this.additionalVariables.get(name); if (result != null) { return result; } } // fall back to delegate return this.delegate.lookupVariable(name); }
@Override public <T extends AbstractToscaType> T getElementInDependencies(Class<T> elementClass, Set<CSARDependency> dependencies, String... keyValueFilters) { return (T) ToscaContext.get().getElement(elementClass, element -> { if (!dependencies.contains(new CSARDependency(element.getArchiveName(), element.getArchiveVersion()))) { return false; } EvaluationContext context = new StandardEvaluationContext(element); for (int i = 0; i < keyValueFilters.length; i += 2) { String field = keyValueFilters[0]; String value = keyValueFilters[1]; if (!value.equals(context.lookupVariable(field).toString())) { return false; } } return true; }).orElse(null); }