|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.partnersoft.io.formats.old.ObjectDatafile
public abstract class ObjectDatafile
| Constructor Summary | |
|---|---|
ObjectDatafile()
|
|
ObjectDatafile(java.lang.String filename)
|
|
| Method Summary | |
|---|---|
void |
appendRecord(java.lang.Object record)
Appends a record to the end of the file. |
void |
clear()
|
void |
close()
|
int |
compare(int a,
int b)
Compares the two indexed records. |
int |
compare(int index,
java.lang.Object key)
Compares the record to the given key. |
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. |
int |
findClosest(java.lang.Object key)
Returns the index of the "closest" record matching the given key (this would be the insertion point if you were to insert the given key) Uses binary search, so the file has to be sorted first. |
protected java.io.RandomAccessFile |
getFile()
If you just have to bang on the file, use this. |
protected int |
getHeaderSize()
Get your header size, in case you've forgotten already. |
protected int |
getRecordSize()
Get your record size, in case you've forgotten already. |
int |
getSize()
Returns size of data file, in records. |
void |
openRead()
|
void |
openWrite()
|
java.lang.Object |
readHeader()
Get object from header. |
protected java.lang.Object |
readHeaderImp(java.io.RandomAccessFile filet)
Override this if you want something returned from read header. |
java.lang.Object |
readKey(int index)
Reads a key from the given slot. |
protected java.lang.Object |
readKeyImp(java.io.RandomAccessFile filet)
Subclasses may override this to read the key for a record. |
java.lang.Object |
readRecord(int index)
Reads a record from the given slot. |
void |
readRecord(int index,
java.lang.Object recyclable)
This might be faster - recycle your own object rather than having me create a new one for you. |
protected abstract 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 abstract java.lang.Object |
readRecordImp(java.io.RandomAccessFile filet)
Subclasses must override this to read an object from the fixed-length format. |
int |
search(java.lang.Object key)
Returns the index of the record matching the given key; -1 if it can't find one. |
protected void |
setHeaderSize(int newSize)
Use this to set your header size. |
protected void |
setRecordSize(int newSize)
Use this to set your record size in bytes. |
void |
sort()
Sorts the file using quicksort. |
void |
writeHeader(java.lang.Object newHeader)
Write object to header. |
protected void |
writeHeaderImp(java.lang.Object header,
java.io.RandomAccessFile filet)
Override this if you want it to do anything. |
void |
writeRecord(int index,
java.lang.Object rec)
Writes a record into the given slot. |
protected abstract 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 java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ObjectDatafile()
public ObjectDatafile(java.lang.String filename)
| Method Detail |
|---|
protected abstract void writeRecordImp(java.lang.Object source,
java.io.RandomAccessFile filet)
throws java.io.IOException
java.io.IOException
protected abstract java.lang.Object readRecordImp(java.io.RandomAccessFile filet)
throws java.io.IOException
java.io.IOException
protected abstract void readRecordImp(java.lang.Object recycleMe,
java.io.RandomAccessFile filet)
throws java.io.IOException
The RandomAccessFile is advanced to the correct spot; just read away.
java.io.IOException
protected java.lang.Object readKeyImp(java.io.RandomAccessFile filet)
throws java.io.IOException
java.io.IOException
protected int compareImp(java.io.RandomAccessFile filet,
long seekA,
long seekB)
throws java.io.IOException
java.io.IOException
protected int compareImp(java.io.RandomAccessFile filet,
java.lang.Object key)
throws java.io.IOException
java.io.IOExceptionprotected void setRecordSize(int newSize)
protected int getRecordSize()
protected void setHeaderSize(int newSize)
protected int getHeaderSize()
protected java.lang.Object readHeaderImp(java.io.RandomAccessFile filet)
throws java.io.IOException
java.io.IOException
protected void writeHeaderImp(java.lang.Object header,
java.io.RandomAccessFile filet)
throws java.io.IOException
java.io.IOExceptionprotected java.io.RandomAccessFile getFile()
public void clear()
throws java.io.IOException
java.io.IOException
public void openRead()
throws java.io.IOException
java.io.IOException
public void openWrite()
throws java.io.IOException
java.io.IOException
public void close()
throws java.io.IOException
java.io.IOException
public void appendRecord(java.lang.Object record)
throws java.io.IOException
java.io.IOException
public void writeRecord(int index,
java.lang.Object rec)
throws java.io.IOException
java.io.IOException
public java.lang.Object readRecord(int index)
throws java.io.IOException
java.io.IOException
public java.lang.Object readKey(int index)
throws java.io.IOException
java.io.IOException
public void readRecord(int index,
java.lang.Object recyclable)
throws java.io.IOException
java.io.IOException
public int getSize()
throws java.io.IOException
java.io.IOException
public int compare(int a,
int b)
throws java.io.IOException
java.io.IOException
public int compare(int index,
java.lang.Object key)
throws java.io.IOException
java.io.IOException
public void sort()
throws java.io.IOException
java.io.IOException
public int search(java.lang.Object key)
throws java.io.IOException
java.io.IOExceptionpublic int findClosest(java.lang.Object key)
public java.lang.Object readHeader()
throws java.io.IOException
java.io.IOException
public void writeHeader(java.lang.Object newHeader)
throws java.io.IOException
java.io.IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||