Holger's
Java API

com.antelmann.timeregister
Class FilePunchDB

java.lang.Object
  extended by com.antelmann.timeregister.AbstractPunchDB
      extended by com.antelmann.timeregister.FilePunchDB
All Implemented Interfaces:
PunchDB

public class FilePunchDB
extends AbstractPunchDB

The implementation is backed by a binary file but works largely in-memory.

Author:
Holger Antelmann

Field Summary
 
Fields inherited from class com.antelmann.timeregister.AbstractPunchDB
listeners
 
Constructor Summary
FilePunchDB(File dataFile)
           
 
Method Summary
 void close()
          empty implementation
 void delete(PunchData entry)
          optional operation; may throw UnsupportedOperationException.
 PunchData getFirstPunch(User user)
          if user is null, the first punch of all is returned.
 PunchData getLastPunch(User user)
          if user is null, the last punch of all is returned.
 PunchDataAnalyzer getPunchData(User user, Date after, Date before, String location, String activity)
          retrieves the relevant set of Punchdata objects
 Map<Object,TimeUser> getUsers()
          returns an unmodifiable view of the users, mapping the id to a TimeUser
 boolean insertUser(User user)
           
 void refresh()
           
 void store(PunchData entry)
          used by the final punch(PunchData) method to delegate the database storing.
 void updatePassword(User user)
          updates the permanent storage with the password that is now present in the user
 
Methods inherited from class com.antelmann.timeregister.AbstractPunchDB
addPunchListener, getPunchListeners, punch, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilePunchDB

public FilePunchDB(File dataFile)
            throws IOException,
                   FormatException
Throws:
IOException
FormatException
Method Detail

close

public void close()
empty implementation


refresh

public void refresh()
             throws IOException,
                    FormatException
Throws:
IOException
FormatException

insertUser

public boolean insertUser(User user)
                   throws IOException
Throws:
IOException

updatePassword

public void updatePassword(User user)
                    throws DatabaseException
Description copied from interface: PunchDB
updates the permanent storage with the password that is now present in the user

Throws:
DatabaseException
See Also:
UserImpl.setPassword(char[]), UserImpl.getPasswordHash()

store

public void store(PunchData entry)
           throws DatabaseException
Description copied from class: AbstractPunchDB
used by the final punch(PunchData) method to delegate the database storing. (Note that a PunchAdminDB makes this method public)

Specified by:
store in class AbstractPunchDB
Throws:
DatabaseException
See Also:
PunchDB.punch(PunchData)

delete

public void delete(PunchData entry)
            throws DatabaseException,
                   UnsupportedOperationException
optional operation; may throw UnsupportedOperationException.

Throws:
DatabaseException
UnsupportedOperationException

getPunchData

public PunchDataAnalyzer getPunchData(User user,
                                      Date after,
                                      Date before,
                                      String location,
                                      String activity)
                               throws DatabaseException
retrieves the relevant set of Punchdata objects

Parameters:
after - limits retrieval by begin date; if null, this limit does not apply
before - limits retrieval by end date; if null, this limit does not apply
user - limits retrieval by employee; if null, this limit does not apply
Returns:
a set of PunchData objects
Throws:
DatabaseException
See Also:
PunchData

getFirstPunch

public PunchData getFirstPunch(User user)
Description copied from interface: PunchDB
if user is null, the first punch of all is returned. If no punch data is available, null is returned.


getLastPunch

public PunchData getLastPunch(User user)
Description copied from interface: PunchDB
if user is null, the last punch of all is returned. If no punch data is available, null is returned.


getUsers

public Map<Object,TimeUser> getUsers()
Description copied from interface: PunchDB
returns an unmodifiable view of the users, mapping the id to a TimeUser



(c) 2001-2006 Holger Antelmann - all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads