All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nuiton.eugene.writer.WriterReport Maven / Gradle / Ivy

There is a newer version: 3.0
Show newest version
/*
 * #%L
 * EUGene :: EUGene
 * %%
 * Copyright (C) 2004 - 2010 CodeLutin
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as 
 * published by the Free Software Foundation, either version 3 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public 
 * License along with this program.  If not, see
 * .
 * #L%
 */
package org.nuiton.eugene.writer;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

/**
 * A class to save generated files in {@link ChainedFileWriter}.
 *
 * @author Tony Chemit - [email protected]
 * @since 2.0.2
 */
public class WriterReport {

    protected Map> datas;

    protected Map> resources;

    public Map> getDatas() {
        if (datas == null) {
            datas = new TreeMap<>();
        }
        return datas;
    }

    public Map> getResources() {
        if (resources == null) {
            resources = new TreeMap<>();
        }
        return resources;
    }

    public void addFile(String entry, File file, boolean verbose) {
        List files = getDatas().get(entry);
        if (files == null) {
            files = new ArrayList<>();
            getDatas().put(entry, files);
        }
        files.add(file);
    }

    public void addResource(String entry, File file, boolean verbose) {
        List files = getResources().get(entry);
        if (files == null) {
            files = new ArrayList<>();
            getResources().put(entry, files);
        }
        files.add(file);
    }

    public int getFilesCount() {
        int tot = 0;
        for (List files : getDatas().values()) {
            tot += files.size();
        }
        return tot;
    }

    public int getResourcesCount() {
        int tot = 0;
        for (List files : getResources().values()) {
            tot += files.size();
        }
        return tot;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy