public void clearKey(final K key) { final int newSize = this.dataContainer.remove(key); if (this.traceExecution && newSize != -1) { this.logger.trace( "[THYMELEAF][{}][*][{}][CACHE_REMOVE][{}] Removed cache entry in cache \"{}\" for key \"{}\". New size is {}.", new Object[] {TemplateEngine.threadIndex(), this.name, Integer.valueOf(newSize), this.name, key, Integer.valueOf(newSize)}); } }
public void clear() { this.dataContainer.clear(); if (this.traceExecution) { this.logger.trace( "[THYMELEAF][{}][*][{}][CACHE_REMOVE][0] Removing ALL cache entries in cache \"{}\". New size is 0.", new Object[] {TemplateEngine.threadIndex(), this.name, this.name}); } }
static Object executeNoOpTokenExpression( final IExpressionContext context, final NoOpTokenExpression expression, final StandardExpressionExecutionContext expContext) { if (logger.isTraceEnabled()) { logger.trace("[THYMELEAF][{}] Evaluating no-op token: \"{}\"", TemplateEngine.threadIndex(), expression.getStringRepresentation()); } return NoOpToken.VALUE; }
private synchronized int putWithTracing(final K key, final CacheEntry<V> value) { final CacheEntry<V> existing = this.container.putIfAbsent(key, value); if (existing == null) { if (this.sizeLimit) { final Object removedKey = this.fifo[this.fifoPointer]; if (removedKey != null) { final CacheEntry<V> removed = this.container.remove(removedKey); if (removed != null) { final Integer newSize = Integer.valueOf(this.container.size()); this.logger.trace( "[THYMELEAF][{}][{}][CACHE_REMOVE][{}] Max size exceeded for cache \"{}\". Removing entry for key \"{}\". New size is {}.", new Object[] {TemplateEngine.threadIndex(), this.name, newSize, this.name, removedKey, newSize}); } } this.fifo[this.fifoPointer] = key; this.fifoPointer = (this.fifoPointer + 1) % this.maxSize; } } return this.container.size(); }
public <K> V getValueIfStillValid(final String cacheMapName, final K key, final ICacheEntryValidityChecker<? super K, ? super V> checker, final boolean traceExecution, final Logger logger) { final V cachedValue = this.cachedValueReference.get(); if (cachedValue == null) { // The soft reference has been cleared by GC -> Memory could be running low if (traceExecution) { logger.trace( "[THYMELEAF][{}][*][{}][CACHE_DELETED_REFERENCES] Some entries at cache \"{}\" " + "seem to have been sacrificed by the Garbage Collector (soft references).", new Object[] {TemplateEngine.threadIndex(), cacheMapName, cacheMapName}); } return null; } if (checker == null || checker.checkIsValueStillValid(key, cachedValue, this.creationTimeInMillis)) { return cachedValue; } return null; }
static Object executeGenericTokenExpression( final IExpressionContext context, final GenericTokenExpression expression, final StandardExpressionExecutionContext expContext) { if (logger.isTraceEnabled()) { logger.trace("[THYMELEAF][{}] Evaluating generic token: \"{}\"", TemplateEngine.threadIndex(), expression.getStringRepresentation()); } return expression.getValue(); }
static Object executeTextLiteralExpression( final IExpressionContext context, final TextLiteralExpression expression, final StandardExpressionExecutionContext expContext) { if (logger.isTraceEnabled()) { logger.trace("[THYMELEAF][{}] Evaluating text literal: \"{}\"", TemplateEngine.threadIndex(), expression.getStringRepresentation()); } return expression.getValue(); }
static Object executeBooleanTokenExpression( final IExpressionContext context, final BooleanTokenExpression expression, final StandardExpressionExecutionContext expContext) { if (logger.isTraceEnabled()) { logger.trace("[THYMELEAF][{}] Evaluating boolean token: \"{}\"", TemplateEngine.threadIndex(), expression.getStringRepresentation()); } return expression.getValue(); }
static Object executeNumberTokenExpression( final IExpressionContext context, final NumberTokenExpression expression, final StandardExpressionExecutionContext expContext) { if (logger.isTraceEnabled()) { logger.trace("[THYMELEAF][{}] Evaluating number token: \"{}\"", TemplateEngine.threadIndex(), expression.getStringRepresentation()); } return expression.getValue(); }
static Object executeNullTokenExpression( final IExpressionContext context, final NullTokenExpression expression, final StandardExpressionExecutionContext expContext) { if (logger.isTraceEnabled()) { logger.trace("[THYMELEAF][{}] Evaluating null token: \"{}\"", TemplateEngine.threadIndex(), expression.getStringRepresentation()); } return expression.getValue(); }
private void reportFinish(final String outputType) { if (this.allProcessingFinished) { if (logger.isTraceEnabled()) { logger.trace( "[THYMELEAF][{}] Finished throttled processing of template \"{}\" with locale {}. Maximum overflow was {} {} (overflow buffer grown {} times).", new Object[]{TemplateEngine.threadIndex(), this.templateSpec, this.context.getLocale(), Integer.valueOf(this.writer.getMaxOverflowSize()), outputType, this.writer.getOverflowGrowCount() }); } } }
public void put(final K key, final V value) { incrementReportEntity(this.putCount); final CacheEntry<V> entry = new CacheEntry<V>(value, this.useSoftReferences); // newSize will be -1 if traceExecution is false final int newSize = this.dataContainer.put(key, entry); if (this.traceExecution) { this.logger.trace( "[THYMELEAF][{}][{}][CACHE_ADD][{}] Adding cache entry in cache \"{}\" for key \"{}\". New size is {}.", new Object[] {TemplateEngine.threadIndex(), this.name, Integer.valueOf(newSize), this.name, key, Integer.valueOf(newSize)}); outputReportIfNeeded(); } }
static Object executeNegation( final IExpressionContext context, 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(context, expContext); final boolean operandBooleanValue = EvaluationUtils.evaluateAsBoolean(operandValue); return Boolean.valueOf(!operandBooleanValue); }
static Object executeDefault( final IExpressionContext context, final DefaultExpression expression, final StandardExpressionExecutionContext expContext) { if (logger.isTraceEnabled()) { logger.trace("[THYMELEAF][{}] Evaluating default expression: \"{}\"", TemplateEngine.threadIndex(), expression.getStringRepresentation()); } final Object queriedValue = expression.getQueriedExpression().execute(context, expContext); if (queriedValue == null) { return expression.getDefaultExpression().execute(context, expContext); } return queriedValue; }
static Object executeMinus( final IExpressionContext context, final MinusExpression expression, final StandardExpressionExecutionContext expContext) { if (logger.isTraceEnabled()) { logger.trace("[THYMELEAF][{}] Evaluating minus expression: \"{}\"", TemplateEngine.threadIndex(), expression.getStringRepresentation()); } Object operandValue = expression.getOperand().execute(context, expContext); if (operandValue == null) { operandValue = "null"; } final BigDecimal operandNumberValue = EvaluationUtils.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 executeAnd( final IExpressionContext context, final AndExpression expression, final StandardExpressionExecutionContext expContext) { if (logger.isTraceEnabled()) { logger.trace("[THYMELEAF][{}] Evaluating AND expression: \"{}\"", TemplateEngine.threadIndex(), expression.getStringRepresentation()); } final Object leftValue = expression.getLeft().execute(context, expContext); // Short circuit final boolean leftBooleanValue = EvaluationUtils.evaluateAsBoolean(leftValue); if (!leftBooleanValue) { return Boolean.FALSE; } final Object rightValue = expression.getRight().execute(context, expContext); final boolean rightBooleanValue = EvaluationUtils.evaluateAsBoolean(rightValue); return Boolean.valueOf(rightBooleanValue); }
static Object executeOr( final IExpressionContext context, 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(context, expContext); // Short circuit final boolean leftBooleanValue = EvaluationUtils.evaluateAsBoolean(leftValue); if (leftBooleanValue) { return Boolean.TRUE; } final Object rightValue = expression.getRight().execute(context, expContext); final boolean rightBooleanValue = EvaluationUtils.evaluateAsBoolean(rightValue); return Boolean.valueOf(rightBooleanValue); }
static Object executeConditional( final IExpressionContext context, final ConditionalExpression expression, final StandardExpressionExecutionContext expContext) { if (logger.isTraceEnabled()) { logger.trace("[THYMELEAF][{}] Evaluating conditional expression: \"{}\"", TemplateEngine.threadIndex(), expression.getStringRepresentation()); } final Object condObj = expression.getConditionExpression().execute(context, expContext); final boolean cond = EvaluationUtils.evaluateAsBoolean(condObj); if (cond) { return expression.getThenExpression().execute(context, expContext); } return expression.getElseExpression().execute(context, expContext); }
@Override protected void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final IElementTagStructureHandler structureHandler) { if (LOGGER.isWarnEnabled()) { LOGGER.warn( "[THYMELEAF][{}][{}] Deprecated attribute {} found in template {}, line {}, col {}. " + "Please use {} instead, this deprecated attribute will be removed in future versions of Thymeleaf.", new Object[]{ TemplateEngine.threadIndex(), LoggingUtils.loggifyTemplateName(context.getTemplateData().getTemplate()), attributeName, tag.getTemplateName(), Integer.valueOf(tag.getAttribute(attributeName).getLine()), Integer.valueOf(tag.getAttribute(attributeName).getCol()), AttributeNames.forHTMLName(attributeName.getPrefix(), StandardReplaceTagProcessor.ATTR_NAME)}); } super.doProcess(context, tag, attributeName, attributeValue, structureHandler); }
static Object executeRemainder( final IExpressionContext context, final RemainderExpression expression, final StandardExpressionExecutionContext expContext) { if (logger.isTraceEnabled()) { logger.trace("[THYMELEAF][{}] Evaluating remainder expression: \"{}\"", TemplateEngine.threadIndex(), expression.getStringRepresentation()); } Object leftValue = expression.getLeft().execute(context, expContext); Object rightValue = expression.getRight().execute(context, expContext); if (leftValue == null) { leftValue = "null"; } if (rightValue == null) { rightValue = "null"; } final BigDecimal leftNumberValue = EvaluationUtils.evaluateAsNumber(leftValue); final BigDecimal rightNumberValue = EvaluationUtils.evaluateAsNumber(rightValue); if (leftNumberValue != null && rightNumberValue != null) { // Addition will act as a mathematical 'plus' return leftNumberValue.remainder(rightNumberValue); } throw new TemplateProcessingException( "Cannot execute division: operands are \"" + LiteralValue.unwrap(leftValue) + "\" and \"" + LiteralValue.unwrap(rightValue) + "\""); }