Package edu.pdx.cs410J.di
Class BookDatabase
java.lang.Object
edu.pdx.cs410J.di.JaxbDatabase
edu.pdx.cs410J.di.BookDatabase
- All Implemented Interfaces:
BookInventory
An implementation of
BookInventory
that stores a database of books in a flat file-
Constructor Summary
ConstructorDescriptionBookDatabase
(File directory) Creates a new database of books stored in a file named "books.xml"BookDatabase
(File directory, String fileName) Creates a new database of books. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds some books to the inventorygetBooks()
Returns all of the books in this inventoryint
Returns the number of copies of the given book in the inventoryvoid
Removes a book from the inventoryMethods inherited from class edu.pdx.cs410J.di.JaxbDatabase
getDatabaseFile, readFile, writeXml
-
Constructor Details
-
BookDatabase
@Inject public BookDatabase(@DataDirectory File directory) throws jakarta.xml.bind.JAXBException, IOException Creates a new database of books stored in a file named "books.xml"- Parameters:
directory
- The directory in which the data file will reside- Throws:
IOException
- If the data file cannot be createdjakarta.xml.bind.JAXBException
- If we cannot create the XML context
-
BookDatabase
BookDatabase(File directory, String fileName) throws IOException, jakarta.xml.bind.JAXBException Creates a new database of books. This method is package-protected for testing purposes.- Parameters:
directory
- The directory in which the data file will residefileName
- The name of the file to store the book inventory- Throws:
IOException
- If the data file cannot be createdjakarta.xml.bind.JAXBException
- If we cannot create the XML context
-
-
Method Details
-
remove
Description copied from interface:BookInventory
Removes a book from the inventory- Specified by:
remove
in interfaceBookInventory
- Parameters:
book
- The book to remove
-
add
Description copied from interface:BookInventory
Adds some books to the inventory- Specified by:
add
in interfaceBookInventory
- Parameters:
books
- A bunch of bookx
-
getCopies
Description copied from interface:BookInventory
Returns the number of copies of the given book in the inventory- Specified by:
getCopies
in interfaceBookInventory
- Parameters:
book
- The book of interest- Returns:
- the number of copies of
book
-
getBooks
Description copied from interface:BookInventory
Returns all of the books in this inventory- Specified by:
getBooks
in interfaceBookInventory
- Returns:
- all of the books in this inventory
-