<commit_before>/**
 * 
 */
package org.commcare.cases.util;

import java.util.Date;
import java.util.NoSuchElementException;
import java.util.Stack;
import java.util.Vector;

import org.commcare.cases.model.Case;
import org.javarosa.core.model.data.DateTimeData;
import org.javarosa.core.model.data.IAnswerData;
import org.javarosa.core.model.instance.FormInstance;
import org.javarosa.core.model.instance.TreeElement;
import org.javarosa.core.model.instance.TreeReference;
import org.javarosa.core.services.Logger;
import org.javarosa.core.services.storage.IStorageUtility;
import org.javarosa.core.services.storage.IStorageUtilityIndexed;
import org.javarosa.core.services.storage.StorageFullException;
import org.javarosa.core.services.storage.StorageManager;
import org.javarosa.core.util.InvalidIndexException;
import org.javarosa.core.util.PropertyUtils;
import org.javarosa.xform.util.XFormAnswerDataSerializer;

/**
 * @author ctsims
 *
 */
public class CaseModelProcessor implements ICaseModelProcessor {

	XFormAnswerDataSerializer serializer = new XFormAnswerDataSerializer();
	Case c;
	
	public Case getCase() {
		return c;
	}
	
	/* (non-Javadoc)
	 * @see org.javarosa.core.model.utils.IInstanceProcessor#processModel(org.javarosa.core.model.instance.FormInstance)
	 */
	public void processInstance(FormInstance tree) {
		Vector caseElements = scrapeForCaseElements(tree);
		for(int i=0; i < caseElements.size(); ++i) {
			try {
				processCase((TreeElement)caseElements.elementAt(i));
			} catch (MalformedCaseModelException e) {
				throw new RuntimeException(e.getMessage());
			}
		}
	}
	
	private void processCase(TreeElement caseElement) throws MalformedCaseModelException {<commit_msg>Fixed a bug with multiple case processing<commit_after>/**
 * 
 */
package org.commcare.cases.util;

import java.util.Date;
import java.util.NoSuchElementException;
import java.util.Stack;
import java.util.Vector;

import org.commcare.cases.model.Case;
import org.javarosa.core.model.data.DateTimeData;
import org.javarosa.core.model.data.IAnswerData;
import org.javarosa.core.model.instance.FormInstance;
import org.javarosa.core.model.instance.TreeElement;
import org.javarosa.core.model.instance.TreeReference;
import org.javarosa.core.services.Logger;
import org.javarosa.core.services.storage.IStorageUtility;
import org.javarosa.core.services.storage.IStorageUtilityIndexed;
import org.javarosa.core.services.storage.StorageFullException;
import org.javarosa.core.services.storage.StorageManager;
import org.javarosa.core.util.InvalidIndexException;
import org.javarosa.core.util.PropertyUtils;
import org.javarosa.xform.util.XFormAnswerDataSerializer;

/**
 * @author ctsims
 *
 */
public class CaseModelProcessor implements ICaseModelProcessor {

	XFormAnswerDataSerializer serializer = new XFormAnswerDataSerializer();
	Case c;
	
	public Case getCase() {
		return c;
	}
	
	/* (non-Javadoc)
	 * @see org.javarosa.core.model.utils.IInstanceProcessor#processModel(org.javarosa.core.model.instance.FormInstance)
	 */
	public void processInstance(FormInstance tree) {
		Vector caseElements = scrapeForCaseElements(tree);
		for(int i=0; i < caseElements.size(); ++i) {
			try {
				processCase((TreeElement)caseElements.elementAt(i));
			} catch (MalformedCaseModelException e) {
				throw new RuntimeException(e.getMessage());
			}
		}
	}
	
	private void processCase(TreeElement caseElement) throws MalformedCaseModelException {
		c = null;
{'fraction_non_alphanumeric': 0.11020881670533643, 'fraction_numerical': 0.000580046403712297, 'mean_word_length': 5.53219696969697, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4040802', 'n_tokens_mistral': 1134, 'n_tokens_neox': 1074, 'n_words': 180}