public class Schedule extends BaseMetadata implements Serializable
The core part of the Schedule is the Recurrence
class that
provides occurrence based on the defined recurrence pattern. Schedule
allows adding dates to be explicitly included for generating occurrences
in addition to the one generated by the recurrence pattern.
Note that more than one Recurrence
can also be supplied with
a Schedule with the help of RecurrenceSet
class. The resulting
occurrences for the schedule would be the union of occurrences generated
by the individual recurrences present in RecurrenceSet
.
It is also possible to exclude date/times instances from the list of
occurrences a Schedule
generates. Such exclusions can be specified
in two mode, by explicitly providing a list of dates to an instance of
Schedule
or by referencing to a named ExclusionsDefinition
.
An example would be an ExclusionsDefinition that contains the list of
holidays for which the Schedule
must skip the occurrences if
generated.
The start and end date/times if specified in the contained
Recurrence
only apply to the occurrences generated by the
recurrence pattern. Any additional dates explicitly added to the
Schedule
can fall before the start or after the end date
specified.
Example
Schedule to run every monday at 10:00 am plus on 10th
of July 2006, but exclude the 15th May 2006.
Recurrence recur = new Recurrence(RecurrenceFields.FREQUENCY.WEEKLY); recur.addDayOfWeek(RecurrenceFields.DAY_OF_WEEK.MONDAY); recur.setRecurTime(RecurrenceFields.TIME_OF_DAY.valueOf(10, 0, 0)); ExplicitDate july10 = new ExplicitDate(RecurrenceFields.YEAR.valueOf(2006), RecurrenceFields.MONTH_OF_YEAR.JULY RecurrenceFields.DAY_OF_MONTH.valueOf(10)); ExplicitDate may15 = new ExplicitDate(RecurrenceFields.YEAR.valueOf(2006), RecurrenceFields.MONTH_OF_YEAR.MAY, RecurrenceFields.DAY_OF_MONTH.valueOf(15)); Schedule schedule = new Schedule("everyMonday", "Weekly Schedule", recur); schedule.addInclusionDate(july10); schedule.addExclusionDate(may15);
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_LIST_LIMIT
Maximum size of the list of occurences returned by schedule.
|
Constructor and Description |
---|
Schedule(String name,
String description,
Collection dates)
Constructs a new instance with the given set of explicit dates.
|
Schedule(String name,
String description,
Recurrence recur)
Constructs a new instance with the given recurrence.
|
Schedule(String name,
String description,
RecurrenceSet recurSet)
Constructs a new instance with the given RecurrenceSet.
|
Schedule(String name,
String displayNameKey,
String descriptionKey,
Collection dates,
String[] resourceBundleIDs)
Constructs a new instance with the given set of explicit dates
and associate resource bundles.
|
Schedule(String name,
String displayNameKey,
String descriptionKey,
RecurrenceSet recurSet,
String[] resourceBundleIDs)
Constructs a new instance with the given RecurrenceSet and
associate resource bundles.
|
Schedule(String name,
String displayNameKey,
String descriptionKey,
Recurrence recur,
String[] resourceBundleIDs)
Constructs a new instance with the given recurrence and associate
resource bundles.
|
Modifier and Type | Method and Description |
---|---|
void |
addExclusion(MetadataObjectId objectId)
Adds a reference of an instance of ExclusionsDefinition in this
Schedule object.
|
void |
addExclusionDate(ExplicitDate date)
Adds an explicit date to be excluded from occurrences in this
Schedule object.
|
void |
addInclusionDate(ExplicitDate date)
Adds an explicit date to be included for occurrences in this Schedule
object.
|
Schedule |
clone(String newName) |
boolean |
equals(Object obj)
Compares an object for equality with this Schedule object.
|
BaseMetadataType |
getBaseMetadataType()
Gets the intended type of this metadata.
|
Collection |
getExclusionDates()
Gets the list of dates excluded for occurrences in this
Schedule object.
|
Collection |
getExclusions()
Gets the list of ExclusionsDefinition metadata ids that are referenced
by this object.
|
Collection |
getInclusionDates()
Gets the list of explicit dates that are included for occurrences
in this Schedule object.
|
Recurrence |
getRecurrence()
Gets the recurrence object of this schedule instance.
|
RecurrenceSet |
getRecurrenceSet()
Gets the RecurrenceSet object of this schedule instance.
|
TimeZone |
getTimeZone()
Gets the TimeZone set for this Schedule object.
|
Collection |
list(Calendar begin,
Calendar end)
Generates a list of possible occurrences of this Schedule object
within a given time period up to the default limit of 300.
|
Collection |
list(Calendar begin,
Calendar end,
int limit)
Generates a list of possible occurrences of this Schedule object
within a given time period.
|
Collection |
list(Calendar begin,
int count)
Generates a list of possible occurrences of this Schedule object
starting with the given time up to the specified count.
|
void |
removeExclusion(MetadataObjectId objectId)
Removes the given reference of ExclusionsDefinition from this
Schedule object.
|
void |
removeExclusionDate(ExplicitDate date)
Removes an explicit date from the list of dates excluded for occurrences
in this Schedule object.
|
void |
removeInclusionDate(ExplicitDate date)
Removes an explicit date from list of included dates of this
Schedule object.
|
void |
setExclusionDates(Collection dates)
Sets the list of dates excluded for occurrences in this Schedule object.
|
void |
setInclusionDates(Collection dates)
Sets the list of dates to be included for occurrences in this Schedule.
|
void |
setRecurrence(Recurrence recur)
Sets the recurrence for this schedule instance.
|
void |
setRecurrenceSet(RecurrenceSet recurSet)
Sets the RecurrenceSet for this schedule instance.
|
void |
setTimeZone(TimeZone tz)
Sets or clears the TimeZone for this Schedule object.
|
String |
toDisplayString(Locale locale)
Enterprise Manager support to acquire a localized string value.
|
String |
toString()
Gets a String representation for this Schedule object.
|
getDescription, getDescriptionKey, getDisplayName, getDisplayNameKey, getMetadataObjectId, getName, getResourceBundles, hashCode, setDescription, setDescriptionKey, setDisplayName, setDisplayNameKey, setResourceBundles, validate
public static final int DEFAULT_LIST_LIMIT
public Schedule(String name, String description, Recurrence recur)
name
- name of the new instance. It cannot be null.
The name is also used as the default display name unless
otherwise specifically set.description
- an optional description.recur
- an instance of Recurrence objectpublic Schedule(String name, String displayNameKey, String descriptionKey, Recurrence recur, String[] resourceBundleIDs)
name
- name of the new instance. It cannot be null.
The name is also used as the default display name unless otherwise
specifically set.displayNameKey
- the resource bundle key for the display name.
Optional.descriptionKey
- the resource bundle key for the description.
Optional.recur
- an instance of Recurrence objectresourceBundleIDs
- an array of resource bundle id. Optional.public Schedule(String name, String description, RecurrenceSet recurSet)
name
- name of the new instance. It cannot be null.
The name is also used as the default display name unless otherwise
specifically set.description
- an optional description.recurSet
- an instance of RecurrenceSet objectpublic Schedule(String name, String displayNameKey, String descriptionKey, RecurrenceSet recurSet, String[] resourceBundleIDs)
name
- name of the new instance. It cannot be null.
The name is also used as the default display name unless otherwise
specifically set.displayNameKey
- the resource bundle key for the display name.
Optional.descriptionKey
- the resource bundle key for the description.
Optional.recurSet
- an instance of RecurrenceSet objectresourceBundleIDs
- an array of resource bundle id. Optional.public Schedule(String name, String description, Collection dates)
name
- the name for the new instance. It cannot be null.
The name is also used as the default display name unless otherwise
specifically set.description
- an optional description.dates
- a collection explicit dates for occurrences.public Schedule(String name, String displayNameKey, String descriptionKey, Collection dates, String[] resourceBundleIDs)
name
- name of the new instance. It cannot be null.
The name is also used as the default display name unless otherwise
specifically set.displayNameKey
- the resource bundle key for the display name.
Optional.descriptionKey
- the resource bundle key for the description.
Optional.dates
- a collection explicit dates for occurrences.resourceBundleIDs
- an array of resource bundle id.public Recurrence getRecurrence()
public void setRecurrence(Recurrence recur)
recur
- Recurrence object that should be used by this Schedule instance.public RecurrenceSet getRecurrenceSet()
public void setRecurrenceSet(RecurrenceSet recurSet)
recurSet
- RecurrenceSet object that should be used.public void addInclusionDate(ExplicitDate date)
date
- the explicit date to be included.public void removeInclusionDate(ExplicitDate date)
date
- the explicit date to be removed from the list of
included dates.public void setInclusionDates(Collection dates)
dates
- collection of explicit date to be included.public Collection getInclusionDates()
public void addExclusionDate(ExplicitDate date)
date
- the explicit date to be excluded.public void removeExclusionDate(ExplicitDate date)
date
- the explicit date to be removed from the list of
excluded dates.public void setExclusionDates(Collection dates)
dates
- the list of explicit date to be excluded.public Collection getExclusionDates()
public void addExclusion(MetadataObjectId objectId)
objectId
- the identifier of the ExclusionsDefinition to be added.public void removeExclusion(MetadataObjectId objectId)
objectId
- identifier of the ExclusionsDefinition to be removed.public Collection getExclusions()
public TimeZone getTimeZone()
public void setTimeZone(TimeZone tz)
tz
- the TimeZone to be set for this object. NULL if the TimeZone
needs to be cleared/unset.public Collection list(Calendar begin, Calendar end) throws IllegalArgumentException
begin
- the start date/time for listing possible occurrences,
inclusive, not null.end
- the end date/time for listing possible occurrences,
inclusive, not null.IllegalArgumentException
public Collection list(Calendar begin, int count) throws IllegalArgumentException
begin
- the start date/time for listing occurrences,
inclusive, not null.count
- the maximum number of occurrences to be listed.IllegalArgumentException
public Collection list(Calendar begin, Calendar end, int limit) throws IllegalArgumentException
begin
- the start date/time for listing possible occurrences,
inclusive, not null.end
- the end date/time for listing possible occurrences,
inclusive.limit
- the maximum number of occurrences to be listed.
The limit has to be a positive integer or zero.
A zero limit results an empty list.IllegalArgumentException
public boolean equals(Object obj)
public String toString()
toString
in class BaseMetadata
public BaseMetadataType getBaseMetadataType()
BaseMetadata
getBaseMetadataType
in class BaseMetadata
public Schedule clone(String newName)
clone
in class BaseMetadata