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