<commit_before>/**
 * 
 */
package org.intermine.webservice.server.output;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

import org.intermine.webservice.server.core.ResultProcessor;
import org.intermine.api.results.ExportResultsIterator;
import org.intermine.api.results.ResultElement;
import org.intermine.webservice.server.output.Output;
import org.json.JSONObject;

/**
 * @author <NAME>
 *
 */
public class JSONObjResultProcessor extends ResultProcessor {

	
	/**
	 * Constructor.
	 */
	public JSONObjResultProcessor() {
		// Empty constructor
	}
	
	@Override
	public void write(Iterator<List<ResultElement>> resultIt, Output output) {
		if (! (resultIt instanceof ExportResultsIterator)) {
			throw new IllegalArgumentException("The iterator must be an ExportResultsIterator");
		}
		ExportResultsIterator exportIter = (ExportResultsIterator) resultIt;
		JSONResultsIterator jsonIter = new JSONResultsIterator(exportIter);
		while (jsonIter.hasNext()) {
			JSONObject next = jsonIter.next();
			List<String> outputLine = new ArrayList<String>(
					Arrays.asList(next.toString()));
			if (jsonIter.hasNext()) { outputLine.add(""); };
			output.addResultItem(outputLine);
		}
	}
}<commit_msg>Uses the abstract parent class<commit_after>package org.intermine.webservice.server.output;

/*
 * Copyright (C) 2002-2011 FlyMine
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  See the LICENSE file for more
 * information or http://www.gnu.org/copyleft/lesser.html.
 *
 */

import java.util.Iterator;

import org.intermine.api.results.ExportResultsIterator;

/**
 * @author <NAME>
 *
 */
public class JSONObjResultProcessor extends JSONResultProcessor
{

    /**
     * Constructor.
     */
    public JSONObjResultProcessor() {
        // Empty constructor
    }

    @Override
    protected Iterator<? extends Object> getResultsIterator(ExportResultsIterator it) {
        JSONResultsIterator jsonIter = new JSONResultsIterator(it);
        return jsonIter;
    }

}
{'fraction_non_alphanumeric': 0.10700934579439253, 'fraction_numerical': 0.003738317757009346, 'mean_word_length': 4.209245742092458, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '5567695', 'n_tokens_mistral': 639, 'n_tokens_neox': 598, 'n_words': 147}