static boolean fixBooleanValue(final Object value) { // This specifies how evaluation to boolean should be done *INSIDE* OGNL expressions, so the conversion // service does not really apply at this point (it will be applied later, on the Standard -not OGNL- expr.) return EvaluationUtil.evaluateAsBoolean(value); }
/** * @deprecated since 2.1, you should use the * {@link org.thymeleaf.standard.expression.IStandardConversionService} implementation * corresponding to the dialect you are using or the methods in * {@link EvaluationUtil}. * Will be removed in 3.0. */ @Deprecated public static BigDecimal evaluateAsNumber(final Object object) { return EvaluationUtil.evaluateAsNumber(object); }
/** * @deprecated since 2.1, you should use the * {@link org.thymeleaf.standard.expression.IStandardConversionService} implementation * corresponding to the dialect you are using or the methods in * {@link EvaluationUtil}. * Will be removed in 3.0. */ @Deprecated public static Object[] convertToArray(final Object value) { return EvaluationUtil.evaluateAsArray(value); }
/** * @deprecated since 2.1, you should use the * {@link org.thymeleaf.standard.expression.IStandardConversionService} implementation * corresponding to the dialect you are using or the methods in * {@link EvaluationUtil}. * Will be removed in 3.0. */ @Deprecated public static List<Object> convertToIterable(final Object value) { return EvaluationUtil.evaluateAsIterable(value); }
/** * @deprecated since 2.1, you should use the * {@link org.thymeleaf.standard.expression.IStandardConversionService} implementation * corresponding to the dialect you are using or the methods in * {@link EvaluationUtil}. * Will be removed in 3.0. */ @Deprecated public static List<Object> convertToList(final Object value) { if (value == null) { // This mimics the old behaviour of the deprecated convertToList() method, which is not the same // as the current EvaluationUtil.convertToList() method. return Collections.singletonList(null); } return EvaluationUtil.evaluateAsIterable(value); }
private int integer(final Object number) { Validate.notNull(number, "Argument cannot be null"); return EvaluationUtil.evaluateAsNumber(number).intValue(); }
/** * Evaluates the given object as a boolean: if it is a Boolean object, it's easy; if * it's a Number or a Character, returns true for non-zero objects; and otherwise * returns true for non-null objects. * <p/> * <h3>Method modified</h3> * <p> * Use a better evaluation supporting "off", "no", "false", 0... * </p> * * @param value an object to interpret as a boolean * @return the boolean value implied by the given object */ public static boolean booleanValue(Object value) { return EvaluationUtil.evaluateAsBoolean(value); }
final Object iteratedObject = iterationSpec.getIteratedObject(); final List<?> list = EvaluationUtil.evaluateAsIterable(iteratedObject);
null : EvaluationUtil.evaluateAsNumber(year)); final BigDecimal nMonth = (month == null? null : EvaluationUtil.evaluateAsNumber(month)); final BigDecimal nDay = (day == null? null : EvaluationUtil.evaluateAsNumber(day)); final BigDecimal nHour = (hour == null? null : EvaluationUtil.evaluateAsNumber(hour)); final BigDecimal nMinute = (minute == null? null : EvaluationUtil.evaluateAsNumber(minute)); final BigDecimal nSecond = (second == null? null : EvaluationUtil.evaluateAsNumber(second)); final BigDecimal nMillisecond = (millisecond == null? null : EvaluationUtil.evaluateAsNumber(millisecond));
/** * @deprecated since 2.1, you should use the * {@link org.thymeleaf.standard.expression.IStandardConversionService} implementation * corresponding to the dialect you are using or the methods in * {@link EvaluationUtil}. * Will be removed in 3.0. */ @Deprecated public static boolean evaluateAsBoolean(final Object condition) { return EvaluationUtil.evaluateAsBoolean(condition); }
final Object iteratedObject = iterationSpec.getIteratedObject(); final List<?> list = EvaluationUtil.evaluateAsIterable(iteratedObject);
final BigDecimal leftNumberValue = EvaluationUtil.evaluateAsNumber(leftValue); final BigDecimal rightNumberValue = EvaluationUtil.evaluateAsNumber(rightValue);
public Boolean isTrue(final Object target) { return Boolean.valueOf(EvaluationUtil.evaluateAsBoolean(target)); }
final BigDecimal leftNumberValue = EvaluationUtil.evaluateAsNumber(leftValue); final BigDecimal rightNumberValue = EvaluationUtil.evaluateAsNumber(rightValue);
public Boolean isFalse(final Object target) { return Boolean.valueOf(!EvaluationUtil.evaluateAsBoolean(target)); }
static Object executeMinus(final Configuration configuration, final IProcessingContext processingContext, final MinusExpression expression, final StandardExpressionExecutionContext expContext) { if (logger.isTraceEnabled()) { logger.trace("[THYMELEAF][{}] Evaluating minus expression: \"{}\"", TemplateEngine.threadIndex(), expression.getStringRepresentation()); } Object operandValue = expression.getOperand().execute(configuration, processingContext, expContext); if (operandValue == null) { operandValue = "null"; } final BigDecimal operandNumberValue = EvaluationUtil.evaluateAsNumber(operandValue); if (operandNumberValue != null) { // Addition will act as a mathematical 'plus' return operandNumberValue.multiply(BigDecimal.valueOf(-1)); } throw new TemplateProcessingException( "Cannot execute minus: operand is \"" + LiteralValue.unwrap(operandValue) + "\""); }
static Object executeNegation(final Configuration configuration, final IProcessingContext processingContext, final NegationExpression expression, final StandardExpressionExecutionContext expContext) { if (logger.isTraceEnabled()) { logger.trace("[THYMELEAF][{}] Evaluating negation expression: \"{}\"", TemplateEngine.threadIndex(), expression.getStringRepresentation()); } final Object operandValue = expression.getOperand().execute(configuration, processingContext, expContext); final boolean operandBooleanValue = EvaluationUtil.evaluateAsBoolean(operandValue); return Boolean.valueOf(!operandBooleanValue); }
final BigDecimal leftNumberValue = EvaluationUtil.evaluateAsNumber(leftValue); final BigDecimal rightNumberValue = EvaluationUtil.evaluateAsNumber(rightValue);
static Object executeOr(final Configuration configuration, final IProcessingContext processingContext, final OrExpression expression, final StandardExpressionExecutionContext expContext) { if (logger.isTraceEnabled()) { logger.trace("[THYMELEAF][{}] Evaluating OR expression: \"{}\"", TemplateEngine.threadIndex(), expression.getStringRepresentation()); } final Object leftValue = expression.getLeft().execute(configuration, processingContext, expContext); // Short circuit final boolean leftBooleanValue = EvaluationUtil.evaluateAsBoolean(leftValue); if (leftBooleanValue) { return Boolean.TRUE; } final Object rightValue = expression.getRight().execute(configuration, processingContext, expContext); final boolean rightBooleanValue = EvaluationUtil.evaluateAsBoolean(rightValue); return Boolean.valueOf(rightBooleanValue); }
final BigDecimal leftNumberValue = EvaluationUtil.evaluateAsNumber(leftValue); final BigDecimal rightNumberValue = EvaluationUtil.evaluateAsNumber(rightValue); if (leftNumberValue != null && rightNumberValue != null) { try {