diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2008-03-14 19:34:14 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2008-03-14 19:34:14 +0000 |
commit | 975ae3f8bbfad31652947a1aed51046082821a3a (patch) | |
tree | e309b0dc6507717d23308f6955576dca7f3260e5 /src/java/com/healthmarketscience/jackcess/Table.java | |
parent | a0c5a05bded5f265079f444b9e113a0d40660d75 (diff) | |
download | jackcess-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.java | 26 |
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; |