summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2013-03-16 01:23:35 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2013-03-16 01:23:35 +0000
commit85a420ac034a513368adffba6185a97d858350a1 (patch)
treeb84d79ac8da1829f48a95783f2901d53730ed068
parent3a62a7937de11bd539aed54075667b64d65eb2e6 (diff)
downloadjackcess-85a420ac034a513368adffba6185a97d858350a1.tar.gz
jackcess-85a420ac034a513368adffba6185a97d858350a1.zip
add more details to unsupported index exceptions
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/jackcess-2@691 f203690c-595d-4dc9-a70b-905162fa7fd2
-rw-r--r--src/java/com/healthmarketscience/jackcess/impl/IndexCursorImpl.java5
-rw-r--r--src/java/com/healthmarketscience/jackcess/impl/IndexData.java46
2 files changed, 25 insertions, 26 deletions
diff --git a/src/java/com/healthmarketscience/jackcess/impl/IndexCursorImpl.java b/src/java/com/healthmarketscience/jackcess/impl/IndexCursorImpl.java
index e477327..0407c15 100644
--- a/src/java/com/healthmarketscience/jackcess/impl/IndexCursorImpl.java
+++ b/src/java/com/healthmarketscience/jackcess/impl/IndexCursorImpl.java
@@ -146,10 +146,11 @@ public class IndexCursorImpl extends CursorImpl implements IndexCursor
"JetFormat " + table.getFormat() +
" does not currently support index lookups");
}
- if(index.getIndexData().isReadOnly()) {
+ if(index.getIndexData().getUnsupportedReason() != null) {
throw new IllegalArgumentException(
"Given index " + index +
- " is not usable for indexed lookups because it is read-only");
+ " is not usable for indexed lookups due to " +
+ index.getIndexData().getUnsupportedReason());
}
IndexCursorImpl cursor = new IndexCursorImpl(table, index,
index.cursor(startRow, startInclusive,
diff --git a/src/java/com/healthmarketscience/jackcess/impl/IndexData.java b/src/java/com/healthmarketscience/jackcess/impl/IndexData.java
index 4533fa5..f4e95ee 100644
--- a/src/java/com/healthmarketscience/jackcess/impl/IndexData.java
+++ b/src/java/com/healthmarketscience/jackcess/impl/IndexData.java
@@ -37,15 +37,13 @@ import java.util.Comparator;
import java.util.List;
import java.util.Map;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import static com.healthmarketscience.jackcess.impl.IndexCodes.*;
-import static com.healthmarketscience.jackcess.impl.ByteUtil.ByteStream;
+import com.healthmarketscience.jackcess.ColumnBuilder;
import com.healthmarketscience.jackcess.Index;
-import com.healthmarketscience.jackcess.RowId;
import com.healthmarketscience.jackcess.IndexBuilder;
-import com.healthmarketscience.jackcess.ColumnBuilder;
+import static com.healthmarketscience.jackcess.impl.ByteUtil.ByteStream;
+import static com.healthmarketscience.jackcess.impl.IndexCodes.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* Access table index data. This is the actual data which backs a logical
@@ -179,8 +177,8 @@ public class IndexData {
private final int _maxPageEntrySize;
/** whether or not this index data is backing a primary key logical index */
private boolean _primaryKey;
- /** FIXME, for SimpleIndex, we can't write multi-page indexes or indexes using the entry compression scheme */
- private boolean _readOnly;
+ /** if non-null, the reason why we cannot create entries for this index */
+ private String _unsupportedReason;
/** Cache which manages the index pages */
private final IndexPageCache _pageCache;
@@ -322,12 +320,13 @@ public class IndexData {
return _rootPageNumber;
}
- protected void setReadOnly() {
- _readOnly = true;
+ private void setUnsupportedReason(String reason) {
+ _unsupportedReason = reason;
+ LOG.warn(reason + ", making read-only");
}
- protected boolean isReadOnly() {
- return _readOnly;
+ String getUnsupportedReason() {
+ return _unsupportedReason;
}
protected int getMaxPageEntrySize() {
@@ -395,9 +394,9 @@ public class IndexData {
// make sure we've parsed the entries
initialize();
- if(_readOnly) {
+ if(_unsupportedReason != null) {
throw new UnsupportedOperationException(
- "FIXME cannot write indexes of this type yet, see Database javadoc for info on enabling large index support");
+ "Cannot write indexes of this type due to " + _unsupportedReason);
}
_pageCache.write();
}
@@ -1205,9 +1204,8 @@ public class IndexData {
return new GenTextColumnDescriptor(col, flags);
}
// unsupported sort order
- LOG.warn("Unsupported collating sort order " + sortOrder +
- " for text index, making read-only");
- setReadOnly();
+ setUnsupportedReason("unsupported collating sort order " + sortOrder +
+ " for text index");
return new ReadOnlyColumnDescriptor(col, flags);
case INT:
case LONG:
@@ -1230,10 +1228,9 @@ public class IndexData {
return new GuidColumnDescriptor(col, flags);
default:
- // FIXME we can't modify this index at this point in time
- LOG.warn("Unsupported data type " + col.getType() +
- " for index, making read-only");
- setReadOnly();
+ // we can't modify this index at this point in time
+ setUnsupportedReason("unsupported data type " + col.getType() +
+ " for index");
return new ReadOnlyColumnDescriptor(col, flags);
}
}
@@ -1624,7 +1621,7 @@ public class IndexData {
/**
* ColumnDescriptor for columns which we cannot currently write.
*/
- private static final class ReadOnlyColumnDescriptor extends ColumnDescriptor
+ private final class ReadOnlyColumnDescriptor extends ColumnDescriptor
{
private ReadOnlyColumnDescriptor(ColumnImpl column, byte flags)
throws IOException
@@ -1636,7 +1633,8 @@ public class IndexData {
protected void writeNonNullValue(Object value, ByteStream bout)
throws IOException
{
- throw new UnsupportedOperationException("should not be called");
+ throw new UnsupportedOperationException(
+ "Cannot write indexes of this type due to " + _unsupportedReason);
}
}