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
ConstructorsConstructorDescriptionBookDatabase(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 TypeMethodDescriptionvoidAdds some books to the inventorygetBooks()Returns all of the books in this inventoryintReturns the number of copies of the given book in the inventoryvoidRemoves 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:BookInventoryRemoves a book from the inventory- Specified by:
removein interfaceBookInventory- Parameters:
book- The book to remove
-
add
Description copied from interface:BookInventoryAdds some books to the inventory- Specified by:
addin interfaceBookInventory- Parameters:
books- A bunch of bookx
-
getCopies
Description copied from interface:BookInventoryReturns the number of copies of the given book in the inventory- Specified by:
getCopiesin interfaceBookInventory- Parameters:
book- The book of interest- Returns:
- the number of copies of
book
-
getBooks
Description copied from interface:BookInventoryReturns all of the books in this inventory- Specified by:
getBooksin interfaceBookInventory- Returns:
- all of the books in this inventory
-