<commit_before>/*
 * This file is part of TDA - Thread Dump Analysis Tool.
 *
 * TDA is free software; you can redistribute it and/or modify
 * it under the terms of the Lesser GNU General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * TDA 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
 * Lesser GNU General Public License for more details.
 *
 * You should have received a copy of the Lesser GNU General Public License
 * along with TDA; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * $Id: AbstractCategory.java,v 1.2 2008-01-07 17:25:52 irockel Exp $
 */
package com.pironet.tda;

import com.pironet.tda.filter.FilterChecker;
import com.pironet.tda.utils.IconFactory;
import com.pironet.tda.utils.PrefManager;
import java.util.Arrays;
import java.util.Comparator;
import javax.swing.Icon;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;

/**
 *
 * @author irockel
 */
public abstract class AbstractCategory implements Category {
    private String info;
    private String name = null;
    
    private DefaultMutableTreeNode rootNode = null;
    private DefaultMutableTreeNode filteredRootNode = null;
    
    private transient JScrollPane lastView = null;
    
    private transient FilterChecker filterChecker = null;
    
    private boolean filterEnabled = true;
    
    private int iconID = -1;
    
    /**
     * sorts the category tree by the given comparator.
     * @param nodeComp 
     */
    public void sort(Comparator nodeComp) {
        Object[] arrayCat = new Object[getRootNode().getChildCount()];
        for(int i = 0; i < getRootNode().getChildCount(); i++) {
            // add nodes to sorting tree
            arrayCat[i] = getRootNode().getChildAt(i);
        }
        setRootNode(new DefaultMutableTreeNode("root"));

        Arrays.sort(arrayCat, nodeComp);
        for(int i = 0; i < arrayCat.length; i++) {
            getRootNode().add((DefaultMutableTreeNode) arrayCat[i]);
        }

        // reset filter.
        setLastView(null);
        
        setFilteredRootNode(null);
        
    }

    public void setName(String value) {
       name = value;
    }
    
    public String getName() {
        return(name);
    }
    
    public Icon getIcon() {
        return(IconFactory.get().getIconFor(iconID));
    }
    
    public void setIconID(int iconID) {
        this.iconID = iconID;
    }
        
    private long lastUpdated = -1;
    
    /**
     * return amount of filtered nodes
     */
    public int howManyFiltered() {
       return(getFilteredRootNode() != null && getRootNode() != null ? getRootNode().getChildCount() - getFilteredRootNode().getChildCount() : 0); 
    }
    
    public int getNodeCount() {
        return(getRootNode().getChildCount());
    }
    
    public int showing() {
       return(getFilteredRootNode() != null ? getFilteredRootNode().getChildCount() : 0);
    }
    
    public String toString() {
        return(getName());
    }<commit_msg>fixed check for node for category nodes<commit_after>/*
 * This file is part of TDA - Thread Dump Analysis Tool.
 *
 * TDA is free software; you can redistribute it and/or modify
 * it under the terms of the Lesser GNU General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * TDA 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
 * Lesser GNU General Public License for more details.
 *
 * You should have received a copy of the Lesser GNU General Public License
 * along with TDA; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * $Id: AbstractCategory.java,v 1.3 2008-01-10 13:10:24 irockel Exp $
 */
package com.pironet.tda;

import com.pironet.tda.filter.FilterChecker;
import com.pironet.tda.utils.IconFactory;
import com.pironet.tda.utils.PrefManager;
import java.util.Arrays;
import java.util.Comparator;
import javax.swing.Icon;
import javax.swing.JScrollPane;
import javax.swing.tree.DefaultMutableTreeNode;

/**
 *
 * @author irockel
 */
public abstract class AbstractCategory extends AbstractInfo implements Category {
    private String info;
    
    private DefaultMutableTreeNode rootNode = null;
    private DefaultMutableTreeNode filteredRootNode = null;
    
    private transient JScrollPane lastView = null;
    
    private transient FilterChecker filterChecker = null;
    
    private boolean filterEnabled = true;
    
    private int iconID = -1;
    
    /**
     * sorts the category tree by the given comparator.
     * @param nodeComp 
     */
    public void sort(Comparator nodeComp) {
        Object[] arrayCat = new Object[getRootNode().getChildCount()];
        for(int i = 0; i < getRootNode().getChildCount(); i++) {
            // add nodes to sorting tree
            arrayCat[i] = getRootNode().getChildAt(i);
        }
        setRootNode(new DefaultMutableTreeNode("root"));

        Arrays.sort(arrayCat, nodeComp);
        for(int i = 0; i < arrayCat.length; i++) {
            getRootNode().add((DefaultMutableTreeNode) arrayCat[i]);
        }

        // reset filter.
        setLastView(null);
        
        setFilteredRootNode(null);
        
    }

    public Icon getIcon() {
        return(IconFactory.get().getIconFor(iconID));
    }
    
    public void setIconID(int iconID) {
        this.iconID = iconID;
    }
        
    private long lastUpdated = -1;
    
    /**
     * return amount of filtered nodes
     */
    public int howManyFiltered() {
       return(getFilteredRootNode() != null && getRootNode() != null ? getRootNode().getChildCount() - getFilteredRootNode().getChildCount() : 0); 
    }
    
    public int getNodeCount() {
        return(getRootNode().getChildCount());
    }
    
    public int showing() {
       return(getFilteredRootNode() != null ? getFilteredRootNode().getChildCount() : 0);
    }
    
    public String toString() {
        return(getName());
    }
{'fraction_non_alphanumeric': 0.09714463066418373, 'fraction_numerical': 0.010862818125387958, 'mean_word_length': 2.7734192037470726, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '820617', 'n_tokens_mistral': 1880, 'n_tokens_neox': 1816, 'n_words': 578}