/*
 * 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.util.HashMap;

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

import com.exedio.cope.IntegerField;
import com.exedio.cope.Item;

	final class TL
	{
		final Editor filter;
		final HttpServletRequest request;
		final HttpServletResponse response;
		final Anchor anchor;
		private HashMap<IntegerField, Item> positionItems = null;
		
		TL(
				final Editor filter,
				final HttpServletRequest request,
				final HttpServletResponse response,
				final Anchor anchor)
		{
			this.filter = filter;
			this.request = request;
			this.response = response;
			this.anchor = anchor;
			
			assert filter!=null;
			assert request!=null;
			assert response!=null;
			assert anchor!=null;
		}
		
		Item registerPositionItem(final IntegerField feature, final Item item)
		{
			final Integer next = feature.get(item);
			if(next==null)
				return null;
			
			if(positionItems==null)
				positionItems = new HashMap<IntegerField, Item>();
			
			final Item result = positionItems.put(feature, item);
			if(result==null)
				return null;
			
			final Integer previous = feature.get(result);
			return (previous!=null && previous.intValue()<next.intValue()) ? result : null;
		}
	}

@@ -1018,17 +1018,16 @@
 .Item;%0A%0A
-%09
 final cl
@@ -1033,20 +1033,18 @@
 lass TL%0A
-%09
 %7B%0A
-%09
 %09final E
@@ -1057,17 +1057,16 @@
 filter;%0A
-%09
 %09final H
@@ -1092,17 +1092,16 @@
 equest;%0A
-%09
 %09final H
@@ -1129,17 +1129,16 @@
 sponse;%0A
-%09
 %09final A
@@ -1151,17 +1151,16 @@
 anchor;%0A
-%09
 %09private
@@ -1215,17 +1215,14 @@
 l;%0A%09
-%09%0A%09
+%0A
 %09TL(%0A
-%09
 %09%09%09f
@@ -1241,17 +1241,16 @@
 filter,%0A
-%09
 %09%09%09final
@@ -1277,25 +1277,24 @@
 request,%0A%09%09%09
-%09
 final HttpSe
@@ -1320,17 +1320,16 @@
 nse,%0A%09%09%09
-%09
 final An
@@ -1341,23 +1341,21 @@
 anchor)%0A
-%09
 %09%7B%0A%09%09
-%09
 this.fil
@@ -1368,17 +1368,16 @@
 filter;%0A
-%09
 %09%09this.r
@@ -1392,25 +1392,24 @@
  request;%0A%09%09
-%09
 this.respons
@@ -1424,17 +1424,16 @@
 onse;%0A%09%09
-%09
 this.anc
@@ -1448,21 +1448,19 @@
 chor;%0A%09%09
-%09
 %0A%09%09
-%09
 assert f
@@ -1464,33 +1464,32 @@
 t filter!=null;%0A
-%09
 %09%09assert request
@@ -1494,25 +1494,24 @@
 st!=null;%0A%09%09
-%09
 assert respo
@@ -1523,17 +1523,16 @@
 null;%0A%09%09
-%09
 assert a
@@ -1548,16 +1548,13 @@
 ll;%0A
-%09
 %09%7D%0A%09
-%09%0A%09
+%0A
 %09Ite
@@ -1625,15 +1625,13 @@
 em)%0A
-%09
 %09%7B%0A%09%09
-%09
 fina
@@ -1668,17 +1668,16 @@
 tem);%0A%09%09
-%09
 if(next=
@@ -1675,33 +1675,32 @@
 %09if(next==null)%0A
-%09
 %09%09%09return null;%0A
@@ -1701,19 +1701,17 @@
 null;%0A%09%09
-%09%0A%09
+%0A
 %09%09if(pos
@@ -1731,17 +1731,16 @@
 ull)%0A%09%09%09
-%09
 position
@@ -1780,27 +1780,25 @@
  Item%3E();%0A%09%09
-%09%0A%09
+%0A
 %09%09final Item
@@ -1843,17 +1843,16 @@
 tem);%0A%09%09
-%09
 if(resul
@@ -1860,17 +1860,16 @@
 ==null)%0A
-%09
 %09%09%09retur
@@ -1878,19 +1878,17 @@
 null;%0A%09%09
-%09%0A%09
+%0A
 %09%09final 
@@ -1927,17 +1927,16 @@
 esult);%0A
-%09
 %09%09return
@@ -2013,11 +2013,9 @@
 ll;%0A
-%09
 %09%7D%0A
-%09
 %7D%0A

fix identation