com.partnersoft.io.formats.dump
Class PackedNamedRandomAccessObjectDump

java.lang.Object
  extended by com.partnersoft.io.formats.dump.PackedNamedRandomAccessObjectDump

public abstract class PackedNamedRandomAccessObjectDump
extends java.lang.Object

This is a packed (single file) version of a NamedObjectDump, that uses a RandomAccessFile for i/o. Read-only; you must first create and sort a NamedObjectDump then run the pack() method on it. Not threadsafe. Write a wrapper if you need thread safety.

Compressed by default; optional constructor for uncompressed mode.


Constructor Summary
PackedNamedRandomAccessObjectDump(java.io.File filet)
          Creates a PackedNamedRandomAccessObjectDump file for the given filename.
 
Method Summary
 void close()
           
 void finalize()
           
 int findClosest(java.lang.String 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.
 java.io.File getFile()
           
 int getSize()
           
 int indexOf(java.lang.String name)
           
 java.lang.String readName(int index)
           
 java.lang.Object readObject(int index)
           
 java.lang.Object readObject(java.lang.String name)
          This requires that the file be sorted.
protected abstract  java.lang.Object readObjectImp(java.lang.String name, java.io.RandomAccessFile filet)
          Override this to provide custom reading of your data.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PackedNamedRandomAccessObjectDump

public PackedNamedRandomAccessObjectDump(java.io.File filet)
                                  throws java.io.IOException
Creates a PackedNamedRandomAccessObjectDump file for the given filename.

Throws:
java.io.IOException
Method Detail

close

public void close()

finalize

public void finalize()
Overrides:
finalize in class java.lang.Object

getSize

public int getSize()

indexOf

public int indexOf(java.lang.String name)

readObject

public java.lang.Object readObject(java.lang.String name)
                            throws java.io.IOException
This requires that the file be sorted. Returns null on fail.

Throws:
java.io.IOException

readObject

public java.lang.Object readObject(int index)
                            throws java.io.IOException
Throws:
java.io.IOException

readName

public java.lang.String readName(int index)
                          throws java.io.IOException
Throws:
java.io.IOException

findClosest

public int findClosest(java.lang.String 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.


getFile

public java.io.File getFile()

readObjectImp

protected abstract java.lang.Object readObjectImp(java.lang.String name,
                                                  java.io.RandomAccessFile filet)
                                           throws java.io.IOException
Override this to provide custom reading of your data. The file is open to the correct position.

Throws:
java.io.IOException