<commit_before>/*
 * =============================================================================
 * 
 *   Copyright (c) 2011, The THYMELEAF team (http://www.thymeleaf.org)
 * 
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 * 
 * =============================================================================
 */
package org.thymeleaf;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.thymeleaf.util.CacheMap;
import org.thymeleaf.util.CacheMap.ICacheMapEntryValidityChecker;
import org.thymeleaf.util.Validate;

/**
 * 
 * @author <NAME>
 * 
 * @since 1.0
 *
 */
final class ParsedTemplateCache {

    
    public static final String PARSER_CACHE_LOGGER_NAME = TemplateEngine.class.getName() + ".PARSERCACHE";
    protected static final Logger logger = LoggerFactory.getLogger(PARSER_CACHE_LOGGER_NAME);
    
    private final CacheMap<String,ParsedTemplate> cache;

    
    ParsedTemplateCache(final int cacheSize) {
        super();
        // Although CacheMap allows it, Parsed Template Cache cannot have unlimited size
        Validate.isTrue(cacheSize >= 0, "Parsed Template Cache size must be 0 (no cache) or > 1");
        if (cacheSize > 0) {
            this.cache = 
                    new CacheMap<String,ParsedTemplate>(
                           "ParsedTemplateCache.cache", true, 16, cacheSize,
                           new ParsedTemplateEntryValidator());
        } else {
            this.cache = null;
        }
    }
    
    <commit_msg>Several changes made<commit_after>/*
 * =============================================================================
 * 
 *   Copyright (c) 2011, The THYMELEAF team (http://www.thymeleaf.org)
 * 
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 * 
 * =============================================================================
 */
package org.thymeleaf;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.thymeleaf.util.CacheMap;
import org.thymeleaf.util.CacheMap.ICacheMapEntryValidityChecker;
import org.thymeleaf.util.Validate;

/**
 * 
 * @author <NAME>
 * 
 * @since 1.0
 *
 */
final class ParsedTemplateCache {

    
    public static final String PARSER_CACHE_LOGGER_NAME = TemplateEngine.class.getName() + ".PARSERCACHE";
    protected static final Logger logger = LoggerFactory.getLogger(PARSER_CACHE_LOGGER_NAME);
    
    private final CacheMap<String,ParsedTemplate> cache;

    
    ParsedTemplateCache(final int cacheSize) {
        super();
        // Although CacheMap allows it, Parsed Template Cache cannot have unlimited size
        Validate.isTrue(cacheSize >= 0, "Parsed Template Cache size must be 0 (no cache) or > 1");
        if (cacheSize > 0) {
            this.cache = 
                    new CacheMap<String,ParsedTemplate>(
                           "ParsedTemplateCache.PARSED_TEMPLATE_CACHE", true, 16, cacheSize,
                           new ParsedTemplateEntryValidator());
        } else {
            this.cache = null;
        }
    }
    
    
{'fraction_non_alphanumeric': 0.15665925376822337, 'fraction_numerical': 0.008895478131949592, 'mean_word_length': 3.003956478733927, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5007291', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1074, 'n_words': 334}