issrg.pba.rbac
Class Time

java.lang.Object
  extended by issrg.pba.rbac.Time
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
Clock

public class Time
extends java.lang.Object
implements java.lang.Comparable

This is an extension for evaluating Time expressions in the XML Policy.

The Policy must contain Const values of type "Time". The values must conform to the following syntax: "ccyy-mm-ddThh:mm:ss timezone" (like in Validity elements in XML Policy). The timezone specification can be either of the form of GMT offset, with no leading space, or a timezone name, known to Java. Thus the time can be specified up to the seconds. The year should always have 4 digits. Other fields do not need to have 2 digits, if they represent numbers less than 10. "*" asterisc can be used as a wildcard to represent "any value" at that position. Trailing fields can be omitted and their values will be considered 0.

Examples:

<Constant Type="Time" Value="*-*-*T8:20" />

The example matches 08:20:00 in the morning any day

<Constant Type="Time" Value="*-*-*T8:20:*" />

The above matches any second after 08:20:00 and before 08:21:00 in the morning any day. This is different from the above example in that it matches ANY second, i.e. the whole minute up to 8:21, whilst the previous example specifies exact time of day (8:20:00).

<Constant Type="Time" Value="*-1-*T20" />

This example matches 8pm any day throughout January.

<Constant Type="Time" Value="*-1" />

This example matches midnight of every 1st of January.

The extension has been provided in PBA v1.1.


Field Summary
protected static java.util.logging.Logger log
           
protected static java.util.TimeZone s_defaultTimeZone
           
static java.lang.String TIME_TYPE
           
 
Constructor Summary
protected Time()
           
  Time(java.lang.String timeString)
          This constructor builds a Time object out of its string representation
 
Method Summary
protected static int[] calendarToTime(java.util.Calendar c)
          This method does the same as calendarToTime( int[], Calendar ), only it allocates the array first, and returns it as the result.
protected static void calendarToTime(int[] t, java.util.Calendar c)
          This routine takes the Calendar and extracts the date/time values in the Calendar's timezone into the array of integers.
 int compareTo(java.lang.Object t1)
          Returns a negative, a positive integer or zero, if this Time is less than, more than, or equal to the given Time respectively.
 boolean equals(java.lang.Object o)
          Returns true, if this Time is equal to the given Time.
static java.util.TimeZone getDefaultTimeZone()
           
 java.util.Date getEvaluationTime()
          Returns the date that the evaluation takes place at.
static int[] parse(java.lang.String timeString)
          This method parses the String as the time of the form "yyyy-MM-ddThh:mm:ss", without the timezone, with every part of the string being optional, and allowing wildcard "*" values.
static void register()
           
static void setDefaultTimeZone(java.lang.String tzID)
          This method sets the default timezone to be used by Time, when parsing string without explicitly specified timezone.
static void setDefaultTimeZone(java.util.TimeZone tz)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static final java.util.logging.Logger log

TIME_TYPE

public static final java.lang.String TIME_TYPE
See Also:
Constant Field Values

s_defaultTimeZone

protected static java.util.TimeZone s_defaultTimeZone
Constructor Detail

Time

protected Time()

Time

public Time(java.lang.String timeString)
     throws java.lang.IllegalArgumentException
This constructor builds a Time object out of its string representation

Parameters:
timeString - - the String in the format explained above.
Throws:
java.lang.IllegalArgumentException
Method Detail

register

public static void register()

getDefaultTimeZone

public static java.util.TimeZone getDefaultTimeZone()

setDefaultTimeZone

public static void setDefaultTimeZone(java.lang.String tzID)
This method sets the default timezone to be used by Time, when parsing string without explicitly specified timezone. The java.util.TimeZone.getTimeZone( String ) is called to obtain the TimeZone for tzID, so if this string is not a valid timezone id, GMT will be used, as specified by javadocs for TimeZone.

Calling this method affects only the newly created Time objects.

Parameters:
tzID - the id of the TimeZone in a format compatible with java.util.TimeZone requirements

setDefaultTimeZone

public static void setDefaultTimeZone(java.util.TimeZone tz)

getEvaluationTime

public java.util.Date getEvaluationTime()
Returns the date that the evaluation takes place at. If the Time is a pattern, the returned Date will be null, as the evaluation time cannot be represented as a single Date.

Returns:
Date containing the time at the point of evaluation; may be null, if this Time is expressed using a pattern

equals

public boolean equals(java.lang.Object o)
Returns true, if this Time is equal to the given Time. This is the same as checking that compareTo( o ) == 0

Overrides:
equals in class java.lang.Object
Parameters:
o - the Time to compare to
Returns:
true, if this Time is equal to o
Throws:
java.lang.ClassCastException - - if o cannot be cast to Time

compareTo

public int compareTo(java.lang.Object t1)
Returns a negative, a positive integer or zero, if this Time is less than, more than, or equal to the given Time respectively.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
time - the Time to compare to
Returns:
a negative integer, if this Time is less than t; a positive integer, if this Time is greater than t; a zero, if this Time is equal to t
Throws:
java.lang.ClassCastException - - if t cannot be cast to Time

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

calendarToTime

protected static void calendarToTime(int[] t,
                                     java.util.Calendar c)
This routine takes the Calendar and extracts the date/time values in the Calendar's timezone into the array of integers.


calendarToTime

protected static int[] calendarToTime(java.util.Calendar c)
This method does the same as calendarToTime( int[], Calendar ), only it allocates the array first, and returns it as the result.


parse

public static int[] parse(java.lang.String timeString)
This method parses the String as the time of the form "yyyy-MM-ddThh:mm:ss", without the timezone, with every part of the string being optional, and allowing wildcard "*" values.