<commit_before>package sds;

import sds.assemble.ClassContent;
import sds.decompile.DecompileProcessor;
import sds.util.ClassFilePrinter;

/**
 * This class is for driving SDS.
 * @author inagaki
 */
public class SDS {
	private String[] args;

	/**
	 * constructor.
	 * @param args command line arguments
	 */
	public SDS(String[] args) {
		this.args = args;
	}

	/**
	 * starts SDS.
	 */
	public void run() {
		boolean output = false;
		for(String arg : args) {
			ClassFileReader reader = new ClassFileReader(arg);
			reader.read();
			ClassFile cf = reader.getClassFile();
			if(output) {
				try {
					ClassFilePrinter printer = new ClassFilePrinter(cf.pool);
					printer.printNumber(cf.magicNumber, cf.majorVersion, cf.minorVersion);
					printer.printConstantPool();
					printer.printAccessFlag(cf.accessFlag);
					printer.printThisClass(cf.thisClass);
					printer.printSuperClass(cf.superClass);
					printer.printInterface(cf.interfaces);
					printer.printFields(cf.fields);
					printer.printMethods(cf.methods);
					printer.printAttributes(cf.attr);
				} catch(Exception e) {
					e.printStackTrace();
				}
			}
			ClassContent cc = new ClassContent(cf);
			DecompileProcessor dp = new DecompileProcessor();
			dp.process(cc);
		}
	}
}<commit_msg>cope with jar file.<commit_after>package sds;

import java.io.File;
import java.io.InputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import sds.assemble.ClassContent;
import sds.decompile.DecompileProcessor;
import sds.util.ClassFilePrinter;
import sds.util.Utf8ValueExtractor;
import org.eclipse.collections.impl.list.mutable.FastList;

/**
 * This class is for driving SDS.
 * @author inagaki
 */
public class SDS {
	private FastList<String> argList;
	private FastList<byte[]> jarContents;
	private FastList<InputStream> streams;
	private JarFile jar;

	/**
	 * constructor.
	 * @param args command line arguments
	 */
	public SDS(String[] args) {
		this.argList = new FastList<>();
		this.jarContents = new FastList<>();
		this.streams = new FastList<>();
		for(String arg : args) {
			if(arg.endsWith(".class")) {
				argList.add(arg);
			} else if(arg.endsWith(".jar")) {
				try {
					this.jar = new JarFile(new File(arg));
				} catch(IOException e) {
					e.printStackTrace();
				}
			} else {
				System.out.println(arg + " is not classfile or jar.");
			}
		}
	}

	/**
	 * starts SDS.
	 */
	public void run() {
		boolean output = true;
		// classfile
		for(String arg : argList) {
			ClassFileReader reader = new ClassFileReader(arg);
			reader.read();
			ClassFile cf = reader.getClassFile();
			if(output) {
				try {
					ClassFilePrinter printer = new ClassFilePrinter(cf.pool);
					printer.printNumber(cf.magicNumber, cf.majorVersion, cf.minorVersion);
					printer.printConstantPool();
					printer.printAccessFlag(cf.accessFlag);
					printer.printThisClass(cf.thisClass);
					printer.printSuperClass(cf.superClass);
					printer.printInterface(cf.interfaces);
					printer.printFields(cf.fields);
					printer.printMethods(cf.methods);
					printer.printAttributes(cf.attr);
				} catch(Exception e) {
					e.printStackTrace();
				}
			}
			ClassContent cc = new ClassContent(cf);
			DecompileProcessor dp = new DecompileProcessor();
			dp.process(cc);
		}
		
		// jar
//		for(byte[] b : jarContents) {
//		for(InputStream b : streams) {
		if(jar == null)
			return;
		try {
			for(Enumeration<JarEntry> e = jar.entries(); e.hasMoreElements();) {
				JarEntry entry = e.nextElement();
				if(! entry.toString().endsWith(".class")) {
					continue;
				}
				ClassFileReader reader = new ClassFileReader(jar.getInputStream(entry));
				reader.read();
				ClassFile cf = reader.getClassFile();
				if(output) {
					ClassFilePrinter printer = new ClassFilePrinter(cf.pool);
					printer.printNumber(cf.magicNumber, cf.majorVersion, cf.minorVersion);
//					printer.printConstantPool();
					printer.printAccessFlag(cf.accessFlag);
					printer.printThisClass(cf.thisClass);
					printer.printSuperClass(cf.superClass);
					printer.printInterface(cf.interfaces);
					printer.printFields(cf.fields);
					printer.printMethods(cf.methods);
//					printer.printAttributes(cf.attr);
				}
				ClassContent cc = new ClassContent(cf);
//			DecompileProcessor dp = new DecompileProcessor();
//			dp.process(cc);
			}
		} catch(Exception e) {}
	}
}
{'fraction_non_alphanumeric': 0.13197278911564625, 'fraction_numerical': 0.00022675736961451248, 'mean_word_length': 3.5709844559585493, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '1330951', 'n_tokens_mistral': 1699, 'n_tokens_neox': 1408, 'n_words': 276}