OpenNMS API 1.2.3

org.opennms.web.admin.users.parsers
Class DutySchedule

java.lang.Object
  extended byorg.opennms.web.admin.users.parsers.DutySchedule

public class DutySchedule
extends java.lang.Object

This class holds information on the duty schedules that users can have. Converstion between different formats of the duty schedule information are possible, as is the comparision between a Calendar passed in and the start and stop times of each day in a duty schedule.

Version:
1.1.1.1
Author:
Jason Johns , OpenNMS

Field Summary
private static int[] CALENDAR_DAY_MAPPING
          A mapping between the days of the week as indexed by the DutySchedule class and those of the Calendar class
static java.lang.String[] DAY_NAMES
          A list of names to abbreviate the days of the week
static int FRIDAY
           
private  java.util.BitSet m_days
          Each boolean in the bit set represents a day of the week.
private  int m_startTime
          The starting time of this DutySchedule
private  int m_stopTime
          The ending time of this DutySchedule
static int MONDAY
          A series of constants to identify the days of the week as used by the DutySchedule class
static int SATURDAY
           
static int SUNDAY
           
static int THURSDAY
           
static int TUESDAY
           
static int WEDNESDAY
           
 
Constructor Summary
DutySchedule()
          Create a new DutySchedule.
DutySchedule(java.lang.String aSchedule)
          Create a new DutySchedule.
DutySchedule(java.util.Vector aSchedule)
          Create a new DutySchedule.
 
Method Summary
 java.util.Vector getAsVector()
          Gets the Vector representation of the DutySchedule.
private  int getDayInt(java.lang.String aDay)
          Gets the index value of a day.
 int getStartTime()
          Gets the start time.
 int getStopTime()
          Gets the stop time.
 boolean isInSchedule(java.util.Calendar aTime)
          Test if time is contined in schedule.
 void setDay(int aDay)
          Sets the day.
 void setEndHour(int anHour)
          Sets the stop Hour.
 void setStartHour(int anHour)
          Sets the start Hour.
 java.lang.String toString()
          String representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_days

private java.util.BitSet m_days
Each boolean in the bit set represents a day of the week. Monday = 0, Tuesday = 1 ... Sunday = 6


m_startTime

private int m_startTime
The starting time of this DutySchedule


m_stopTime

private int m_stopTime
The ending time of this DutySchedule


MONDAY

public static final int MONDAY
A series of constants to identify the days of the week as used by the DutySchedule class

See Also:
Constant Field Values

TUESDAY

public static final int TUESDAY
See Also:
Constant Field Values

WEDNESDAY

public static final int WEDNESDAY
See Also:
Constant Field Values

THURSDAY

public static final int THURSDAY
See Also:
Constant Field Values

FRIDAY

public static final int FRIDAY
See Also:
Constant Field Values

SATURDAY

public static final int SATURDAY
See Also:
Constant Field Values

SUNDAY

public static final int SUNDAY
See Also:
Constant Field Values

DAY_NAMES

public static final java.lang.String[] DAY_NAMES
A list of names to abbreviate the days of the week


CALENDAR_DAY_MAPPING

private static final int[] CALENDAR_DAY_MAPPING
A mapping between the days of the week as indexed by the DutySchedule class and those of the Calendar class

Constructor Detail

DutySchedule

public DutySchedule()
Create a new DutySchedule. Builds the BitSet used to identify the days of the week that are set.


DutySchedule

public DutySchedule(java.util.Vector aSchedule)
Create a new DutySchedule. This constructor is designed to convert from a Vector filled with 7 Boolean objects and two String objects into the BitSet and integer start and stop time. Very useful for the ModifyUser screen when it is converting from a table display to save the information to a string format for the users.xml.

Parameters:
aSchedule - Vector filled with 7 Boolean objects and two String objects

DutySchedule

public DutySchedule(java.lang.String aSchedule)
Create a new DutySchedule. This constructor is designed to build a new DutySchedule from a String representation formatted as such. - eg. MoWeFr800-1700, TuTh900-1500.

Parameters:
aSchedule - the string to convert to a new DutySchedule
Method Detail

getDayInt

private int getDayInt(java.lang.String aDay)
Gets the index value of a day. This method returns the index value of a day abbreviation

Parameters:
aDay - the day abbreviation
Returns:
the index associated with this abbreviation

setDay

public void setDay(int aDay)
Sets the day. This method sets the BitSet that tracks what days this DutySchedule applies to.

Parameters:
aDay - the day index to set in the BitSet

getStartTime

public int getStartTime()
Gets the start time. This method return the start time as an integer

Returns:
the start time of this DutySchedule

getStopTime

public int getStopTime()
Gets the stop time. This method return the stop time as an integer

Returns:
the stop time of this DutySchedule

getAsVector

public java.util.Vector getAsVector()
Gets the Vector representation of the DutySchedule. This method formats the DutySchedule as a vector populated with the first seven objects as Booleans set to indicate what days of the week are stored, and the last two objects as Strings that reflect the start time and stop time respectively. This method gives a Vector that can be passed to the DutySchedule(Vector) constructor to create a new DutySchedule

Returns:
a Vector properly formatted to reflect this DutySchedule

isInSchedule

public boolean isInSchedule(java.util.Calendar aTime)
Test if time is contined in schedule. This method decides if a given time falls within the duty schedule contained in this object. It creates two partial Calendars from the Calendar that is passed in and then sets the start time for one and the end time for the other. Then in a loop it reassigns the day of week according to the BitSet. It makes a comparision to see if the argument Calendar is between the start and stop times and returns true immediately if it is.

Parameters:
aTime - the time to check
Returns:
true if the Calendar is contained in the duty schedule, false if it isn't.

setStartHour

public void setStartHour(int anHour)
Sets the start Hour. This method sets the start time of this DutySchedule

Parameters:
anHour - the hour in military time to set the start time for the DutySchedule

setEndHour

public void setEndHour(int anHour)
Sets the stop Hour. This method sets the stop time of this DutySchedule

Parameters:
anHour - the hour in military time to set the end time for the DutySchedule

toString

public java.lang.String toString()
String representation. This method returns the DutySchedule formatted as a string that the DutySchedule(String) constructor could parse. The string will be formatted as such: - eg. MoWeFr800-1700, TuTh900-1500.

Returns:
a string representation of this DutySchedule

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.