issrg.test.util
Class ConstantClock

java.lang.Object
  extended by issrg.pba.rbac.Time
      extended by issrg.pba.rbac.Clock
          extended by issrg.test.util.ConstantClock
All Implemented Interfaces:
java.lang.Comparable

public class ConstantClock
extends Clock

This class extends the abstract class Clock and has a trivial implementation in that all it does is return the Date object that is used to create it when asked for the current time. This is useful for test purposes.

Author:
sfl

Field Summary
 
Fields inherited from class issrg.pba.rbac.Time
log, s_defaultTimeZone, TIME_TYPE
 
Constructor Summary
ConstantClock(java.util.Date time)
          Creates the ConstancClock object using the Date object that will be returned on subsequent calls to latch and getTime.
ConstantClock(java.lang.String timeString)
          Construct a constant time clock.
 
Method Summary
 java.util.Date getTime()
          This method returns the time returned by the last call to latch, so all calculations will be consistent.
 java.util.Date latch()
          This method gets the actual time and keeps it for later reference.
 
Methods inherited from class issrg.pba.rbac.Clock
getEvaluationTime
 
Methods inherited from class issrg.pba.rbac.Time
calendarToTime, calendarToTime, compareTo, equals, getDefaultTimeZone, parse, register, setDefaultTimeZone, setDefaultTimeZone, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConstantClock

public ConstantClock(java.util.Date time)
Creates the ConstancClock object using the Date object that will be returned on subsequent calls to latch and getTime.

Parameters:
time - the Date object representing the time that will represent the current time

ConstantClock

public ConstantClock(java.lang.String timeString)
Construct a constant time clock. The parameter is interpreted as a time string. If it has a time zone specification attached, then that will be used, otherwise Java's default TimeZone will be used.

Parameters:
timeString - a String representing the time
See Also:
issrg.pba.rbac.Time#Constructor(String)
Method Detail

getTime

public java.util.Date getTime()
Description copied from class: Clock
This method returns the time returned by the last call to latch, so all calculations will be consistent.

Specified by:
getTime in class Clock
Returns:
the time as specified by the constructor.

latch

public java.util.Date latch()
Description copied from class: Clock
This method gets the actual time and keeps it for later reference. Subsequent calls to getTime will return the same value (needed in operations extended in time).

Specified by:
latch in class Clock
Returns:
the time as specified by the constructor.