<commit_before>/*
 * Copyright (C) 2004-2009  exedio GmbH (www.exedio.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package com.exedio.cope.editor;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.exedio.cope.Cope;
import com.exedio.cope.Feature;
import com.exedio.cope.IntegerField;
import com.exedio.cope.Item;
import com.exedio.cope.StringField;
import com.exedio.cope.pattern.MapField;
import com.exedio.cope.pattern.Media;
import com.exedio.cope.pattern.MediaFilter;
import com.exedio.cops.XMLEncoder;

final class LiveRequest
{
	static LiveRequest get(
			final Editor filter,
			final HttpServletRequest request,
			final HttpServletResponse response)
	{
		final HttpSession httpSession = request.getSession(false);
		if(httpSession!=null)
		{
			final Object anchor = httpSession.getAttribute(Editor.ANCHOR);
			if(anchor!=null)
				return new LiveRequest(filter, request, response, (Anchor)anchor);
			else
				return null;
		}
		else
		{
			return null;
		}
	}
	
	private final Editor filter;
	private final HttpServletRequest request;
	private final HttpServletResponse response;
	private final Anchor anchor;
	private HashMap<IntegerField, Item> positionItems = null;
	
	private LiveRequest(
			final Editor filter,
			final HttpServletRequest request,
			final HttpServletResponse response,
			final Anchor anchor)
	{
		this.filter = filter;
		this.request = request;
		this.response = response;
		this.anchor = anchor;<commit_msg>simplify code<commit_after>/*
 * Copyright (C) 2004-2009  exedio GmbH (www.exedio.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package com.exedio.cope.editor;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.exedio.cope.Cope;
import com.exedio.cope.Feature;
import com.exedio.cope.IntegerField;
import com.exedio.cope.Item;
import com.exedio.cope.StringField;
import com.exedio.cope.pattern.MapField;
import com.exedio.cope.pattern.Media;
import com.exedio.cope.pattern.MediaFilter;
import com.exedio.cops.XMLEncoder;

final class LiveRequest
{
	static LiveRequest get(
			final Editor filter,
			final HttpServletRequest request,
			final HttpServletResponse response)
	{
		final HttpSession httpSession = request.getSession(false);
		if(httpSession==null)
			return null;
		
		final Object anchor = httpSession.getAttribute(Editor.ANCHOR);
		if(anchor==null)
			return null;
		
		return new LiveRequest(filter, request, response, (Anchor)anchor);
	}
	
	private final Editor filter;
	private final HttpServletRequest request;
	private final HttpServletResponse response;
	private final Anchor anchor;
	private HashMap<IntegerField, Item> positionItems = null;
	
	private LiveRequest(
			final Editor filter,
			final HttpServletRequest request,
			final HttpServletResponse response,
			final Anchor anchor)
	{
		this.filter = filter;
		this.request = request;
		this.response = response;
		this.anchor = anchor;
{'fraction_non_alphanumeric': 0.0779777206512425, 'fraction_numerical': 0.010282776349614395, 'mean_word_length': 4.42906976744186, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5618580', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1343, 'n_words': 472}