net.metanotion.io.block
Class FreeListBlock
java.lang.Object
net.metanotion.io.block.FreeListBlock
class FreeListBlock
- extends Object
On-disk format:
Magic number (long)
next freelist block page (unsigned int)
size (unsigned int)
that many free pages (unsigned ints)
Always fits on one page.
Free page format:
Magic number (long)
page
public final int page
FreeListBlock
public FreeListBlock(RandomAccessInterface file,
int startPage)
throws IOException
- Throws:
IOException
writeBlock
public void writeBlock()
throws IOException
- Throws:
IOException
getNextPage
public int getNextPage()
setNextPage
public void setNextPage(int nxt)
throws IOException
- Set and write the next page only
- Throws:
IOException
isEmpty
public boolean isEmpty()
isFull
public boolean isFull()
addPage
public void addPage(int freePage)
throws IOException
- Adds free page and writes new len to disk
- Throws:
IllegalStateException
- if full
IOException
takePage
public int takePage()
throws IOException
- Takes next page and writes new len to disk
- Throws:
IllegalStateException
- if empty
IOException
initPage
public static void initPage(RandomAccessInterface file,
int page)
throws IOException
- Throws:
IOException
toString
public String toString()
- Overrides:
toString
in class Object