Java Code Examples for javax.el.ELContext#isPropertyResolved()
The following examples show how to use
javax.el.ELContext#isPropertyResolved() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ELResolverImpl.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
@Override public Object getValue(ELContext context, Object base, Object property) throws NullPointerException, PropertyNotFoundException, ELException { if (context == null) { throw new NullPointerException(); } if (base == null) { context.setPropertyResolved(true); if (property != null) { try { return this.variableResolver.resolveVariable(property .toString()); } catch (javax.servlet.jsp.el.ELException e) { throw new ELException(e.getMessage(), e.getCause()); } } } if (!context.isPropertyResolved()) { return elResolver.getValue(context, base, property); } return null; }
Example 2
Source File: ELResolverImpl.java From tomcatsrc with Apache License 2.0 | 6 votes |
@Override public Object getValue(ELContext context, Object base, Object property) throws NullPointerException, PropertyNotFoundException, ELException { if (context == null) { throw new NullPointerException(); } if (base == null) { context.setPropertyResolved(true); if (property != null) { try { return this.variableResolver.resolveVariable(property .toString()); } catch (javax.servlet.jsp.el.ELException e) { throw new ELException(e.getMessage(), e.getCause()); } } } if (!context.isPropertyResolved()) { return elResolver.getValue(context, base, property); } return null; }
Example 3
Source File: UelUtil.java From scipio-erp with Apache License 2.0 | 6 votes |
@Override public void setValue(ELContext context, Object base, Object property, Object val) { super.setValue(context, base, property, val); if (!context.isPropertyResolved() && base == null) { if (Debug.verboseOn()) { Debug.logVerbose("ExtendedCompositeResolver.setValue: base = " + base + ", property = " + property + ", value = " + val, module); } try { BasicContext elContext = (BasicContext) context; elContext.variables.put(property.toString(), val); context.setPropertyResolved(true); } catch (ClassCastException e) { Debug.logInfo(e.getMessage(), module); } } }
Example 4
Source File: ELResolverImpl.java From tomcatsrc with Apache License 2.0 | 6 votes |
@Override public Class<?> getType(ELContext context, Object base, Object property) throws NullPointerException, PropertyNotFoundException, ELException { if (context == null) { throw new NullPointerException(); } if (base == null) { context.setPropertyResolved(true); if (property != null) { try { Object obj = this.variableResolver.resolveVariable(property .toString()); return (obj != null) ? obj.getClass() : null; } catch (javax.servlet.jsp.el.ELException e) { throw new ELException(e.getMessage(), e.getCause()); } } } if (!context.isPropertyResolved()) { return elResolver.getType(context, base, property); } return null; }
Example 5
Source File: ELResolverImpl.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
@Override public void setValue(ELContext context, Object base, Object property, Object value) throws NullPointerException, PropertyNotFoundException, PropertyNotWritableException, ELException { if (context == null) { throw new NullPointerException(); } if (base == null) { context.setPropertyResolved(true); throw new PropertyNotWritableException( "Legacy VariableResolver wrapped, not writable"); } if (!context.isPropertyResolved()) { elResolver.setValue(context, base, property, value); } }
Example 6
Source File: ELResolverImpl.java From tomcatsrc with Apache License 2.0 | 6 votes |
@Override public void setValue(ELContext context, Object base, Object property, Object value) throws NullPointerException, PropertyNotFoundException, PropertyNotWritableException, ELException { if (context == null) { throw new NullPointerException(); } if (base == null) { context.setPropertyResolved(true); throw new PropertyNotWritableException( "Legacy VariableResolver wrapped, not writable"); } if (!context.isPropertyResolved()) { elResolver.setValue(context, base, property, value); } }
Example 7
Source File: ELResolverImpl.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Override public Class<?> getType(ELContext context, Object base, Object property) { Objects.requireNonNull(context); if (base == null) { context.setPropertyResolved(base, property); if (property != null) { try { Object obj = this.variableResolver.resolveVariable(property .toString()); return (obj != null) ? obj.getClass() : null; } catch (javax.servlet.jsp.el.ELException e) { throw new ELException(e.getMessage(), e.getCause()); } } } if (!context.isPropertyResolved()) { return elResolver.getType(context, base, property); } return null; }
Example 8
Source File: ELResolverImpl.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Override public Object getValue(ELContext context, Object base, Object property) { Objects.requireNonNull(context); if (base == null) { context.setPropertyResolved(base, property); if (property != null) { try { return this.variableResolver.resolveVariable(property .toString()); } catch (javax.servlet.jsp.el.ELException e) { throw new ELException(e.getMessage(), e.getCause()); } } } if (!context.isPropertyResolved()) { return elResolver.getValue(context, base, property); } return null; }
Example 9
Source File: ELSupport.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Coerce an object to a string. * @param ctx the context in which this conversion is taking place * @param obj the object to convert * @return the String value of the object */ public static final String coerceToString(final ELContext ctx, final Object obj) { if (ctx != null) { boolean originalIsPropertyResolved = ctx.isPropertyResolved(); try { Object result = ctx.getELResolver().convertToType(ctx, obj, String.class); if (ctx.isPropertyResolved()) { return (String) result; } } finally { ctx.setPropertyResolved(originalIsPropertyResolved); } } if (obj == null) { return ""; } else if (obj instanceof String) { return (String) obj; } else if (obj instanceof Enum<?>) { return ((Enum<?>) obj).name(); } else { return obj.toString(); } }
Example 10
Source File: JasperELResolver.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Override public Object getValue(ELContext context, Object base, Object property) throws NullPointerException, PropertyNotFoundException, ELException { context.setPropertyResolved(false); int start; Object result = null; if (base == null) { // call implicit and app resolvers int index = 1 /* implicit */ + appResolversSize; for (int i = 0; i < index; i++) { result = resolvers[i].getValue(context, base, property); if (context.isPropertyResolved()) { return result; } } // skip collection-based resolvers (map, resource, list, array, and // bean) start = index + 5; } else { // skip implicit resolver only start = 1; } for (int i = start; i < size; i++) { result = resolvers[i].getValue(context, base, property); if (context.isPropertyResolved()) { return result; } } return null; }
Example 11
Source File: JasperELResolver.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public Object getValue(ELContext context, Object base, Object property) throws NullPointerException, PropertyNotFoundException, ELException { context.setPropertyResolved(false); int start; Object result = null; if (base == null) { // call implicit and app resolvers int index = 1 /* implicit */ + appResolversSize; for (int i = 0; i < index; i++) { result = resolvers[i].getValue(context, base, property); if (context.isPropertyResolved()) { return result; } } // skip stream, static and collection-based resolvers (map, // resource, list, array) and bean start = index + 7; } else { // skip implicit resolver only start = 1; } int size = resolversSize.get(); for (int i = start; i < size; i++) { result = resolvers[i].getValue(context, base, property); if (context.isPropertyResolved()) { return result; } } return null; }
Example 12
Source File: JasperELResolver.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Override public Object invoke(ELContext context, Object base, Object method, Class<?>[] paramTypes, Object[] params) { String targetMethod = coerceToString(method); if (targetMethod.length() == 0) { throw new ELException(new NoSuchMethodException()); } context.setPropertyResolved(false); Object result = null; // skip implicit and call app resolvers int index = 1 /* implicit */ + appResolversSize; for (int i = 1; i < index; i++) { result = resolvers[i].invoke( context, base, targetMethod, paramTypes, params); if (context.isPropertyResolved()) { return result; } } // skip map, resource, list, and array resolvers index += 4; // call bean and the rest of resolvers for (int i = index; i < size; i++) { result = resolvers[i].invoke( context, base, targetMethod, paramTypes, params); if (context.isPropertyResolved()) { return result; } } return null; }
Example 13
Source File: ELSupport.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * Convert an object to Boolean. * Null and empty string are false. * @param ctx the context in which this conversion is taking place * @param obj the object to convert * @param primitive is the target a primitive in which case coercion to null * is not permitted * @return the Boolean value of the object * @throws ELException if object is not Boolean or String */ public static final Boolean coerceToBoolean(final ELContext ctx, final Object obj, boolean primitive) throws ELException { if (ctx != null) { boolean originalIsPropertyResolved = ctx.isPropertyResolved(); try { Object result = ctx.getELResolver().convertToType(ctx, obj, Boolean.class); if (ctx.isPropertyResolved()) { return (Boolean) result; } } finally { ctx.setPropertyResolved(originalIsPropertyResolved); } } if (!COERCE_TO_ZERO && !primitive) { if (obj == null) { return null; } } if (obj == null || "".equals(obj)) { return Boolean.FALSE; } if (obj instanceof Boolean) { return (Boolean) obj; } if (obj instanceof String) { return Boolean.valueOf((String) obj); } throw new ELException(MessageFactory.get("error.convert", obj, obj.getClass(), Boolean.class)); }
Example 14
Source File: JasperELResolver.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public Object invoke(ELContext context, Object base, Object method, Class<?>[] paramTypes, Object[] params) { String targetMethod = coerceToString(method); if (targetMethod.length() == 0) { throw new ELException(new NoSuchMethodException()); } context.setPropertyResolved(false); Object result = null; // skip implicit and call app resolvers int index = 1 /* implicit */ + appResolversSize; for (int i = 1; i < index; i++) { result = resolvers[i].invoke( context, base, targetMethod, paramTypes, params); if (context.isPropertyResolved()) { return result; } } // skip map, resource, list, and array resolvers index += 4; // call bean and the rest of resolvers for (int i = index; i < size; i++) { result = resolvers[i].invoke( context, base, targetMethod, paramTypes, params); if (context.isPropertyResolved()) { return result; } } return null; }
Example 15
Source File: ELSupport.java From Tomcat8-Source-Read with MIT License | 5 votes |
public static final Number coerceToNumber(final ELContext ctx, final Object obj, final Class<?> type) throws ELException { if (ctx != null) { boolean originalIsPropertyResolved = ctx.isPropertyResolved(); try { Object result = ctx.getELResolver().convertToType(ctx, obj, type); if (ctx.isPropertyResolved()) { return (Number) result; } } finally { ctx.setPropertyResolved(originalIsPropertyResolved); } } if (!COERCE_TO_ZERO) { if (obj == null && !type.isPrimitive()) { return null; } } if (obj == null || "".equals(obj)) { return coerceToNumber(ZERO, type); } if (obj instanceof String) { return coerceToNumber((String) obj, type); } if (ELArithmetic.isNumber(obj)) { return coerceToNumber((Number) obj, type); } if (obj instanceof Character) { return coerceToNumber(Short.valueOf((short) ((Character) obj) .charValue()), type); } throw new ELException(MessageFactory.get("error.convert", obj, obj.getClass(), type)); }
Example 16
Source File: JuelConnector.java From scipio-erp with Apache License 2.0 | 5 votes |
@Override public void setValue(Bindings bindings, ELContext context, Object value) throws ELException { if (!lvalue) { throw new ELException(LocalMessages.get("error.value.set.rvalue")); } Object base = null; try { base = prefix.eval(bindings, context); } catch (Exception e) { if (Debug.verboseOn()) { Debug.logVerbose(e, module); } } Object property = getProperty(bindings, context); if (property == null && strict) { throw new PropertyNotFoundException(LocalMessages.get("error.property.property.notfound", "null", base)); } if (base == null) { base = UelUtil.autoVivifyListOrMap(property); if (Debug.verboseOn()) { Debug.logVerbose("ExtendedAstBracket.setValue auto-vivify base: " + base + ", property = " + property, module); } prefix.setValue(bindings, context, base); } context.getELResolver().setValue(context, base, property, value); if (!context.isPropertyResolved()) { throw new PropertyNotFoundException(LocalMessages.get("error.property.property.notfound", property, base)); } }
Example 17
Source File: JuelConnector.java From scipio-erp with Apache License 2.0 | 5 votes |
@Override public void setValue(Bindings bindings, ELContext context, Object value) throws ELException { if (!lvalue) { throw new ELException(LocalMessages.get("error.value.set.rvalue")); } Object base = null; try { base = prefix.eval(bindings, context); } catch (Exception e) { if (Debug.verboseOn()) { Debug.logVerbose(e, module); } } Object property = getProperty(bindings, context); if (property == null && strict) { throw new PropertyNotFoundException(LocalMessages.get("error.property.property.notfound", "null", base)); } if (base == null) { base = UelUtil.autoVivifyListOrMap(property); if (Debug.verboseOn()) { Debug.logVerbose("ExtendedAstDot.setValue auto-vivify base: " + base + ", property = " + property, module); } prefix.setValue(bindings, context, base); } context.getELResolver().setValue(context, base, property, value); if (!context.isPropertyResolved()) { throw new PropertyNotFoundException(LocalMessages.get("error.property.property.notfound", property, base)); } }
Example 18
Source File: ELSupport.java From Tomcat8-Source-Read with MIT License | 5 votes |
private static final Character coerceToCharacter(final ELContext ctx, final Object obj) throws ELException { if (ctx != null) { boolean originalIsPropertyResolved = ctx.isPropertyResolved(); try { Object result = ctx.getELResolver().convertToType(ctx, obj, Character.class); if (ctx.isPropertyResolved()) { return (Character) result; } } finally { ctx.setPropertyResolved(originalIsPropertyResolved); } } if (obj == null || "".equals(obj)) { return Character.valueOf((char) 0); } if (obj instanceof String) { return Character.valueOf(((String) obj).charAt(0)); } if (ELArithmetic.isNumber(obj)) { return Character.valueOf((char) ((Number) obj).shortValue()); } Class<?> objType = obj.getClass(); if (obj instanceof Character) { return (Character) obj; } throw new ELException(MessageFactory.get("error.convert", obj, objType, Character.class)); }
Example 19
Source File: ELSupport.java From Tomcat8-Source-Read with MIT License | 4 votes |
public static final Object coerceToType(final ELContext ctx, final Object obj, final Class<?> type) throws ELException { if (ctx != null) { boolean originalIsPropertyResolved = ctx.isPropertyResolved(); try { Object result = ctx.getELResolver().convertToType(ctx, obj, type); if (ctx.isPropertyResolved()) { return result; } } finally { ctx.setPropertyResolved(originalIsPropertyResolved); } } if (type == null || Object.class.equals(type) || (obj != null && type.isAssignableFrom(obj.getClass()))) { return obj; } if (!COERCE_TO_ZERO) { if (obj == null && !type.isPrimitive() && !String.class.isAssignableFrom(type)) { return null; } } if (String.class.equals(type)) { return coerceToString(ctx, obj); } if (ELArithmetic.isNumberType(type)) { return coerceToNumber(ctx, obj, type); } if (Character.class.equals(type) || Character.TYPE == type) { return coerceToCharacter(ctx, obj); } if (Boolean.class.equals(type) || Boolean.TYPE == type) { return coerceToBoolean(ctx, obj, Boolean.TYPE == type); } if (type.isEnum()) { return coerceToEnum(ctx, obj, type); } // new to spec if (obj == null) return null; if (obj instanceof String) { PropertyEditor editor = PropertyEditorManager.findEditor(type); if (editor == null) { if ("".equals(obj)) { return null; } throw new ELException(MessageFactory.get("error.convert", obj, obj.getClass(), type)); } else { try { editor.setAsText((String) obj); return editor.getValue(); } catch (RuntimeException e) { if ("".equals(obj)) { return null; } throw new ELException(MessageFactory.get("error.convert", obj, obj.getClass(), type), e); } } } // Handle special case because the syntax for the empty set is the same // for an empty map. The parser will always parse {} as an empty set. if (obj instanceof Set && type == Map.class && ((Set<?>) obj).isEmpty()) { return Collections.EMPTY_MAP; } // Handle arrays if (type.isArray() && obj.getClass().isArray()) { return coerceToArray(ctx, obj, type); } throw new ELException(MessageFactory.get("error.convert", obj, obj.getClass(), type)); }
Example 20
Source File: RootResolver.java From validator-web with Apache License 2.0 | 4 votes |
private boolean resolve(ELContext context, Object base, Object property) { context.setPropertyResolved(base == null && property instanceof String); return context.isPropertyResolved(); }