<commit_before>package com.haulmont.cuba.report.formatters.tools;

import com.sun.star.text.XText;

import java.util.HashMap;

/**
 * Created by IntelliJ IDEA.
 * User: fontanenko
 * Date: 23.06.2010
 * Time: 19:44:23
 * To change this template use File | Settings | File Templates.
 */
public class TableTemplate {
    private HashMap<Integer, String> columnsTemplates;
    private String tableName;
    private int templateRow;

    public TableTemplate() {
        columnsTemplates = new HashMap<Integer, String>();
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public void addColumnTemplate(Integer tableColumnIndex, String columnTemplate) {
        columnsTemplates.put(tableColumnIndex, columnTemplate);
    }

    public boolean isEmpty() {
        return columnsTemplates.isEmpty();
    }

    public int getTemplateRow() {
        return templateRow;
    }

    public void setTemplateRow(int templateRow) {
        this.templateRow = templateRow;
    }

    public HashMap<Integer, String> getColumnsTemplates() {
        return columnsTemplates;
    }
    
    public String getColumnTemplate(int col) {
        return columnsTemplates.get(col);
    }

    public boolean haveValueExpressions() {
        boolean haveValueExpressions = false;
        for(String columnTemplate : columnsTemplates.values()) {
            String templateText = columnTemplate;
            if (templateText.matches(".*\\$\\{[^\\.]+?\\}.*")) {//ED - only table aliases are matched there - if there is a point - this is not a table alias 
                haveValueExpressions = true;
            }
        }
        return haveValueExpressions;
    }
}<commit_msg>Previous version didn't work if expression in table contains \n characters<commit_after>package com.haulmont.cuba.report.formatters.tools;

import com.sun.star.text.XText;

import java.util.HashMap;
import java.util.regex.Pattern;

/**
 * Created by IntelliJ IDEA.
 * User: fontanenko
 * Date: 23.06.2010
 * Time: 19:44:23
 * To change this template use File | Settings | File Templates.
 */
public class TableTemplate {
    private HashMap<Integer, String> columnsTemplates;
    private String tableName;
    private int templateRow;

    public TableTemplate() {
        columnsTemplates = new HashMap<Integer, String>();
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public void addColumnTemplate(Integer tableColumnIndex, String columnTemplate) {
        columnsTemplates.put(tableColumnIndex, columnTemplate);
    }

    public boolean isEmpty() {
        return columnsTemplates.isEmpty();
    }

    public int getTemplateRow() {
        return templateRow;
    }

    public void setTemplateRow(int templateRow) {
        this.templateRow = templateRow;
    }

    public HashMap<Integer, String> getColumnsTemplates() {
        return columnsTemplates;
    }
    
    public String getColumnTemplate(int col) {
        return columnsTemplates.get(col);
    }

    public boolean haveValueExpressions() {
        boolean haveValueExpressions = false;
        for(String columnTemplate : columnsTemplates.values()) {
            String templateText = columnTemplate;
            if (Pattern.compile("\\$\\{[^\\.]+?\\}").matcher(templateText).find()) {//ED - only table aliases are matched there - if there is a point - this is not a table alias 
                haveValueExpressions = true;
            }
        }
        return haveValueExpressions;
    }
}
{'fraction_non_alphanumeric': 0.09430362496593077, 'fraction_numerical': 0.007631507222676479, 'mean_word_length': 2.741080530071356, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6275020', 'n_tokens_mistral': 1027, 'n_tokens_neox': 976, 'n_words': 266}