/** * Add a new row to the database. If this is to be the first row added to the database you must * have called setColumnNames() before. * * @param itemset the new row to be added to the data file * @exception IOException from library call * @exception DBException column names have not been set or an invalid item was contained in the * itemset */ public void addRow(Itemset itemset) throws IOException, DBException { if (wroteColumnNames == false) throw new DBException("Column names must be set first"); int size = itemset.size(); for (int i = 0; i < size; i++) if (itemset.get(i) > numColumns) throw new DBException("Attempt to write invalid item"); if (needReposition == true) { outStream.seek(lastPosition); needReposition = false; } outStream.writeInt(size); CRC = updateCRC(CRC, size); int item; for (int i = 0; i < size; i++) { item = itemset.get(i); outStream.writeInt(item); CRC = updateCRC(CRC, item); } numRows++; }