|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectDBFile
public class DBFile
Low level database file. This abstraction allows the user to treat a database as a collection of pages.
| Nested Class Summary | |
|---|---|
static class |
DBFile.BadPageNumberException
|
static class |
DBFile.EmptyFileException
|
static class |
DBFile.FileFullException
|
static class |
DBFile.NonPositiveRunSizeException
|
static class |
DBFile.PageNotAllocatedException
|
| Constructor Summary | |
|---|---|
DBFile(java.lang.String name)
Opens the database with the given name. |
|
DBFile(java.lang.String name,
int numPages)
Creates a database with the specified number of pages. |
|
| Method Summary | |
|---|---|
int |
allocatePages(int runSize)
Allocates a set of pages. |
void |
deallocatePages(int startPageNum,
int runSize)
Deallocates a set of pages. |
static boolean |
erase(java.lang.String name)
Erases the database entirely from the filesystem. |
static void |
main(java.lang.String[] args)
|
void |
readPage(int pageNum,
Page page)
Reads the contents of the specified page from disk into the page object provided. |
void |
writePage(int pageNum,
Page page)
Writes the contents of the specified page to disk. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DBFile(java.lang.String name,
int numPages)
throws java.io.IOException
name - name to be given to database.numPages - maximum number of pages in database.
java.io.IOException - passed through from underlying filesystem.
public DBFile(java.lang.String name)
throws java.io.IOException
name - name of the database.
java.io.IOException - passed through from underlying file system.| Method Detail |
|---|
public static boolean erase(java.lang.String name)
name - name of the database.
public int allocatePages(int runSize)
throws java.io.IOException
runSize - number of pages to be allocated in the run.
DBFile.NonPositiveRunSizeException - if the run size is less
than or equal to zero.
DBFile.FileFullException - if there are not enough free pages.
java.io.IOException - passed through from underlying file system.
public void deallocatePages(int startPageNum,
int runSize)
throws java.io.IOException
startPageNum - page number at the beginning of the run to
be deallocated.runSize - number of pages to deallocate.
DBFile.NonPositiveRunSizeException - if the run size is less
than or equal to zero.
DBFile.BadPageNumberException - if startPageNum is illegal.
java.io.IOException - passed through from underlying file system.
public void readPage(int pageNum,
Page page)
throws java.io.IOException
pageNum - the page number to be read.page - a reference to an already allocated Page object.
DBFile.BadPageNumberException - if pageNum is not in the file.
java.io.IOException - passed through from underlying file system.
DBFile.PageNotAllocatedException - if pageNum is not allocaated.
public void writePage(int pageNum,
Page page)
throws java.io.IOException
pageNum - the page number to be written.page - a Page object with data to be written.
EmptyFileException() - if the file has no pages within it.
DBFile.BadPageNumberException - if pageNum is not in the file.
java.io.IOException - passed through from underlying file system.
DBFile.PageNotAllocatedException - if pageNum is not allocaated.
public static void main(java.lang.String[] args)
throws java.io.IOException
java.io.IOException
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||