summaryrefslogtreecommitdiffstats
path: root/src/java/com/healthmarketscience/jackcess/Table.java
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2008-03-14 19:34:14 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2008-03-14 19:34:14 +0000
commit975ae3f8bbfad31652947a1aed51046082821a3a (patch)
treee309b0dc6507717d23308f6955576dca7f3260e5 /src/java/com/healthmarketscience/jackcess/Table.java
parenta0c5a05bded5f265079f444b9e113a0d40660d75 (diff)
downloadjackcess-975ae3f8bbfad31652947a1aed51046082821a3a.tar.gz
jackcess-975ae3f8bbfad31652947a1aed51046082821a3a.zip
fix creation of tables with auto-number columns
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@273 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/java/com/healthmarketscience/jackcess/Table.java')
-rw-r--r--src/java/com/healthmarketscience/jackcess/Table.java26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/java/com/healthmarketscience/jackcess/Table.java b/src/java/com/healthmarketscience/jackcess/Table.java
index 311f0ad..0c30d79 100644
--- a/src/java/com/healthmarketscience/jackcess/Table.java
+++ b/src/java/com/healthmarketscience/jackcess/Table.java
@@ -735,7 +735,12 @@ public class Table
buffer.putShort((short) 0); //Unknown
buffer.putInt(0); //Number of rows
buffer.putInt(0); //Last Autonumber
- for (int i = 0; i < 16; i++) { //Unknown
+ if(countAutoNumberColumns(columns) > 0) {
+ buffer.put((byte) 1);
+ } else {
+ buffer.put((byte) 0);
+ }
+ for (int i = 0; i < 15; i++) { //Unknown
buffer.put((byte) 0);
}
buffer.put(Table.TYPE_USER); //Table type
@@ -1310,6 +1315,11 @@ public class Table
return ++_lastAutoNumber;
}
+ int getLastAutoNumber() {
+ // gets the last used auto number (does not modify)
+ return _lastAutoNumber;
+ }
+
@Override
public String toString() {
StringBuilder rtn = new StringBuilder();
@@ -1491,6 +1501,20 @@ public class Table
return rowSize + format.SIZE_ROW_LOCATION;
}
+ /**
+ * @return the number of "AutoNumber" columns in the given collection of
+ * columns.
+ */
+ public static int countAutoNumberColumns(Collection<Column> columns) {
+ int numAutoNumCols = 0;
+ for(Column c : columns) {
+ if(c.isAutoNumber()) {
+ ++numAutoNumCols;
+ }
+ }
+ return numAutoNumCols;
+ }
+
/** various statuses for the row data */
private enum RowStatus {
INIT, INVALID_PAGE, INVALID_ROW, VALID, DELETED, NORMAL, OVERFLOW;