<commit_before>package gov.nih.nci.cananolab.util;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

/**
 * Utilility class to handle domain class manipulations
 * 
 * @author pansu
 * 
 */
public class ClassUtils {
	/**
	 * Get all caNanoLab domain classes
	 * 
	 * @return
	 * @throws Exception
	 */
	public static Collection<Class> getDomainClasses() throws Exception {
		Collection<Class> list = new ArrayList<Class>();
		JarFile file = null;
		URL url = Thread.currentThread().getContextClassLoader().getResource(
				"application-config.xml");

		File webinfDirect = (new File(url.getPath())).getParentFile()
				.getParentFile();

		String fullJarFilePath = webinfDirect + File.separator + "lib"
				+ File.separatorChar + Constants.SDK_BEAN_JAR;
		file = new JarFile(fullJarFilePath);

		if (file == null)
			throw new Exception("Could not locate the bean jar");
		Enumeration e = file.entries();
		while (e.hasMoreElements()) {
			JarEntry o = (JarEntry) e.nextElement();
			if (!o.isDirectory()) {
				String name = o.getName();
				if (name.endsWith(".class")) {
					String klassName = name.replace('/', '.').substring(0,
							name.lastIndexOf('.'));
					list.add(Class.forName(klassName));
				}
			}
		}
		return list;
	}

	/**
	 * Get child classes of a parent class in caNanoLab
	 * 
	 * @param parentClassName
	 * @return
	 * @throws Exception
	 */
	public static List<Class> getChildClasses(String parentClassName)<commit_msg>updated getDomainClasses to handle the use in the grid service<commit_after>package gov.nih.nci.cananolab.util;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

/**
 * Utilility class to handle domain class manipulations
 * 
 * @author pansu
 * 
 */
public class ClassUtils {
	/**
	 * Get all caNanoLab domain classes
	 * 
	 * @return
	 * @throws Exception
	 */
	public static Collection<Class> getDomainClasses() throws Exception {
		Collection<Class> list = new ArrayList<Class>();
		JarFile file = null;
		URL url = Thread.currentThread().getContextClassLoader().getResource(
				"client-config.wsdd");

		File webInfDirectory = (new File(url.getPath())).getParentFile()
				.getParentFile();

		String fullJarFilePath = webInfDirectory + File.separator + "lib"
				+ File.separatorChar + Constants.SDK_BEAN_JAR;

		file = new JarFile(fullJarFilePath);

		if (file == null)
			throw new Exception("Could not locate the bean jar");
		Enumeration e = file.entries();
		while (e.hasMoreElements()) {
			JarEntry o = (JarEntry) e.nextElement();
			if (!o.isDirectory()) {
				String name = o.getName();
				if (name.endsWith(".class")) {
					String klassName = name.replace('/', '.').substring(0,
							name.lastIndexOf('.'));
					list.add(Class.forName(klassName));
				}
			}
		}
		return list;
	}

	/**
	 * Get child classes of a parent class in caNanoLab
	 * 
	 * @param parentClassName
	 * @return
	 * @throws Exception
	 */
	public static List<Class> getChildClasses(String parentClassName)
{'fraction_non_alphanumeric': 0.12563840653728295, 'fraction_numerical': 0.0005107252298263534, 'mean_word_length': 4.106910039113429, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, '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': '817122', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1201, 'n_words': 296}