1 package org.iotivity.service.tm;
3 import android.util.Log;
6 * This class provides time-related information used for
7 * scheduled/recursive group action features. Along with time-related
8 * variables, it also provides various useful functionality including
9 * translating time to second unit
13 public enum ActionSetType {
14 NONE, SCHEDULED, RECURSIVE
18 public int mMonth = 0;
23 public int mDayOfWeek = 0;
25 private ActionSetType mType = ActionSetType.NONE;
26 private long mDelay = 0;
28 private final String LOG_TAG = this.getClass().getSimpleName();
31 * Set the time for executing ActionSet.
36 * Month of the year to be set
38 * Day of the month to be set
46 * Day of the week to be set
49 public void setTime(int year, int month, int day, int hour, int min,
50 int sec, int dayOfTheWeek) {
51 if (year < 0 || month < 0 || day < 0 || hour < 0 || min < 0 || sec < 0
52 || dayOfTheWeek < 0) {
53 Log.e(LOG_TAG, "Input time is invalid");
67 mDayOfWeek = dayOfTheWeek;
68 mType = ActionSetType.NONE;
72 * Set type of ActionSet.
77 public void setType(ActionSetType type) {
82 * Set day of the week for recursively executing ActionSet.
87 public void setDayOfWeekForRecursive(int day) {
89 mType = ActionSetType.RECURSIVE;
90 setTime(0, 0, 0, 0, 0, 0, day);
95 * Set the time delay in seconds for executing ActionSet.
98 * time delay in seconds
101 public void setDelay(long seconds) {
102 if (mType != ActionSetType.NONE) {
108 * Get absolute time in seconds.
110 * @return long - Absolute time in seconds.
113 public long getSecAbsTime() {
116 interval = (mHour * 60 * 60);
117 interval += (mMin * 60);
118 interval += (mSec * 1);
124 * Get the type of ActionSet.
126 * @return ActionSetType - Type of ActionSet.
129 public ActionSetType getType() {
134 * Get the time delay in seconds set in the ActionSet.
136 * @return long - Delay in seconds.
139 public long getDelay() {