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

/**
 * Signals, that an attempt to write an attribute has been failed,
 * because it cannot be written with any value.
 *
 * This exception will be thrown by {@link Item#set(FunctionAttribute,Object) Item.set}
 * if that attribute is {@link Attribute#isFinal() final}.
 * 
 * @author Ralf Wiebicke
 */
public final class FinalViolationException extends ConstraintViolationException
{

	private final Item item;
	private final Attribute readOnlyAttribute;
	
	/**
	 * Creates a new FinalViolationException with the neccessary information about the violation.
	 * @param item initializes, what is returned by {@link #getItem()}.
	 * @param readOnlyAttribute initializes, what is returned by {@link #getFinalAttribute()}.
	 */
	public FinalViolationException(final Item item, final Attribute readOnlyAttribute)
	{
		super(null);
		this.item = item;
		this.readOnlyAttribute = readOnlyAttribute;
	}
	
	/**
	 * Returns the item that was attempted to be modified.
	 */
	public final Item getItem()
	{
		return item;
	}

	/**
	 * Returns the attribute, that was attempted to be written.
	 */
	public Attribute getFinalAttribute()
	{
		return readOnlyAttribute;
	}

	public String getMessage()
	{
		return "read-only violation on " + item.getCopeID() + " for " + readOnlyAttribute;
	}
	
}

@@ -1255,32 +1255,29 @@
 l Attribute 
-readOnly
+final
 Attribute;%0A%09
@@ -1457,24 +1457,21 @@
  @param 
-readOnly
+final
 Attribut
@@ -1605,24 +1605,21 @@
 tribute 
-readOnly
+final
 Attribut
@@ -1666,24 +1666,21 @@
 %0A%09%09this.
-readOnly
+final
 Attribut
@@ -1683,24 +1683,21 @@
 ibute = 
-readOnly
+final
 Attribut
@@ -1942,24 +1942,21 @@
 %09return 
-readOnly
+final
 Attribut
@@ -2063,16 +2063,13 @@
 %22 + 
-readOnly
+final
 Attr

rename readOnlyAttribute to finalAttribute