<commit_before>/*
 * Copyright 2013 Haulmont
 *
 * 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 com.haulmont.yarg.structure;

import com.haulmont.yarg.structure.impl.BandOrientation;

import java.util.*;

/**
 * @author degtyarjov
 * @version $Id$
 */

@SuppressWarnings({"UnusedDeclaration"})
public class BandData {
    public static final String ROOT_BAND_NAME = "Root";

    protected Map<String, Object> data = new HashMap<String, Object>(10);
    protected BandData parentBand;

    protected Map<String, List<BandData>> childrenBands = new LinkedHashMap<String, List<BandData>>();

    protected final String name;
    protected final BandOrientation orientation;
    protected Set<String> firstLevelBandDefinitionNames = null;
    protected int level;
    protected Map<String, ReportFieldFormat> reportFieldFormats = new HashMap<String, ReportFieldFormat>();


    public BandData(String name) {
        this.name = name;
        this.parentBand = null;
        this.orientation = BandOrientation.HORIZONTAL;
    }

    public BandData(String name, BandData parentBand) {
        this.name = name;
        this.parentBand = parentBand;
        this.orientation = BandOrientation.HORIZONTAL;
    }

    public BandData(String name, BandData parentBand, BandOrientation orientation) {
        this.name = name;
        this.parentBand = parentBand;
        this.orientation = orientation;

        BandData currentBand = this;
        while (currentBand != null) {
            level++;
            currentBand = currentBand.parentBand;
        }
    }

    public Map<String, List<BandData>> getChildrenBands() {
        return childrenBands;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }

    public void addData(String name, Object value) {
        data.put(name, value);
    }

    public Object getParameterValue(String name) {
        return data.get(name);
    }

    public void addAllParameters(Map<String, Object> parameters) {
        data.putAll(parameters);
    }

    public String getName() {
        return name;
    }

    public BandData getParentBand() {
        return parentBand;
    }

    public void setParentBand(BandData parentBand) {
        this.parentBand = parentBand;
    }

    public BandOrientation getOrientation() {
        return orientation;
    }
<commit_msg>Fixes #PL-3334<commit_after>/*
 * Copyright 2013 Haulmont
 *
 * 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 com.haulmont.yarg.structure;

import com.haulmont.yarg.structure.impl.BandOrientation;

import java.util.*;

/**
 * @author degtyarjov
 * @version $Id$
 */

@SuppressWarnings({"UnusedDeclaration"})
public class BandData {
    public static final String ROOT_BAND_NAME = "Root";

    protected Map<String, Object> data = new HashMap<String, Object>(10);
    protected BandData parentBand;

    protected Map<String, List<BandData>> childrenBands = new LinkedHashMap<String, List<BandData>>();

    protected final String name;
    protected final BandOrientation orientation;
    protected Set<String> firstLevelBandDefinitionNames = null;
    protected int level;
    protected Map<String, ReportFieldFormat> reportFieldFormats = new HashMap<String, ReportFieldFormat>();


    public BandData(String name) {
        this.name = name;
        this.parentBand = null;
        this.orientation = BandOrientation.HORIZONTAL;
    }

    public BandData(String name, BandData parentBand) {
        this.name = name;
        this.parentBand = parentBand;
        this.orientation = BandOrientation.HORIZONTAL;
    }

    public BandData(String name, BandData parentBand, BandOrientation orientation) {
        this.name = name;
        this.parentBand = parentBand;
        this.orientation = orientation;

        BandData currentBand = this;
        while (currentBand != null) {
            level++;
            currentBand = currentBand.parentBand;
        }
    }

    public Map<String, List<BandData>> getChildrenBands() {
        return childrenBands;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }

    public void addData(String name, Object value) {
        data.put(name, value);
    }

    public Object getParameterValue(String name) {
        return data.get(name);
    }

    //added for back compatibility
    public Object getParameter(String name) {
        return getParameterValue(name);
    }

    public void addAllParameters(Map<String, Object> parameters) {
        data.putAll(parameters);
    }

    public String getName() {
        return name;
    }

    public BandData getParentBand() {
        return parentBand;
    }

    public void setParentBand(BandData parentBand) {
        this.parentBand = parentBand;
    }

    public BandOrientation getOrientation() {
        return orientation;
    }

{'fraction_non_alphanumeric': 0.08848525245792369, 'fraction_numerical': 0.003999333444425929, 'mean_word_length': 2.9960053262316912, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '409168', 'n_tokens_mistral': 1664, 'n_tokens_neox': 1592, 'n_words': 497}