1 4 package org.oddjob.schedules; 5 6 import java.util.Date ; 7 import java.util.HashMap ; 8 import java.util.Map ; 9 import java.util.TimeZone ; 10 11 15 public class ScheduleContext { 16 17 18 private final Date date; 19 20 21 private TimeZone timeZone; 22 23 26 private final Map data; 27 28 34 public ScheduleContext(Date now) { 35 this(now, null); 36 } 37 38 45 public ScheduleContext(Date now, TimeZone timeZone) { 46 this(now, timeZone, new HashMap ()); 47 } 48 49 57 public ScheduleContext(Date now, TimeZone timeZone, Map data) { 58 if (timeZone == null) { 59 timeZone = TimeZone.getDefault(); 60 } 61 62 this.date = now; 63 this.timeZone = timeZone; 64 this.data = data; 65 } 66 67 72 public Date getDate() { 73 return date; 74 } 75 76 81 public TimeZone getTimeZone() { 82 return timeZone; 83 } 84 85 91 public void putData(Object key, Object value) { 92 data.put(key, value); 93 } 94 95 101 public Object getData(Object key) { 102 return data.get(key); 103 } 104 105 111 public ScheduleContext spawn(Date date) { 112 ScheduleContext newContext = new ScheduleContext(date, 113 this.timeZone, this.data); 114 return newContext; 115 } 116 } 117 | Popular Tags |