<commit_before>/*
 * [The "New BSD" license]
 * Copyright (c) 2012 The Board of Trustees of The University of Alabama
 * All rights reserved.
 *
 * See LICENSE for details.
 */
package edu.ua.eng.software.mallard;

//import java.io.FileOutputStream;
//import java.io.PrintStream;
import java.util.concurrent.ConcurrentMap;

/**
 * @author      <NAME> <<EMAIL>>
 * @version     $Id: Mallard.java 9 2012-04-06 20:39:29Z nkraft $
 */
public class Mallard
{
    private static void usage() {
        System.out.println("Usage: java edu.ua.cs.mallard.Mallard JAR ZIP");
    }

    public static void main (String [] args) throws Exception {
        if (2 != args.length) {
            usage();
            System.exit(1);
        }

        // Redirect System.out and System.err to a tmp file.
        /*
        File ifile = new File(args[0]);
        File ofile = File.createTempFile("mallard-",".log");
        FileOutputStream ofs = new FileOutputStream(ofile);
        System.setOut(new PrintStream(ofs,true));
        System.setErr(new PrintStream(ofs,true));
        */

        long start = System.nanoTime();

        ConcurrentMap<String,Method> methods = Methods.merge(
            CallGraph.build(args[0]),
            Methods.extract(args[1])
        );
        computeMaxFanInFanOut(methods);

        long elapsed = System.nanoTime() - start;
        System.out.println("Elapsed time in Mallard.main: " + (elapsed / 1000000000.0) + " seconds");
    }

    private static void computeMaxFanInFanOut(ConcurrentMap<String,Method> methods) {
        int maxFanIn = 0;
        String maxFanInName = null;
        int maxFanOut = 0;
        String maxFanOutName = null;
        for (String qname : methods.keySet()) {
            Method method = methods.get(qname);
            int fanIn = method.getCallers().size();
            if (fanIn > maxFanIn) {
                maxFanIn = fanIn;
                maxFanInName = qname;
            }
            int fanOut = method.getCallees().size();
            if (fanOut > maxFanOut) {
                maxFanOut = fanOut;
                maxFanOutName = qname;
            }
        }
        System.out.println("Max Fan-In: " + maxFanIn + " --- " + maxFanInName);
        System.out.println("Max Fan-Out: " + maxFanOut + " --- " + maxFanOutName);
    }
}<commit_msg>Initial xml_output code. Will move to its own class soon.<commit_after>/*
 * [The "New BSD" license]
 * Copyright (c) 2012 The Board of Trustees of The University of Alabama
 * All rights reserved.
 *
 * See LICENSE for details.
 */
package edu.ua.eng.software.mallard;

//import java.io.FileOutputStream;
//import java.io.PrintStream;
import java.util.concurrent.ConcurrentMap;

/**
 * @author      <NAME> <<EMAIL>>
 * @version     $Id: Mallard.java 9 2012-04-06 20:39:29Z nkraft $
 */
public class Mallard
{
    private static void usage() {
        System.out.println("Usage: java edu.ua.cs.mallard.Mallard JAR ZIP");
    }

    public static void main (String [] args) throws Exception {
        if (2 != args.length) {
            usage();
            System.exit(1);
        }

        // Redirect System.out and System.err to a tmp file.
        /*
        File ifile = new File(args[0]);
        File ofile = File.createTempFile("mallard-",".log");
        FileOutputStream ofs = new FileOutputStream(ofile);
        System.setOut(new PrintStream(ofs,true));
        System.setErr(new PrintStream(ofs,true));
        */

        long start = System.nanoTime();

        ConcurrentMap<String,Method> methods = Methods.merge(
            CallGraph.build(args[0]),
            Methods.extract(args[1])
        );
        computeMaxFanInFanOut(methods);
        System.out.println(xml_output(methods));

        long elapsed = System.nanoTime() - start;
        System.out.println("Elapsed time in Mallard.main: " + (elapsed / 1000000000.0) + " seconds");
    }

    private static void computeMaxFanInFanOut(ConcurrentMap<String,Method> methods) {
        int maxFanIn = 0;
        String maxFanInName = null;
        int maxFanOut = 0;
        String maxFanOutName = null;
        for (String qname : methods.keySet()) {
            Method method = methods.get(qname);
            int fanIn = method.getCallers().size();
            if (fanIn > maxFanIn) {
                maxFanIn = fanIn;
                maxFanInName = qname;
            }
            int fanOut = method.getCallees().size();
            if (fanOut > maxFanOut) {
                maxFanOut = fanOut;
                maxFanOutName = qname;
            }
        }
        System.out.println("Max Fan-In: " + maxFanIn + " --- " + maxFanInName);
        System.out.println("Max Fan-Out: " + maxFanOut + " --- " + maxFanOutName);
    }
    
    private static String xml_output(ConcurrentMap<String,Method> methods) {
    	StringBuilder output = new StringBuilder();
    	output.append("<methods>\n");
    	for (String qname : methods.keySet()) {
    		Method method = methods.get(qname);
    		output.append("\t<method qname=\"" + qname + "\">\n");
    		output.append("\t\t<callees>\n");
    		for (String cname : method.getCallees()) {
    			output.append("\t\t\t<callee qname=\"" + cname + "\"></callee>\n");
    		}
    		output.append("\t\t</callees>\n");
    		output.append("\t\t<callers>\n");
    		for (Method caller : method.getCallers()) {
    			output.append("\t\t\t<caller qname=\"" + caller.getQualifiedName() + "\"></caller>\n");
    		}
    		output.append("\t\t</callers>\n");
    		output.append("\t</method>\n");
    	}
    	output.append("</methods>\n");
    	return output.toString();
    }
}
{'fraction_non_alphanumeric': 0.13936473947180586, 'fraction_numerical': 0.013204853675945753, 'mean_word_length': 2.1666666666666665, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 3}, 'pii_count': 0, 'substrings_counts': 2, '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': '2761094', 'n_tokens_mistral': 1850, 'n_tokens_neox': 1727, 'n_words': 379}