/** * Converts an object to a specific type. * * <p>An <code>ELException</code> is thrown if an error occurs during * the conversion.</p> * * @param context The context of this evaluation. * @param obj The object to convert. * @param targetType The target type for the convertion. * @throws ELException thrown if errors occur. * * @since EL 3.0 */ @Override public Object convertToType(ELContext context, Object obj, Class<?> targetType) { context.setPropertyResolved(false); Object value = null; for (int i = 0; i < size; i++) { value = elResolvers[i].convertToType(context, obj, targetType); if (context.isPropertyResolved()) { return value; } } return null; }
ELResolver elResolver = getELResolver(); if (elResolver != null) { Object res = elResolver.convertToType(this, obj, targetType); if (isPropertyResolved()) { return res;
@Override public Object convertToType(ELContext context, Object obj, Class<?> targetType) { return delegate.convertToType(context, obj, targetType); } }
@Override public Object convertToType(ELContext context, Object obj, Class<?> type) { context.setPropertyResolved(false); int sz = this.size; for (int i = 0; i < sz; i++) { Object result = this.resolvers[i].convertToType(context, obj, type); if (context.isPropertyResolved()) { return result; } } return null; }
@Override public Object convertToType(ELContext context, Object obj, Class<?> type) { context.setPropertyResolved(false); int sz = this.size; for (int i = 0; i < sz; i++) { Object result = this.resolvers[i].convertToType(context, obj, type); if (context.isPropertyResolved()) { return result; } } return null; }
@Override public Object convertToType(ELContext context, Object obj, Class<?> type) { context.setPropertyResolved(false); int sz = this.size; Object result = null; for (int i = 0; i < sz; i++) { result = this.resolvers[i].convertToType(context, obj, type); if (context.isPropertyResolved()) { return result; } } return null; }
/** * Converts an object to a specific type. * * <p>An <code>ELException</code> is thrown if an error occurs during * the conversion.</p> * * @param context The context of this evaluation. * @param obj The object to convert. * @param targetType The target type for the convertion. * @throws ELException thrown if errors occur. * * @since EL 3.0 */ @Override public Object convertToType(ELContext context, Object obj, Class<?> targetType) { context.setPropertyResolved(false); Object value = null; for (int i = 0; i < size; i++) { value = elResolvers[i].convertToType(context, obj, targetType); if (context.isPropertyResolved()) { return value; } } return null; }
/** * Converts an object to a specific type. * * <p>An <code>ELException</code> is thrown if an error occurs during * the conversion.</p> * * @param context The context of this evaluation. * @param obj The object to convert. * @param targetType The target type for the convertion. * @throws ELException thrown if errors occur. * * @since EL 3.0 */ @Override public Object convertToType(ELContext context, Object obj, Class<?> targetType) { context.setPropertyResolved(false); Object value = null; for (int i = 0; i < size; i++) { value = elResolvers[i].convertToType(context, obj, targetType); if (context.isPropertyResolved()) { return value; } } return null; }
/** * Converts an object to a specific type. * * <p>An <code>ELException</code> is thrown if an error occurs during * the conversion.</p> * * @param context The context of this evaluation. * @param obj The object to convert. * @param targetType The target type for the convertion. * @throws ELException thrown if errors occur. * * @since EL 3.0 */ @Override public Object convertToType(ELContext context, Object obj, Class<?> targetType) { context.setPropertyResolved(false); Object value = null; for (int i = 0; i < size; i++) { value = elResolvers[i].convertToType(context, obj, targetType); if (context.isPropertyResolved()) { return value; } } return null; }
/** * Converts an object to a specific type. * * <p>An <code>ELException</code> is thrown if an error occurs during * the conversion.</p> * * @param context The context of this evaluation. * @param obj The object to convert. * @param targetType The target type for the convertion. * @throws ELException thrown if errors occur. * * @since EL 3.0 */ @Override public Object convertToType(ELContext context, Object obj, Class<?> targetType) { context.setPropertyResolved(false); Object value = null; for (int i = 0; i < size; i++) { value = elResolvers[i].convertToType(context, obj, targetType); if (context.isPropertyResolved()) { return value; } } return null; }
/** * Converts an object to a specific type. * * <p>An <code>ELException</code> is thrown if an error occurs during * the conversion.</p> * * @param context The context of this evaluation. * @param obj The object to convert. * @param targetType The target type for the convertion. * @throws ELException thrown if errors occur. * * @since EL 3.0 */ @Override public Object convertToType(ELContext context, Object obj, Class<?> targetType) { context.setPropertyResolved(false); Object value = null; for (int i = 0; i < size; i++) { value = elResolvers[i].convertToType(context, obj, targetType); if (context.isPropertyResolved()) { return value; } } return null; }
/** * Converts an object to a specific type. * * <p>An <code>ELException</code> is thrown if an error occurs during * the conversion.</p> * * @param context The context of this evaluation. * @param obj The object to convert. * @param targetType The target type for the convertion. * @throws ELException thrown if errors occur. * * @since EL 3.0 */ @Override public Object convertToType(ELContext context, Object obj, Class<?> targetType) { context.setPropertyResolved(false); Object value = null; for (int i = 0; i < size; i++) { value = elResolvers[i].convertToType(context, obj, targetType); if (context.isPropertyResolved()) { return value; } } return null; }
/** * Converts an object to a specific type. * * <p>An <code>ELException</code> is thrown if an error occurs during * the conversion.</p> * * @param context The context of this evaluation. * @param obj The object to convert. * @param targetType The target type for the convertion. * @throws ELException thrown if errors occur. * * @since EL 3.0 */ @Override public Object convertToType(ELContext context, Object obj, Class<?> targetType) { context.setPropertyResolved(false); Object value = null; for (int i = 0; i < size; i++) { value = elResolvers[i].convertToType(context, obj, targetType); if (context.isPropertyResolved()) { return value; } } return null; }
/** * Converts an object to a specific type. * * <p>An <code>ELException</code> is thrown if an error occurs during * the conversion.</p> * * @param context The context of this evaluation. * @param obj The object to convert. * @param targetType The target type for the convertion. * @throws ELException thrown if errors occur. * * @since EL 3.0 */ @Override public Object convertToType(ELContext context, Object obj, Class<?> targetType) { context.setPropertyResolved(false); Object value = null; for (int i = 0; i < size; i++) { value = elResolvers[i].convertToType(context, obj, targetType); if (context.isPropertyResolved()) { return value; } } return null; }
/** * Converts an object to a specific type. * * <p>An <code>ELException</code> is thrown if an error occurs during * the conversion.</p> * * @param context The context of this evaluation. * @param obj The object to convert. * @param targetType The target type for the convertion. * @throws ELException thrown if errors occur. * * @since EL 3.0 */ @Override public Object convertToType(ELContext context, Object obj, Class<?> targetType) { context.setPropertyResolved(false); Object value = null; for (int i = 0; i < size; i++) { value = elResolvers[i].convertToType(context, obj, targetType); if (context.isPropertyResolved()) { return value; } } return null; }
/** * 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(); } }
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)); }
/** * @since EL 3.0 */ public Object convertToType(Object obj, Class<?> type) { boolean originalResolved = isPropertyResolved(); setPropertyResolved(false); try { ELResolver resolver = getELResolver(); if (resolver != null) { Object result = resolver.convertToType(this, obj, type); if (isPropertyResolved()) { return result; } } } finally { setPropertyResolved(originalResolved); } return ELManager.getExpressionFactory().coerceToType(obj, type); } }
ELResolver resolver = getELResolver(); if (resolver != null) { Object result = resolver.convertToType(this, obj, type); if (isPropertyResolved()) { return result;
ELResolver resolver = getELResolver(); if (resolver != null) { Object result = resolver.convertToType(this, obj, type); if (isPropertyResolved()) { return result;