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

com.cflint.BugList Maven / Gradle / Ivy

Go to download

A static code analysis tool for ColdFusion (in the spirit of FindBugs and Lint). With CFLint, you are able to analyze your ColdFusion code base for code violations.

There is a newer version: 1.5.0
Show newest version
package com.cflint;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import com.cflint.tools.CFLintFilter;

public class BugList implements Iterable {

    Map> bugList = new HashMap>();
    CFLintFilter filter;
    CFLintFilter fileFilter;

    /**
     *
     */
    @SuppressWarnings("unused")
    private static final long serialVersionUID = -8008927848087276202L;

    public BugList(final CFLintFilter filter) {
        super();
        this.filter = filter;
    }

    public CFLintFilter getFileFilter() {
        return fileFilter;
    }

    public CFLintFilter getFilter() {
        return filter;
    }

    public void setFilter(final CFLintFilter filter) {
        this.filter = filter;
        this.fileFilter = filter.createFilePreFilter();
    }

    public boolean add(final BugInfo bugInfo) {
        if (filter == null || filter.include(bugInfo)) {
            if (!bugList.containsKey(bugInfo.getMessageCode())) {
                bugList.put(bugInfo.getMessageCode(), new ArrayList());
            }
            final List curBugList = bugList.get(bugInfo.getMessageCode());
            return curBugList.add(bugInfo);
        } else {
            return false;
        }
    }

    /**
     * Returns a list of bugs as a map.
     *
     * @return Map of bugs
     */
    public Map> getBugList() {
        return bugList;
    }

    public int size() {
        int size = 0;
        for (final List list : bugList.values()) {
            size += list.size();
        }
        return size;
    }

    public List getFlatBugList() {
        final List retval = new ArrayList();
        for (final List list : bugList.values()) {
            retval.addAll(list);
        }
        return retval;

    }

    @Override
    public Iterator iterator() {
        return getFlatBugList().iterator();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy