<author email="javajedi@users.sf.net">Tim McCune</author>
</properties>
<body>
+ <release version="2.0.2" date="TBD">
+ <action dev="jahlborn" type="update">
+ Add ConstraintViolationException to distinguish exceptions due to
+ violating database constraints from other random errors.
+ </action>
+ </release>
<release version="2.0.1" date="2013-10-13">
<action dev="jahlborn" type="add">
Add initial support for creating/parsing ole content.
--- /dev/null
+/*
+Copyright (c) 2013 James Ahlborn
+
+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.healthmarketscience.jackcess;
+
+import java.io.IOException;
+
+/**
+ * IOException which indicates that the failure was caused by a database
+ * constraint violation.
+ *
+ * @author James Ahlborn
+ */
+public class ConstraintViolationException extends IOException
+{
+ private static final long serialVersionUID = 20131113L;
+
+ public ConstraintViolationException(String msg) {
+ super(msg);
+ }
+}
+
import java.util.TreeSet;
import com.healthmarketscience.jackcess.Column;
+import com.healthmarketscience.jackcess.ConstraintViolationException;
import com.healthmarketscience.jackcess.Index;
import com.healthmarketscience.jackcess.IndexCursor;
import com.healthmarketscience.jackcess.Row;
// ensure that the relevant rows exist in the primary tables for which
// this table is a secondary table.
if(!joiner.hasRows(row)) {
- throw new IOException("Adding new row " + Arrays.asList(row) +
- " violates constraint " + joiner.toFKString());
+ throw new ConstraintViolationException(
+ "Adding new row " + Arrays.asList(row) + " violates constraint " +
+ joiner.toFKString());
}
}
// ensure that no rows exist in the secondary table for which this table is
// the primary table.
if(joiner.hasRows(row)) {
- throw new IOException("Removing old row " + Arrays.asList(row) +
- " violates constraint " + joiner.toFKString());
+ throw new ConstraintViolationException(
+ "Removing old row " + Arrays.asList(row) + " violates constraint " +
+ joiner.toFKString());
}
}
import java.util.Map;
import com.healthmarketscience.jackcess.ColumnBuilder;
+import com.healthmarketscience.jackcess.ConstraintViolationException;
import com.healthmarketscience.jackcess.Index;
import com.healthmarketscience.jackcess.IndexBuilder;
+import com.healthmarketscience.jackcess.RuntimeIOException;
import static com.healthmarketscience.jackcess.impl.ByteUtil.ByteStream;
import static com.healthmarketscience.jackcess.impl.IndexCodes.*;
import org.apache.commons.lang.builder.ToStringBuilder;
return;
}
if(isBackingPrimaryKey() && (nullCount > 0)) {
- throw new IOException("Null value found in row " + Arrays.asList(row)
- + " for primary key index " + this);
+ throw new ConstraintViolationException(
+ "Null value found in row " + Arrays.asList(row) +
+ " for primary key index " + this);
}
// make sure we've parsed the entries
((prevPos != null) &&
newEntry.equalsEntryBytes(prevPos.getEntry())));
if(isUnique() && !isNullEntry && isDupeEntry) {
- throw new IOException(
+ throw new ConstraintViolationException(
"New row " + Arrays.asList(row) +
" violates uniqueness constraint for index " + this);
}
try {
sb.append("entryCount", getEntryCount());
} catch(IOException e) {
- throw new RuntimeException(e);
+ throw new RuntimeIOException(e);
}
}
sb.append("pageCache", _pageCache);