<commit_before>package org.adligo.j2se.util;

import java.io.IOException;
import java.io.InputStream;

import org.adligo.i.util.client.Event;
import org.adligo.i.util.client.I_Factory;
import org.adligo.i.util.client.I_Listener;
import org.adligo.i.util.client.I_Map;
import org.adligo.i.util.client.ListenerValueObject;
import org.adligo.i.util.client.MapFactory;
import org.adligo.i.util.client.PropertyFactory;
import org.adligo.i.util.client.StringUtils;

public class J2SEPropertyFactory extends PropertyFactory implements I_Factory {

	/**
	 * get a file from the relative url
	 * this is done in a single threaded synchronus way
	 * with a callback
	 * 
	 */
	public Object createNew(Object p) {
		ListenerValueObject list = (ListenerValueObject) p;
		String propClasspathName = (String) list.getValue();
		I_Listener callback = list.getListener();
		
		try {
			InputStream in = J2SEPropertyFactory.class.getResourceAsStream(propClasspathName);
			
			/**
			 * this will only read askii and not 
			 * extended utf8 (chineese, sanskrit exc)
			 */
			StringBuffer sb = new StringBuffer();
			byte [] b = new byte[1];
			if (in != null) {
				while ( (in.read(b)) != -1) {
					sb.append((char) b[0]);
				}
			}
			I_Map map = MapFactory.create();
			StringUtils.parse(sb.toString(), map);
			Event e = new Event();
			e.setValue(map);
			callback.onEvent(e);
			
		} catch (IOException x) {
			x.printStackTrace();
		}
		
		return callback;
	}
	
	protected static void init() throws Exception {
		init(new J2SEPropertyFactory());
	}
}
<commit_msg>refactored the way property files errors get handled<commit_after>package org.adligo.j2se.util;

import java.io.InputStream;
import java.net.URL;

import org.adligo.i.util.client.Event;
import org.adligo.i.util.client.I_Factory;
import org.adligo.i.util.client.I_Listener;
import org.adligo.i.util.client.I_Map;
import org.adligo.i.util.client.ListenerValueObject;
import org.adligo.i.util.client.MapFactory;
import org.adligo.i.util.client.PropertyFactory;
import org.adligo.i.util.client.PropertyFileReadException;
import org.adligo.i.util.client.StringUtils;

public class J2SEPropertyFactory extends PropertyFactory implements I_Factory {
	/**
	 * get a file from the relative url
	 * this is done in a single threaded synchronus way
	 * with a callback
	 * 
	 */
	public Object createNew(Object p) {
		ListenerValueObject list = (ListenerValueObject) p;
		String propClasspathName = (String) list.getValue();
		I_Listener callback = list.getListener();
		
		try {
			Class<?> c = this.getClass();
	        URL r = c.getResource(propClasspathName);
	        InputStream in = r.openStream();
			
			/**
			 * this will only read askii and not 
			 * extended utf8 (chineese, sanskrit exc)
			 */
			StringBuffer sb = new StringBuffer();
			byte [] b = new byte[1];
			if (in != null) {
				while ( (in.read(b)) != -1) {
					sb.append((char) b[0]);
				}
			}
			I_Map map = MapFactory.create();
			StringUtils.parse(sb.toString(), map);
			Event e = new Event();
			e.setValue(map);
			callback.onEvent(e);
			
		} catch (Exception x) {
			PropertyFileReadException ex = new PropertyFileReadException(
					"Error reading property file " + propClasspathName);
			ex.initCause(x);
			
			Event e = new Event();
			e.setValue(ex);
			callback.onEvent(e);
		}
		
		return callback;
	}
	
	protected static void init() throws Exception {
		init(new J2SEPropertyFactory());
	}
}

{'fraction_non_alphanumeric': 0.12085032032615026, 'fraction_numerical': 0.004368083867210251, 'mean_word_length': 3.573901464713715, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '6980601', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1114, 'n_words': 270}