<commit_before>package org.qfox.jestful.server.wrapper;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import org.qfox.jestful.core.Action;
import org.qfox.jestful.core.Actor;
import org.qfox.jestful.core.BeanContainer;
import org.qfox.jestful.core.Encoding;
import org.qfox.jestful.core.Encodings;
import org.qfox.jestful.core.Initialable;
import org.qfox.jestful.core.Response;
import org.qfox.jestful.core.codec.ResponseEncoder;
import org.qfox.jestful.core.exception.NoSuchCodecException;
import org.qfox.jestful.server.JestfulServletResponse;

public class ResponseEncodeWrapper implements Actor, Initialable {
	private final Map<Encoding, ResponseEncoder> map = new HashMap<Encoding, ResponseEncoder>();

	public Object react(Action action) throws Exception {
		if (action.isAllowEncode()) {
			Encodings encodings = action.getContentEncodings().clone();
			Encodings availables = new Encodings(map.keySet());
			if (encodings.isEmpty() == false) {
				encodings.retainAll(availables);
			} else {
				encodings = availables;
			}
			if (encodings.isEmpty()) {
				Encodings expects = action.getContentEncodings();
				Encodings actuals = availables;
				throw new NoSuchCodecException(expects, actuals);
			}
			Encoding encoding = encodings.first();
			ResponseEncoder encoder = map.get(encoding);
			Response source = action.getResponse();
			Response target = new EncodedServletResponse((JestfulServletResponse) source, encoding, encoder);
			target.setResponseHeader("Content-Encoding", encoding.toString(false));
			action.setResponse(target);
		}
		return null;
	}

	public void initialize(BeanContainer beanContainer) {
		Collection<ResponseEncoder> encoders = beanContainer.find(ResponseEncoder.class).values();
		for (ResponseEncoder encoder : encoders) {
			String contentEncoding = encoder.getContentEncoding();
			Encoding encoding = Encoding.valueOf(contentEncoding);
			map.put(encoding, encoder);
		}
	}

}<commit_msg>foolish bug fix<commit_after>package org.qfox.jestful.server.wrapper;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import org.qfox.jestful.core.Action;
import org.qfox.jestful.core.Actor;
import org.qfox.jestful.core.BeanContainer;
import org.qfox.jestful.core.Encoding;
import org.qfox.jestful.core.Encodings;
import org.qfox.jestful.core.Initialable;
import org.qfox.jestful.core.Response;
import org.qfox.jestful.core.codec.ResponseEncoder;
import org.qfox.jestful.core.exception.NoSuchCodecException;
import org.qfox.jestful.server.JestfulServletResponse;

public class ResponseEncodeWrapper implements Actor, Initialable {
	private final Map<Encoding, ResponseEncoder> map = new HashMap<Encoding, ResponseEncoder>();

	public Object react(Action action) throws Exception {
		if (action.isAllowEncode()) {
			Encodings encodings = action.getContentEncodings().clone();
			Encodings availables = new Encodings(map.keySet());
			if (encodings.isEmpty() == false) {
				encodings.retainAll(availables);
			} else {
				encodings = availables;
			}
			if (encodings.isEmpty()) {
				Encodings expects = action.getContentEncodings();
				Encodings actuals = availables;
				throw new NoSuchCodecException(expects, actuals);
			}
			Encoding encoding = encodings.first();
			ResponseEncoder encoder = map.get(encoding);
			Response source = action.getResponse();
			Response target = new EncodedServletResponse((JestfulServletResponse) source, encoding, encoder);
			target.setResponseHeader("Content-Encoding", encoding.toString(false));
			action.setResponse(target);
		}
		return action.execute();
	}

	public void initialize(BeanContainer beanContainer) {
		Collection<ResponseEncoder> encoders = beanContainer.find(ResponseEncoder.class).values();
		for (ResponseEncoder encoder : encoders) {
			String contentEncoding = encoder.getContentEncoding();
			Encoding encoding = Encoding.valueOf(contentEncoding);
			map.put(encoding, encoder);
		}
	}

}
{'fraction_non_alphanumeric': 0.11040929762506316, 'fraction_numerical': 0.0, 'mean_word_length': 5.344551282051282, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '987098', 'n_tokens_mistral': 1323, 'n_tokens_neox': 1177, 'n_words': 234}