Holger's
Java API

com.antelmann.timeregister
Class WorkUnitValidator

java.lang.Object
  extended by com.antelmann.timeregister.WorkUnitValidator
All Implemented Interfaces:
Filter<WorkUnit>, Serializable, Comparable<WorkUnitValidator>

public class WorkUnitValidator
extends Object
implements Filter<WorkUnit>, Serializable, Comparable<WorkUnitValidator>

implements a schedule template for a user.

Author:
Holger Antelmann
See Also:
TimeUser, Serialized Form

Nested Class Summary
static class WorkUnitValidator.CheckInterval
          defines the time interval in which a WorkUnit can begin/end
 
Constructor Summary
WorkUnitValidator(String name)
          uses 9am as standardDayBegin and 12h for maxUnitLength
WorkUnitValidator(String name, TimeInDay standardDayBegin, long maxUnitLength)
          uses 0 for minUnitLength
WorkUnitValidator(String name, TimeInDay standardDayBegin, long minUnitLength, long maxUnitLength)
           
WorkUnitValidator(String name, WorkUnitValidator wv)
          allows easy copying of validators
 
Method Summary
 boolean accept(WorkUnit unit)
           
 void add(WorkUnitValidator.CheckInterval interval)
           
 int compareTo(WorkUnitValidator wv)
          simply compares by name
 boolean equals(Object obj)
          based on the name
 TimeInDay getBreakTime(Date date)
           
 TimeInDay getBreakTime(int day)
           
 TimeInDay getDayBegin()
          returns the time a standard working day begins
 long getHolidayTime(HolidayCalendar holidays, Date begin, Date end)
          returns the net working time that falls on a holiday according to this schedule within the given limits.
 List<WorkUnitValidator.CheckInterval> getIntervals()
           
 long getMaxUnitLength()
           
 long getMinUnitLength()
           
 String getName()
           
 TimeInDay getNetWorkingTime(Date date)
           
 long getNetWorkingTime(Date from, Date until)
          consideres the whole days, both limits inclusive, but subtracts break times
 long getWeeklyTime()
          returns the sum of the times of all weekdays
 TimeInDay getWorkingTime(Date date)
           
 long getWorkingTime(Date from, Date until)
          consideres whole days, both limits inclusive (includes break time)
 TimeInDay getWorkingTime(int day)
          takes an integer as defined in Calendar.DAY_OF_WEEK
 int hashCode()
           
 boolean isWorkingDay(int day)
          it is a working day if the scheduled time for that weekday is more than 0
 void remove(WorkUnitValidator.CheckInterval interval)
           
 void setBreakTime(int day, TimeInDay time)
          time must be less or equal than the corresponding working time
 void setWorkingTime(int day, TimeInDay time)
          if time is null, a TimeInDay with value 0 is used instead
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WorkUnitValidator

public WorkUnitValidator(String name)
uses 9am as standardDayBegin and 12h for maxUnitLength


WorkUnitValidator

public WorkUnitValidator(String name,
                         TimeInDay standardDayBegin,
                         long maxUnitLength)
uses 0 for minUnitLength


WorkUnitValidator

public WorkUnitValidator(String name,
                         TimeInDay standardDayBegin,
                         long minUnitLength,
                         long maxUnitLength)

WorkUnitValidator

public WorkUnitValidator(String name,
                         WorkUnitValidator wv)
allows easy copying of validators

Method Detail

getDayBegin

public TimeInDay getDayBegin()
returns the time a standard working day begins


getBreakTime

public TimeInDay getBreakTime(Date date)

getBreakTime

public TimeInDay getBreakTime(int day)

setBreakTime

public void setBreakTime(int day,
                         TimeInDay time)
                  throws IllegalArgumentException
time must be less or equal than the corresponding working time

Throws:
IllegalArgumentException

getWorkingTime

public long getWorkingTime(Date from,
                           Date until)
consideres whole days, both limits inclusive (includes break time)


getNetWorkingTime

public long getNetWorkingTime(Date from,
                              Date until)
consideres the whole days, both limits inclusive, but subtracts break times


getNetWorkingTime

public TimeInDay getNetWorkingTime(Date date)

getWorkingTime

public TimeInDay getWorkingTime(Date date)

getWorkingTime

public TimeInDay getWorkingTime(int day)
takes an integer as defined in Calendar.DAY_OF_WEEK


setWorkingTime

public void setWorkingTime(int day,
                           TimeInDay time)
                    throws IllegalArgumentException
if time is null, a TimeInDay with value 0 is used instead

Throws:
IllegalArgumentException - if the given time for the day is smaller than the corresponing pause

isWorkingDay

public boolean isWorkingDay(int day)
                     throws IllegalArgumentException
it is a working day if the scheduled time for that weekday is more than 0

Throws:
IllegalArgumentException

getWeeklyTime

public long getWeeklyTime()
returns the sum of the times of all weekdays


getMinUnitLength

public long getMinUnitLength()

getMaxUnitLength

public long getMaxUnitLength()

getIntervals

public List<WorkUnitValidator.CheckInterval> getIntervals()

add

public void add(WorkUnitValidator.CheckInterval interval)

remove

public void remove(WorkUnitValidator.CheckInterval interval)

accept

public boolean accept(WorkUnit unit)
Specified by:
accept in interface Filter<WorkUnit>

getName

public String getName()

compareTo

public int compareTo(WorkUnitValidator wv)
simply compares by name

Specified by:
compareTo in interface Comparable<WorkUnitValidator>

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
based on the name

Overrides:
equals in class Object

getHolidayTime

public long getHolidayTime(HolidayCalendar holidays,
                           Date begin,
                           Date end)
returns the net working time that falls on a holiday according to this schedule within the given limits.

See Also:
HolidayCalendar.getHolidays(Date, Date)


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