SHORT_DATE_TIME((byte) 0x08, Types.TIMESTAMP, 8),
BINARY((byte) 0x09, Types.BINARY, 255, true),
TEXT((byte) 0x0A, Types.VARCHAR, 50 * 2, true),
- OLE((byte) 0x0B, Types.LONGVARBINARY, 12),
- MEMO((byte) 0x0C, Types.LONGVARCHAR, 12),
+ OLE((byte) 0x0B, Types.LONGVARBINARY, 12, true),
+ MEMO((byte) 0x0C, Types.LONGVARCHAR, 12, true),
UNKNOWN_0D((byte) 0x0D),
GUID((byte) 0x0F, null, 16),
NUMERIC((byte) 0x10, Types.NUMERIC, 17);
* is much more efficient than calling <code>addRow</code> multiple times.
* @param rows List of Object[] row values
*/
- public void addRows(List rows) throws IOException {
+ public void addRows(List<? extends Object[]> rows) throws IOException {
ByteBuffer dataPage = _pageChannel.createPageBuffer();
ByteBuffer[] rowData = new ByteBuffer[rows.size()];
- Iterator iter = rows.iterator();
+ Iterator<? extends Object[]> iter = rows.iterator();
for (int i = 0; iter.hasNext(); i++) {
rowData[i] = createRow((Object[]) iter.next());
}
- List pageNumbers = _ownedPages.getPageNumbers();
+ List<Integer> pageNumbers = _ownedPages.getPageNumbers();
int pageNumber;
int rowSize;
if (pageNumbers.size() == 0) {
rowCount * _format.SIZE_ROW_LOCATION, rowLocation);
dataPage.position(rowLocation);
dataPage.put(rowData[i]);
- iter = _indexes.iterator();
- while (iter.hasNext()) {
- Index index = (Index) iter.next();
+ Iterator<Index> indIter = _indexes.iterator();
+ while (indIter.hasNext()) {
+ Index index = (Index) indIter.next();
index.addRow((Object[]) rows.get(i), pageNumber, (byte) rowCount);
}
}
ByteBuffer tdefPage = _pageChannel.createPageBuffer();
_pageChannel.readPage(tdefPage, _tableDefPageNumber);
tdefPage.putInt(_format.OFFSET_NUM_ROWS, ++_rowCount);
- iter = _indexes.iterator();
+ Iterator<Index> indIter = _indexes.iterator();
for (int i = 0; i < _indexes.size(); i++) {
tdefPage.putInt(_format.OFFSET_INDEX_DEF_BLOCK +
i * _format.SIZE_INDEX_DEFINITION + 4, _rowCount);
- Index index = (Index) iter.next();
+ Index index = (Index) indIter.next();
index.update();
}
_pageChannel.writePage(tdefPage, _tableDefPageNumber);
assertEquals(1, db.getTableNames().size());
Table table = db.getTable("Table1");
- Map row = table.getNextRow();
+ Map<String, Object> row = table.getNextRow();
assertEquals("abcdefg", row.get("A"));
assertEquals("hijklmnop", row.get("B"));
assertEquals(new Byte((byte) 2), row.get("C"));
table.addRow(row);
}
for (int i = 0; i < count; i++) {
- Map readRow = table.getNextRow();
+ Map<String, Object> readRow = table.getNextRow();
assertEquals(row[0], readRow.get("A"));
assertEquals(row[1], readRow.get("B"));
assertEquals(row[2], readRow.get("C"));
Table table = db.getTable("Test");
table.addRows(rows);
for (int i = 0; i < count; i++) {
- Map readRow = table.getNextRow();
+ Map<String, Object> readRow = table.getNextRow();
assertEquals(row[0], readRow.get("A"));
assertEquals(row[1], readRow.get("B"));
assertEquals(row[2], readRow.get("C"));
public void testReadMemo() throws Exception {
Database db = Database.open(new File("test/data/test2.mdb"));
- String tableName = "MSP_PROJECTS";
- Table table = db.getTable(tableName);
+ Table table = db.getTable("MSP_PROJECTS");
Map<String, Object> row = table.getNextRow();
assertEquals("Jon Iles this is a a vawesrasoih aksdkl fas dlkjflkasjd flkjaslkdjflkajlksj dfl lkasjdf lkjaskldfj lkas dlk lkjsjdfkl; aslkdf lkasjkldjf lka skldf lka sdkjfl;kasjd falksjdfljaslkdjf laskjdfk jalskjd flkj aslkdjflkjkjasljdflkjas jf;lkasjd fjkas dasdf asd fasdf asdf asdmhf lksaiyudfoi jasodfj902384jsdf9 aw90se fisajldkfj lkasj dlkfslkd jflksjadf as", row.get("PROJ_PROP_AUTHOR"));
assertEquals("T", row.get("PROJ_PROP_COMPANY"));
assertEquals("Project1", row.get("PROJ_PROP_TITLE"));
}
+ public void testWriteMemo() throws Exception {
+
+ Database db = create();
+
+ List<Column> columns = new ArrayList<Column>();
+ Column col = new Column();
+ col.setName("A");
+ col.setType(DataType.TEXT);
+ columns.add(col);
+ col = new Column();
+ col.setName("B");
+ col.setType(DataType.MEMO);
+ columns.add(col);
+ db.createTable("test", columns);
+
+ String testStr = "This is a test";
+
+ Table table = db.getTable("Test");
+ table.addRow(new Object[]{testStr, testStr});
+
+ Map<String, Object> row = table.getNextRow();
+
+ assertEquals(testStr, row.get("A"));
+ assertEquals(testStr, row.get("B"));
+
+ }
+
public void testMissingFile() throws Exception {
File bogusFile = new File("fooby-dooby.mdb");
assertTrue(!bogusFile.exists());