com.partnersoft.v3x.apps.Propagate
Class ChecksumDatafile

java.lang.Object
  extended by com.partnersoft.v3x.io.formats.ObjectDatafile
      extended by com.partnersoft.v3x.apps.Propagate.ChecksumDatafile

public class ChecksumDatafile
extends ObjectDatafile

An ObjectDatafile for storing SheetCoords. Ignores content - you'll have to deal with that all by yerself, and variable-length strings complicate things. More than likely you'll want one of these for each content anyway.


Field Summary
static int FILENAMEMAX
           
static byte[] fillerBuffer
           
static int HEADERSIZE
           
static int RECORDSIZE
           
 
Constructor Summary
ChecksumDatafile()
           
ChecksumDatafile(java.lang.String filename)
           
 
Method Summary
protected  int compareImp(java.io.RandomAccessFile filet, long seekA, long seekB)
          Subclasses may override this to compare two records directly.
protected  int compareImp(java.io.RandomAccessFile filet, java.lang.Object key)
          Subclasses may override this to compare the seeked-to record to a key.
 long readChecksum()
          Gets the checksum out of the header.
protected  java.lang.Object readHeaderImp(java.io.RandomAccessFile filet)
          Override this if you want something returned from read header.
protected  java.lang.Object readKeyImp(java.io.RandomAccessFile filet)
          Subclasses may override this to read the key for a record.
protected  void readRecordImp(java.lang.Object recycleMe, java.io.RandomAccessFile filet)
          Subclasses must override this to read an object from the fixed-length format, given an object to put the results into.
protected  java.lang.Object readRecordImp(java.io.RandomAccessFile filet)
          Subclasses must override this to read an object from the fixed-length format.
 void updateChecksum()
          This is special.
protected  void writeHeaderImp(java.lang.Object header, java.io.RandomAccessFile filet)
          Override this if you want it to do anything.
protected  void writeRecordImp(java.lang.Object source, java.io.RandomAccessFile filet)
          Subclasses must override this to write out the object in the desired form.
 
Methods inherited from class com.partnersoft.v3x.io.formats.ObjectDatafile
appendRecord, clear, close, compare, compare, findClosest, getFile, getHeaderSize, getRecordSize, getSize, openRead, openWrite, readHeader, readKey, readRecord, readRecord, search, setHeaderSize, setRecordSize, sort, writeHeader, writeRecord
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILENAMEMAX

public static final int FILENAMEMAX
See Also:
Constant Field Values

RECORDSIZE

public static final int RECORDSIZE
See Also:
Constant Field Values

HEADERSIZE

public static final int HEADERSIZE
See Also:
Constant Field Values

fillerBuffer

public static final byte[] fillerBuffer
Constructor Detail

ChecksumDatafile

public ChecksumDatafile()

ChecksumDatafile

public ChecksumDatafile(java.lang.String filename)
Method Detail

updateChecksum

public void updateChecksum()
                    throws java.io.IOException
This is special. Builds a checksum of the contents (not including header) of the datafile and sticks it in the header.

Throws:
java.io.IOException

readChecksum

public long readChecksum()
                  throws java.io.IOException
Gets the checksum out of the header.

Throws:
java.io.IOException

writeRecordImp

protected void writeRecordImp(java.lang.Object source,
                              java.io.RandomAccessFile filet)
                       throws java.io.IOException
Description copied from class: ObjectDatafile
Subclasses must override this to write out the object in the desired form. The RandomAccessFile is advanced to the correct spot; just write away.

Specified by:
writeRecordImp in class ObjectDatafile
Throws:
java.io.IOException

readRecordImp

protected java.lang.Object readRecordImp(java.io.RandomAccessFile filet)
                                  throws java.io.IOException
Description copied from class: ObjectDatafile
Subclasses must override this to read an object from the fixed-length format. The RandomAccessFile is advanced to the correct spot; just read away.

Specified by:
readRecordImp in class ObjectDatafile
Throws:
java.io.IOException

readRecordImp

protected void readRecordImp(java.lang.Object recycleMe,
                             java.io.RandomAccessFile filet)
                      throws java.io.IOException
Description copied from class: ObjectDatafile
Subclasses must override this to read an object from the fixed-length format, given an object to put the results into. Quite often, for speed, you don't want to create objects, but reuse them instead. This allows you to do that.

The RandomAccessFile is advanced to the correct spot; just read away.

Specified by:
readRecordImp in class ObjectDatafile
Throws:
java.io.IOException

compareImp

protected int compareImp(java.io.RandomAccessFile filet,
                         long seekA,
                         long seekB)
                  throws java.io.IOException
Description copied from class: ObjectDatafile
Subclasses may override this to compare two records directly. This must be overridden if you plan on using the sorting or searching features. Pretty standard: -1 means a is less than b; 0 means they are equal; 1 means b is less than a. The parameters include the seek positions for both A and B. Default returns 0.

Overrides:
compareImp in class ObjectDatafile
Throws:
java.io.IOException

compareImp

protected int compareImp(java.io.RandomAccessFile filet,
                         java.lang.Object key)
                  throws java.io.IOException
Description copied from class: ObjectDatafile
Subclasses may override this to compare the seeked-to record to a key. This must be overridden if you plan on using the sorting or searching features. Pretty standard: -1 means a is less than b; 0 means they are equal; 1 means b is less than a. Default is 0.

Overrides:
compareImp in class ObjectDatafile
Throws:
java.io.IOException

readKeyImp

protected java.lang.Object readKeyImp(java.io.RandomAccessFile filet)
                               throws java.io.IOException
Description copied from class: ObjectDatafile
Subclasses may override this to read the key for a record. Again, you can assume the file is at the correct location. Default is to simply read the whole record.

Overrides:
readKeyImp in class ObjectDatafile
Throws:
java.io.IOException

readHeaderImp

protected java.lang.Object readHeaderImp(java.io.RandomAccessFile filet)
                                  throws java.io.IOException
Description copied from class: ObjectDatafile
Override this if you want something returned from read header. File preset to byte 0 for your convenience.

Overrides:
readHeaderImp in class ObjectDatafile
Throws:
java.io.IOException

writeHeaderImp

protected void writeHeaderImp(java.lang.Object header,
                              java.io.RandomAccessFile filet)
                       throws java.io.IOException
Description copied from class: ObjectDatafile
Override this if you want it to do anything. Be sure to set your header size!

Overrides:
writeHeaderImp in class ObjectDatafile
Throws:
java.io.IOException