|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.cometway.om.FileObjectBlock
public class FileObjectBlock
This class is used to store Objects into a file prepared by FileObjectStore. The store returns a reference to a block in the file. Objects can be written and read from this block. A FileObjectBlock can be given a header description (an Object) as well as the Object stored in the body of the block. If the Object stored in the body of the block exceeds the length of the block, a new block will be allocated and the remaining bytes stored there. If the next block is used up, it will automatically allocate a new one from the store, and so on. When these extra blocks in chain of blocks are no longer needed, they are automatically disposed of.
FileObjectStore| Field Summary | |
|---|---|
protected static int |
BODY_DATA_OFFSET
|
protected static int |
BODY_EXTENDED_DATA_OFFSET
|
protected static int |
BODY_TAG_OFFSET
|
boolean |
conservativeWithErrors
When this flag is set to FALSE this FileObjectBlock will be slightly more inventive when encountering unexpected errors rather than just give up. |
protected static int |
HEADER_DATA_OFFSET
|
protected static int |
HEADER_NEXT_INDEX_OFFSET
|
protected static int |
HEADER_PARENT_INDEX_OFFSET
|
protected static int |
HEADER_TAG_OFFSET
|
protected int |
headerLength
|
protected boolean |
isEmpty
|
protected FileObjectBlock |
nextBlock
|
protected int |
parentBlockIndex
|
| Constructor Summary | |
|---|---|
protected |
FileObjectBlock(FileObjectStore store,
int index)
Creates an instance of FileObjectBlock. |
| Method Summary | |
|---|---|
protected void |
debug(java.lang.String s)
|
void |
dispose()
This method is called when the Block is no longer needed and should be considered a FREE BLOCK, to be reused. |
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)
|
protected void |
finalize()
Overrides Object.finalize(). |
protected void |
format()
This method writes the physical space of the store file so that Objects can be written and read from this Block. |
protected long |
getOffset()
This returns the dynamic offset of the beginning of this block in the store file |
int |
hashCode()
Overrides Object.hashCode(). |
boolean |
isFreeBlock()
This method reads the dirty flag in the store file for this Block and returns true if it reports itself to be FREE. |
protected void |
print(java.lang.String s)
|
java.lang.Object |
readHeader()
This method returns the Object stored in the header of this block. |
java.lang.Object |
readObject()
This method reads the Object stored in the body of this Block. |
void |
updateFromFile()
This method updates all the local instance fields from information stored in the file. |
boolean |
writeHeader(java.lang.Object data)
This method writes an Object in the header of this Block. |
boolean |
writeObject(java.lang.Object data)
This method stores an Object in the body of this Block. |
| Methods inherited from class java.lang.Object |
|---|
clone, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final int HEADER_TAG_OFFSET
protected static final int HEADER_PARENT_INDEX_OFFSET
protected static final int HEADER_NEXT_INDEX_OFFSET
protected static final int HEADER_DATA_OFFSET
protected static final int BODY_TAG_OFFSET
protected static final int BODY_DATA_OFFSET
protected static final int BODY_EXTENDED_DATA_OFFSET
protected int headerLength
protected boolean isEmpty
protected FileObjectBlock nextBlock
protected int parentBlockIndex
public boolean conservativeWithErrors
| Constructor Detail |
|---|
protected FileObjectBlock(FileObjectStore store,
int index)
store - THis is the FileObjectStore which this block will read and write to.index - This is the index into the store file which this block will read and write to.| Method Detail |
|---|
public void updateFromFile()
public java.lang.Object readHeader()
public boolean writeHeader(java.lang.Object data)
data - This Object will be stored in the header of this Block
public java.lang.Object readObject()
public boolean writeObject(java.lang.Object data)
data - The Object to write in the body of this Block.
public void dispose()
protected void format()
throws java.io.IOException
java.io.IOException - Throws the IOException caused when writing to the store file.public boolean isFreeBlock()
protected long getOffset()
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwablepublic 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 | ||||||||