org.cdlib.xtf.util
Interface StructuredStore

All Known Implementing Classes:
StructuredFile, StructuredFileProxy

public interface StructuredStore

A simple structured storage with a flat top-level directory. Substores can be added to an existing storage using createSubStore(String), and accessed later using openSubStore(String).

Author:
Martin Haye

Method Summary
 void close()
          Closes the store.
 SubStoreWriter createSubStore(String name)
          Create a new sub-store with the specified name.
 void delete()
          Deletes the storage completely (implies close() first)
 String getSystemId()
          Gets the path, URI, or other unique identifier for this store
 String getUserVersion()
          Gets the user version (if any) set by setUserVersion(String).
 SubStoreReader openSubStore(String name)
          Opens a pre-existing sub-store for read (or write).
 void setUserVersion(String ver)
          Sets a user-defined version number for the file.
 

Method Detail

createSubStore

SubStoreWriter createSubStore(String name)
                              throws IOException
Create a new sub-store with the specified name. Returns a SubStore that has most of the interface of a RandomAccessFile, except that seeks will be relative to the sub-store start. Only one substore may be created at a time (though many others may be opened, provided they were created before.) The caller must call SubStore.close() when the file is complete, to ensure that the directory gets written.

Parameters:
name - Name of the sub-file to create. Must not exist.
Returns:
A sub-store to write to.
Throws:
IOException

openSubStore

SubStoreReader openSubStore(String name)
                            throws IOException
Opens a pre-existing sub-store for read (or write). Returns a sub-store that has most of the interface of a RandomAccessFile, except that seeks will be relative to the sub-file start, and IO operations cannot exceed the boundaries of the sub-file. Many sub-stores may be open simultaneously; each one has an independent file pointer. Each one is light weight, so it's okay to have many open at a time.

Parameters:
name - Name of pre-existing sub-store to open.
Throws:
IOException

getSystemId

String getSystemId()
Gets the path, URI, or other unique identifier for this store


setUserVersion

void setUserVersion(String ver)
                    throws IOException
Sets a user-defined version number for the file. It can be retrieved later with getUserVersion().

Parameters:
ver - The version number to set.
Throws:
IOException

getUserVersion

String getUserVersion()
Gets the user version (if any) set by setUserVersion(String).


close

void close()
           throws IOException
Closes the store. This should always be called, to ensure that all sub-stores have been closed and that the directory has been written.

Throws:
IOException

delete

void delete()
            throws IOException
Deletes the storage completely (implies close() first)

Throws:
IOException