laur.dm.ar
Class DBWriter

java.lang.Object
  |
  +--laur.dm.ar.DBWriter

public class DBWriter
extends java.lang.Object

A DBWriter is used to write itemsets into a database.


Field Summary
static int CHAR_SIZE
           
static int COLUMN_LENGTH
           
static int COLUMN_NAME_OFFSET
           
static int COLUMN_SIZE
           
static int CRC_SIZE
           
static int DESCRIPTION_LENGTH
           
static int DESCRIPTION_SIZE
           
static int HEAD_SIZE_OFFSET
           
static int HEADER_SIZE
           
static java.lang.String ID
           
static int ID_SIZE
           
static int INT_SIZE
           
static int LONG_SIZE
           
static int MIN_DATA_OFFSET
           
static int NUMCOLUMNS_SIZE
           
static int NUMROWS_OFFSET
           
static int NUMROWS_SIZE
           
static int VERSION_SIZE
           
 
Constructor Summary
DBWriter(java.lang.String fileName)
          Create a new DBWriter according to the input file name.
 
Method Summary
 void addRow(Itemset itemset)
          Add a new row to the database.
 void close()
          Close the I/O stream and save any unsaved data.
static void main(java.lang.String[] args)
          sample usage and testing
 void setColumnNames(java.util.ArrayList names)
          Set the column names for the database.
 void setDescription(java.lang.String description)
          Set the description of the database.
static int updateCRC(int crc, int value)
          Update a CRC-16 value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHAR_SIZE

public static final int CHAR_SIZE

INT_SIZE

public static final int INT_SIZE

LONG_SIZE

public static final int LONG_SIZE

CRC_SIZE

public static final int CRC_SIZE

COLUMN_LENGTH

public static final int COLUMN_LENGTH

DESCRIPTION_LENGTH

public static final int DESCRIPTION_LENGTH

ID_SIZE

public static final int ID_SIZE

VERSION_SIZE

public static final int VERSION_SIZE

HEADER_SIZE

public static final int HEADER_SIZE

NUMROWS_SIZE

public static final int NUMROWS_SIZE

NUMCOLUMNS_SIZE

public static final int NUMCOLUMNS_SIZE

COLUMN_SIZE

public static final int COLUMN_SIZE

DESCRIPTION_SIZE

public static final int DESCRIPTION_SIZE

HEAD_SIZE_OFFSET

public static final int HEAD_SIZE_OFFSET

NUMROWS_OFFSET

public static final int NUMROWS_OFFSET

COLUMN_NAME_OFFSET

public static final int COLUMN_NAME_OFFSET

MIN_DATA_OFFSET

public static final int MIN_DATA_OFFSET

ID

public static final java.lang.String ID
Constructor Detail

DBWriter

public DBWriter(java.lang.String fileName)
         throws java.io.IOException
Create a new DBWriter according to the input file name.
Parameters:
fileName - the name of the file
Throws:
java.io.FileNotFoundException - from library call
java.io.IOException - from library call or if file is corrupted
Method Detail

setColumnNames

public void setColumnNames(java.util.ArrayList names)
                    throws java.io.IOException,
                           DBException
Set the column names for the database.
Parameters:
names - the column names
Throws:
java.io.IOException - from library call
DBException - size of names does not match number of columns

setDescription

public void setDescription(java.lang.String description)
                    throws java.io.IOException
Set the description of the database.
Parameters:
description - the description of the database
Throws:
java.io.IOException - from library call

addRow

public void addRow(Itemset itemset)
            throws java.io.IOException,
                   DBException
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.
Parameters:
itemset - the new row to be added to the data file
Throws:
java.io.IOException - from library call
DBException - column names have not been set or an invalid item was contained in the itemset

close

public void close()
           throws java.io.IOException
Close the I/O stream and save any unsaved data.
Throws:
java.io.IOException - from library call

updateCRC

public static int updateCRC(int crc,
                            int value)
Update a CRC-16 value.
Parameters:
crc - the previous CRC value
value - the value for which we update the CRC
Returns:
the updated CRC value

main

public static void main(java.lang.String[] args)
sample usage and testing