public class Book
extends java.lang.Object
This book implementation skeleton reads the book headers from a file stored on disk after verifying that the book format is correct. Therefore, after initialising the book using the default constructor the database offset is positioned just after the last header read
The database header must have the following format:
signature version\n field_name_1: field_value_1\n field_name_2: field_value_2\n ... field_name_N: field_value_N\n \n
Constructor and Description |
---|
Book(java.io.File file,
java.lang.String signature)
Initializes a new
Book object wich will read entries from
a file stored on disk. |
Modifier and Type | Method and Description |
---|---|
java.util.Iterator<java.lang.String> |
fields()
Returns an iterator over the field names found in the book's
header information.
|
protected void |
finalize()
Destructor for this
Book instance. |
java.io.RandomAccessFile |
getDatabase()
Returns the random access file object associated with this book.
|
java.lang.String |
getField(java.lang.String name)
Returns the value of the specified header field.
|
java.lang.String |
getVersion()
Returns the value for the database book format version.
|
public Book(java.io.File file, java.lang.String signature) throws java.io.IOException
Book
object wich will read entries from
a file stored on disk.file
- The database file for the booksignature
- Signature that identifies the book formatFileNotFoundException
- If the file could not be openedjava.io.IOException
- If an I/O exception occurredpublic java.lang.String getVersion()
null
public java.io.RandomAccessFile getDatabase()
public java.lang.String getField(java.lang.String name)
name
- Field namenull
if the field doesn't existpublic java.util.Iterator<java.lang.String> fields()
protected void finalize() throws java.lang.Throwable
Book
instance.finalize
in class java.lang.Object
java.lang.Throwable