com.partnersoft.io.formats.dump
Class NamedObjectDump

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

public class NamedObjectDump
extends java.lang.Object

This is similar to the ObjectDump, except that it is indexed by a string name rather than an integer ID. Essentially, it is WORM - you can dump an object to it, in which case the object is appended, in serialized form, with its name to the data file, and an entry added to the offset file. You can then ask for that object by index number. Not threadsafe. Write a wrapper if you need thread safety.

Compressed by default; optional constructor for uncompressed mode.


Constructor Summary
NamedObjectDump(java.lang.String filename)
          Creates a NamedObjectDump file for the given filename base (everything but the extensions).
 
Method Summary
 void appendObject(java.lang.String name, java.lang.Object victim)
           
 void clear()
           
 java.io.File getDataFile()
           
 java.io.File getOffsetFile()
           
 int getSize()
           
 void pack()
           
 java.lang.String readName(int index)
           
 java.lang.Object readObject(int index)
           
 java.lang.Object readObject(java.lang.String name)
          If cached == true, this is a cached version of readObjectUncached.
 java.lang.Object readObjectImp(java.io.DataInputStream dater)
           
 java.lang.Object readObjectUncached(java.lang.String name)
          This requires that the file be sorted.
 void sort()
           
 void sortInMemory()
           
 void sortOnDisk()
           
 void swap(int a, int b)
           
 void writeObjectImp(java.lang.Object victim, java.io.DataOutputStream outie)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamedObjectDump

public NamedObjectDump(java.lang.String filename)
Creates a NamedObjectDump file for the given filename base (everything but the extensions).

Method Detail

getSize

public int getSize()

getDataFile

public java.io.File getDataFile()

getOffsetFile

public java.io.File getOffsetFile()

appendObject

public void appendObject(java.lang.String name,
                         java.lang.Object victim)
                  throws java.io.IOException
Throws:
java.io.IOException

writeObjectImp

public void writeObjectImp(java.lang.Object victim,
                           java.io.DataOutputStream outie)
                    throws java.io.IOException
Throws:
java.io.IOException

readObject

public java.lang.Object readObject(java.lang.String name)
                            throws java.io.IOException
If cached == true, this is a cached version of readObjectUncached. Otherwise it just runs straight through.

Throws:
java.io.IOException

readObjectUncached

public java.lang.Object readObjectUncached(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

readObjectImp

public java.lang.Object readObjectImp(java.io.DataInputStream dater)
                               throws java.io.IOException
Throws:
java.io.IOException

readName

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

clear

public void clear()
           throws java.io.IOException
Throws:
java.io.IOException

swap

public void swap(int a,
                 int b)
          throws java.io.IOException
Throws:
java.io.IOException

sort

public void sort()

pack

public void pack()
          throws java.io.IOException
Throws:
java.io.IOException

sortOnDisk

public void sortOnDisk()

sortInMemory

public void sortInMemory()