org.xith3d.io
Class Archive

java.lang.Object
  extended by org.xith3d.io.Archive
All Implemented Interfaces:
java.util.Comparator<java.lang.String>

public class Archive
extends java.lang.Object
implements java.util.Comparator<java.lang.String>

An archive is a flexible and high performance storage system for Scribable objects. Objects can be stored and retrieved by name. The archive can grow as needed. Objects can be deleted and/or replaced. You can also get an iterator to step through the objects sequentially. Each object can be stored compressed or uncompressed. The file is organized as follows: The first entry in the file is a directory block. Each directory block is 20,000 bytes. We cram as many DirEntry as possible into each 20k chunk. Assuming around an average of 30 bytes per entry this is about 600 entries per block. Each free block contains two longs, one is the length of the block and the other is a link to the next free block.


Constructor Summary
Archive(java.lang.String filename, boolean readonly)
          Creates an Archive object.
 
Method Summary
 void close()
          Writes the directory, free list and closes the file.
 int compare(java.lang.String a, java.lang.String b)
          Compares two keys together
 boolean exists(java.lang.String name)
           
 Scribable read(java.lang.String name)
          Writes out the object to the repository.
 void remove(java.lang.String name)
          Removes an entry from the repository
 void write(java.lang.String name, Scribable object, boolean compress)
          Writes out the object to the repository.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

Archive

public Archive(java.lang.String filename,
               boolean readonly)
        throws java.io.IOException
Creates an Archive object.

Parameters:
filename - The name of the file
readonly - True if the file should not be written to
Throws:
java.io.IOException
Method Detail

exists

public boolean exists(java.lang.String name)

close

public void close()
           throws java.io.IOException
Writes the directory, free list and closes the file.

Throws:
java.io.IOException

compare

public int compare(java.lang.String a,
                   java.lang.String b)
Compares two keys together

Specified by:
compare in interface java.util.Comparator<java.lang.String>

write

public void write(java.lang.String name,
                  Scribable object,
                  boolean compress)
           throws java.io.IOException,
                  UnscribableNodeEncountered
Writes out the object to the repository.

Parameters:
object -
Throws:
java.io.IOException
UnscribableNodeEncountered

read

public Scribable read(java.lang.String name)
               throws java.io.IOException,
                      InvalidFormat
Writes out the object to the repository.

Parameters:
name -
Throws:
java.io.IOException
InvalidFormat

remove

public void remove(java.lang.String name)
Removes an entry from the repository

Parameters:
name -