/*
 * Copyright (C) 2004-2006  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;

import java.util.Map;


abstract class State
{
	final Item item;
	final Type type;
	final int pk;


	protected State(final Item item)
	{
		this.item = item;
		this.type = item.type;
		this.pk = item.pk;

		if(pk==Type.NOT_A_PK)
			throw new RuntimeException();
	}
	
	abstract Object get(FunctionField attribute);
	
	abstract <E> State put(Transaction transaction, FunctionField<E> attribute, E value);
	
	abstract State write(Transaction transaction, Map<BlobColumn, byte[]> blobs);
	
	
	abstract Object store(final Column column);

	abstract State delete( Transaction transaction );
	
	void discard( final Transaction transaction )
	{
		transaction.removeEntity( item );
	}
	
	abstract Row stealValues();
	
	abstract boolean exists();

	@Override
	public String toString()
	{
		return getClass().getName()+"-"+item.getCopeID();
	}

	public abstract String toStringWithValues();
}

@@ -1124,25 +1124,21 @@
 onField 
-attribute
+field
 );%0A%09%0A%09ab
@@ -1204,17 +1204,13 @@
 %3CE%3E 
-attribute
+field
 , E 

rename attribute to field