|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.cometway.om.FileObjectStore
public class FileObjectStore
This class takes a File and partitions it into FileObjectBlocks. This class will keep track of free blocks and allocate new blocks if needed.
FileObjectBlock| Field Summary | |
|---|---|
protected long |
BLOCK_SIZE
|
protected java.lang.String |
headerInfo
|
protected long |
headerLength
|
| Constructor Summary | |
|---|---|
FileObjectStore(java.io.File storeFile)
Creates an instance of FileObjectStore using an empty description and the default block size. |
|
FileObjectStore(java.io.File storeFile,
java.lang.String fileInfo)
Creates an instance of FileObjectStore using the description parameter and the default block size. |
|
FileObjectStore(java.io.File storeFile,
java.lang.String fileInfo,
long blockSize)
Creates an instance of FileObjectStore using the description parameter and the given block size. |
|
| Method Summary | |
|---|---|
boolean |
allocateNewBlocks(int number)
This method allocates new blocks at the end of the store file. |
boolean |
changeFileInfo(java.lang.String newInfo)
This method changes the String info stored in the header of this Store to the String parameter. |
protected void |
debug(java.lang.String s)
|
void |
dispose()
This method removes this file from the filesystem and frees resources that it was using. |
boolean |
equals(java.lang.Object o)
Overrides Object.equals(Object). |
protected void |
error(java.lang.String s)
|
protected void |
error(java.lang.String s,
java.lang.Exception e)
|
FileObjectBlock |
getBlock(int index)
This method retrieves the previously allocated FileObjectBlock with the index given. |
java.lang.String |
getFileInfo()
This method reads the String info stored in the header of this Store and returns it. |
FileObjectBlock |
getNextFreeBlock()
This method returns the next Free Block. |
int |
hashCode()
Overrides Object.hashCode(). |
protected void |
initBlocks()
This method attempts to initialize all the blocks stored in the file. |
protected void |
print(java.lang.String s)
|
protected byte[] |
readBytes(long start,
long stop)
This method reads a byte array from the file at the positions given as the parameters. |
protected void |
readHeader()
This method reads the store file header information from the physical file. |
protected int |
readInt(long start)
This method reads an int at the position in the file given as the parameter. |
protected long |
readLong(long start)
This method reads a long at the position in the file given as the parameter. |
protected void |
writeBytes(byte[] data,
long start)
This method writes a byte array to the file starting at the position given by the parameter. |
protected void |
writeHeader()
This method writes the store file header information to the physical file. |
protected void |
writeInt(int data,
long start)
This method writes an int at the position in the file given as the parameter. |
protected void |
writeLong(long data,
long start)
This method writes a long at the position in the file given as the parameter. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected long BLOCK_SIZE
protected long headerLength
protected java.lang.String headerInfo
| Constructor Detail |
|---|
public FileObjectStore(java.io.File storeFile)
throws java.io.IOException
storeFile - This is the File which will be used for initialization and all reads and writes.
java.io.IOException - This is thrown if the FileObjectStore could not be created from the given parameters.
public FileObjectStore(java.io.File storeFile,
java.lang.String fileInfo)
throws java.io.IOException
storeFile - This is the File which will be used for initialization and all reads and writes.fileInfo - This will be stored in the header of this store file (NOT block headers) as a description for this file. If this is an empty String, the original fileInfo will attempt to be read in.
java.io.IOException - This is thrown if the FileObjectStore could not be created from the given parameters.
public FileObjectStore(java.io.File storeFile,
java.lang.String fileInfo,
long blockSize)
throws java.io.IOException
storeFile - This is the File which will be used for initialization and all reads and writes.fileInfo - This will be stored in the header of this store file (NOT block headers) as a description for this file. If this is an empty String, the original fileInfo will attempt to be read in.blockSize - This will be the size each FileObjectBlock allocated by this FileObjectStore.
java.io.IOException - This is thrown if the FileObjectStore could not be created from the given parameters.FileObjectBlock| Method Detail |
|---|
public java.lang.String getFileInfo()
public boolean changeFileInfo(java.lang.String newInfo)
public FileObjectBlock getBlock(int index)
throws java.lang.ArrayIndexOutOfBoundsException
index - This is the block index of the FileObjectBlock to retrieve.
java.lang.ArrayIndexOutOfBoundsException - This is thrown if the index given not used by this Store.public FileObjectBlock getNextFreeBlock()
public boolean allocateNewBlocks(int number)
number - The number of new blocks to allocate.
public void dispose()
protected void initBlocks()
throws java.io.IOException
java.io.IOException
protected void writeHeader()
throws java.io.IOException
java.io.IOException
protected void readHeader()
throws java.io.IOException
java.io.IOException
protected long readLong(long start)
throws java.io.IOException
java.io.IOException
protected void writeLong(long data,
long start)
throws java.io.IOException
java.io.IOException
protected int readInt(long start)
throws java.io.IOException
java.io.IOException
protected void writeInt(int data,
long start)
throws java.io.IOException
java.io.IOException
protected byte[] readBytes(long start,
long stop)
throws java.io.IOException
java.io.IOException
protected void writeBytes(byte[] data,
long start)
throws java.io.IOException
java.io.IOExceptionpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectprotected void print(java.lang.String s)
protected void error(java.lang.String s)
protected void error(java.lang.String s,
java.lang.Exception e)
protected void debug(java.lang.String s)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||