All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class org.dorm4.fls.Library

java.lang.Object
   |
   +----java.rmi.server.RemoteObject
           |
           +----java.rmi.server.RemoteServer
                   |
                   +----java.rmi.server.UnicastRemoteObject
                           |
                           +----org.dorm4.fls.Library

public class Library
extends UnicastRemoteObject
implements IRemoteLibrary, ILibraryConstants
Library class interfaces to a JDBC database and provides a set of objects to represent items and borrowers.


Constructor Index

 o Library(OutputStream, Connection, IKey, Registry)

Method Index

 o add(StdLibraryObject)
Adds the object to the database
 o addListener(ILibraryListener)
Adds a listener to the Library.
 o createLibraryObject(String)
Creates a new library object for this id, but doesn't make a database record
 o find(StdLibraryObject, Vector)
Does a lookup in all fields for the specified text and returns the hits as a Vector of the itemType.
 o find(StdLibraryObject, Vector, Vector, Vector)
Does a lookup in the specified fields for the specified text and returns the hits as a Vector of the itemType.
 o findID(Vector, Vector)
Does a lookup in all fields for the specified text and returns the hits as a Vector of ids.
 o findID(Vector, Vector, Vector, Vector)
Does a lookup in the specified fields for the specified text and returns the hits as a Vector of ids.
 o getAltName()
Gives the alternate name of this library
 o getBorrower(Item)
Checks if the item is on loan and if so returns the Borrower, otherwise null.
 o getDueDate(Item)
Checks if the item is on loan and if so returns the due date, otherwise null.
 o getLibraryObject(String)
Gets a StdLibraryObject in the database.
 o getLoanPeriod(Item)
Gets the default loan period for this item.
 o getLoans(Borrower)
Gets the Items this Borrower has on loan.
 o getName()
Gives the name of this library
 o getRegisteredTypes()
Gets an array of classes for all registered types
 o goOffline()
When called, the Library will unregister itself with the RMI registry and notify all listeners.
 o goOnline()
When called, the Library will register itself with the RMI registry and notify all listeners.
 o loanTo(Item, Borrower, Date)
Adds a record to the loans table in the database.
 o receive(Item)
Checks if the book is overdue then removes the loan record from the database.
 o remove(StdLibraryObject)
Removes the object from the database
 o removeListener(ILibraryListener)
Removes a listener from the Library.
 o renumber(StdLibraryObject, String)
Gives the object a new number in the database
 o setConnection(Connection)
Sets the database connection.
 o update(StdLibraryObject)
Updates the object in the database
 o validate(StdLibraryObject)
Verifies that the object is in the database and sets its properties to the values in the database.

Constructors

 o Library
 public Library(OutputStream out,
                Connection con,
                IKey idKey,
                Registry registry) throws RemoteException
Parameters:
out - The OutputStream that log messages are sent to.
con - The connection to the database.
idKey - The key to be used to verify the ids.
registry - The registry where this library can lookup other libraries

Methods

 o addListener
 public void addListener(ILibraryListener listener)
Adds a listener to the Library.

 o removeListener
 public void removeListener(ILibraryListener listener)
Removes a listener from the Library.

 o goOnline
 public void goOnline()
When called, the Library will register itself with the RMI registry and notify all listeners.

 o goOffline
 public void goOffline()
When called, the Library will unregister itself with the RMI registry and notify all listeners.

 o setConnection
 public void setConnection(Connection con)
Sets the database connection.

 o getName
 public String getName()
Gives the name of this library

 o getAltName
 public String getAltName()
Gives the alternate name of this library

 o getRegisteredTypes
 public Class[] getRegisteredTypes() throws RemoteException
Gets an array of classes for all registered types

 o findID
 public Vector findID(Vector tables,
                      Vector includeStrings) throws IllegalArgumentException, RemoteException
Does a lookup in all fields for the specified text and returns the hits as a Vector of ids.

Parameters:
tables - Names of tables to search.
includeStrings - Strings that must be included in the results.
Returns:
A Vector of ids as String objects.
 o findID
 public Vector findID(Vector tables,
                      Vector includeStrings,
                      Vector excludeStrings,
                      Vector searchFields) throws IllegalArgumentException, RemoteException
Does a lookup in the specified fields for the specified text and returns the hits as a Vector of ids.

Parameters:
tables - StdLibraryObjects.
includeStrings - Strings that must be included in the results.
excludeStrings - Strings that must not be included in the results.
searchFields - Fields to be searched.
Returns:
A Vector of ids as String objects.
 o find
 public Vector find(StdLibraryObject itemType,
                    Vector includeStrings) throws IllegalArgumentException, RemoteException
Does a lookup in all fields for the specified text and returns the hits as a Vector of the itemType.

Parameters:
itemType - Child of StdLibraryObject.
includeStrings - Strings that must be included in the results.
Returns:
A Vector of ids as String objects.
 o find
 public Vector find(StdLibraryObject itemType,
                    Vector includeStrings,
                    Vector excludeStrings,
                    Vector searchFields) throws IllegalArgumentException, RemoteException
Does a lookup in the specified fields for the specified text and returns the hits as a Vector of the itemType.

Parameters:
itemType - Child of StdLibraryObject.
includeStrings - Strings that must be included in the results.
excludeStrings - Strings that must not be included in the results.
searchFields - Fields to be searched.
Returns:
A Vector of ids as String objects.
 o getLibraryObject
 public StdLibraryObject getLibraryObject(String id) throws RemoteException
Gets a StdLibraryObject in the database. Returns null if it can't be found.

 o createLibraryObject
 public StdLibraryObject createLibraryObject(String id) throws CannotAllowException, RemoteException
Creates a new library object for this id, but doesn't make a database record

Throws: CannotAllowException
Thrown if access is denied.
 o add
 public void add(StdLibraryObject obj) throws CannotAllowException, RemoteException
Adds the object to the database

Parameters:
obj - The object to be added
Returns:
Returns true if the method succeeded, false otherwise.
Throws: CannotAllowException
Thrown if access is denied.
 o remove
 public void remove(StdLibraryObject obj) throws CannotAllowException, RecordNotFoundException, RemoteException
Removes the object from the database

Parameters:
obj - The object to be removed
Returns:
Returns true if the method succeeded, false otherwise.
Throws: CannotAllowException
Thrown if access is denied.
Throws: RecordNotFoundException
Thrown if the object isn't in the database.
 o update
 public void update(StdLibraryObject obj) throws CannotAllowException, RecordNotFoundException, RemoteException
Updates the object in the database

Parameters:
obj - The object to be update
Returns:
Returns true if the method succeeded, false otherwise.
Throws: CannotAllowException
Thrown if access is denied.
Throws: RecordNotFoundException
Thrown if the object isn't in the database.
 o renumber
 public void renumber(StdLibraryObject obj,
                      String newid) throws CannotAllowException, RecordNotFoundException, RemoteException
Gives the object a new number in the database

Parameters:
obj - The object to be update
newid - The new id for the object
Returns:
Returns true if the method succeeded, false otherwise.
Throws: CannotAllowException
Thrown if access is denied.
Throws: RecordNotFoundException
Thrown if the object isn't in the database.
 o validate
 public StdLibraryObject validate(StdLibraryObject obj) throws RecordNotFoundException, RemoteException
Verifies that the object is in the database and sets its properties to the values in the database.

Throws: RecordNotFoundException
Thrown if the object isn't in the database.
 o loanTo
 public void loanTo(Item item,
                    Borrower borrower,
                    Date dueDate) throws CannotAllowException, RecordNotFoundException, RemoteException
Adds a record to the loans table in the database.

Parameters:
item - The item to be checked out.
borrower - The person checking the item out.
dueDate - The date the item is due.
Throws: CannotAllowException
Thrown if the item is already checked out or if the borrower doesn't have permission.
Throws: RecordNotFoundException
Thrown if the item or borrower is not valid
Throws: RuntimeException
Thrown if the item and borrower objects do not match their database records
 o receive
 public Borrower receive(Item item) throws OverdueException, RecordNotFoundException, RemoteException
Checks if the book is overdue then removes the loan record from the database.

Parameters:
item - The item to be received.
Returns:
The Borrower the item is on loan to or null if it's not on loan.
Throws: OverdueException
Thrown if the book is overdue.
Throws: RecordNotFoundException
Thrown if the borrower is not valid
Throws: RuntimeException
Thrown if the item object does not match its database record
 o getDueDate
 public Date getDueDate(Item item) throws RemoteException
Checks if the item is on loan and if so returns the due date, otherwise null.

Returns:
The due date of the item on loan or null if it's not on loan.
Throws: RuntimeException
Thrown if the item object does not match its database record
 o getLoanPeriod
 public int getLoanPeriod(Item item) throws RemoteException
Gets the default loan period for this item.

Returns:
The default loan period in days or 0 if there is none.
 o getBorrower
 public Borrower getBorrower(Item item) throws RemoteException
Checks if the item is on loan and if so returns the Borrower, otherwise null.

Returns:
The Borrower of the item on loan or null if it's not on loan.
 o getLoans
 public Vector getLoans(Borrower borrower) throws RemoteException
Gets the Items this Borrower has on loan.

Returns:
The Borrower of the item on loan or null if it's not on loan.

All Packages  Class Hierarchy  This Package  Previous  Next  Index