@@ -0,0 +1,2627 @@
+/*%0A * Copyright (C) 2004-2005  exedio GmbH (www.exedio.com)%0A *%0A * This library is free software; you can redistribute it and/or%0A * modify it under the terms of the GNU Lesser General Public%0A * License as published by the Free Software Foundation; either%0A * version 2.1 of the License, or (at your option) any later version.%0A *%0A * This library is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU%0A * Lesser General Public License for more details.%0A *%0A * You should have received a copy of the GNU Lesser General Public%0A * License along with this library; if not, write to the Free Software%0A * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA%0A */%0A%0Apackage com.exedio.cope;%0A%0A/**%0A * Signals, that an attempt to write a %7B@link DataAttribute data attribute%7D has been failed,%0A * because value to be written violated the length constraint on that attribute.%0A *%0A * This exception will be thrown by %7B@link DataAttribute#set(Item,byte%5B%5D)%7D etc.%0A * and item constructors.%0A * %0A * @author Ralf Wiebicke%0A */%0Apublic final class DataLengthViolationException extends RuntimeException%0A%7B%0A%09// TODO introduce ConstraintRuntimeException%0A%09private final Item item;%0A%09private final DataAttribute dataAttribute;%0A%09private final long length;%0A%09%0A%09/**%0A%09 * Creates a new LengthViolationRuntimeException with the neccessary information about the violation.%0A%09 * @param item initializes, what is returned by %7B@link #getItem()%7D.%0A%09 * @param dataAttribute initializes, what is returned by %7B@link #getDataAttribute()%7D.%0A%09 * @param value initializes, what is returned by %7B@link #getValue()%7D.%0A%09 */%0A%09public DataLengthViolationException(final Item item, final DataAttribute dataAttribute, final long length)%0A%09%7B%0A%09%09super();%0A%09%09this.item = item;%0A%09%09this.dataAttribute = dataAttribute;%0A%09%09this.length = length;%0A%09%7D%0A%09%0A%09/**%0A%09 * Returns the item that was attempted to be modified.%0A%09 * Returns null, if the violation occured on the creation of an item.%0A%09 */%0A%09public final Item getItem()%0A%09%7B%0A%09%09return item;%0A%09%7D%0A%0A%09/**%0A%09 * Returns the attribute, that was attempted to be written.%0A%09 */%0A%09public DataAttribute getDataAttribute()%0A%09%7B%0A%09%09return dataAttribute;%0A%09%7D%0A%0A%09/**%0A%09 * Returns the length of the data, that was attempted to be written.%0A%09 * Returns -1, if that length is unknown.%0A%09 */%09%0A%09public long getLength()%0A%09%7B%0A%09%09return length;%0A%09%7D%0A%09%0A%09public String getMessage()%0A%09%7B%0A%09%09return%0A%09%09%09%22length violation on %22 + Cope.getCopeID(item) +%0A%09%09%09%22, %22 + (length%3E=0 ? String.valueOf(length) + %22 bytes %22 : %22%22) +%0A%09%09%09%22is too long for %22+ dataAttribute;%0A%09%7D%0A%09%0A%7D%0A

fix for: added length constraint for DataAttribute