biweekly.component
Class VAlarm

java.lang.Object
  extended by biweekly.component.ICalComponent
      extended by biweekly.component.VAlarm

public class VAlarm
extends ICalComponent

Defines a reminder for an event or to-do task. This class contains static factory methods to aid in the construction of valid alarms.

Examples:

 //audio alarm
 Trigger trigger = ...
 Attachment sound = ...
 VAlarm audio = VAlarm.audio(trigger, sound);
 
 //display alarm
 Trigger trigger = ...
 String message = "Meeting at 1pm";
 VAlarm display = VAlarm.display(trigger, message);
 
 //email alarm
 Trigger trigger = ...
 String subject = "Reminder: Meeting at 1pm";
 String body = "Team,\n\nThe team meeting scheduled for 1pm is about to start.  Snacks will be served!\n\nThanks,\nJohn";
 List<String> to = Arrays.asList("janedoe@example.com", "bobsmith@example.com");
 VAlarm email = VAlarm.email(trigger, subject, body, to);
 

Author:
Michael Angstadt
Specification Reference:
RFC 5545 p.71-6

Field Summary
 
Fields inherited from class biweekly.component.ICalComponent
components, properties
 
Constructor Summary
VAlarm(Action action, Trigger trigger)
          Creates a new alarm.
 
Method Summary
 void addAttachment(Attachment attachment)
          Adds an attachment to the alarm.
 void addAttendee(Attendee attendee)
          Adds a person who will be emailed when the alarm fires (only applicable for EMAIL alarms).
static VAlarm audio(Trigger trigger)
          Creates an audio alarm.
static VAlarm audio(Trigger trigger, Attachment sound)
          Creates an audio alarm.
static VAlarm display(Trigger trigger, String displayText)
          Creates a display alarm.
static VAlarm email(Trigger trigger, String subject, String body, List<String> recipients)
          Creates an email alarm.
static VAlarm email(Trigger trigger, String subject, String body, String... recipients)
          Creates an email alarm.
 Action getAction()
          Gets the type of action to invoke when the alarm is triggered.
 List<Attachment> getAttachments()
          Gets any attachments that are associated with the alarm.
 List<Attendee> getAttendees()
          Gets the people who will be emailed when the alarm fires (only applicable for EMAIL alarms).
 Description getDescription()
           Gets a detailed description of the alarm.
 DurationProperty getDuration()
          Gets the length of the pause between alarm repetitions.
 Repeat getRepeat()
          Gets the number of times an alarm should be repeated after its initial trigger.
 Summary getSummary()
           Gets the summary of the alarm.
 Trigger getTrigger()
          Gets when the alarm will be triggered.
 void setAction(Action action)
          Sets the type of action to invoke when the alarm is triggered.
 void setDescription(Description description)
           Sets a detailed description of the alarm.
 Description setDescription(String description)
           Sets a detailed description of the alarm.
 DurationProperty setDuration(Duration duration)
          Sets the length of the pause between alarm repetitions.
 void setDuration(DurationProperty duration)
          Sets the length of the pause between alarm repetitions.
 void setRepeat(int count, Duration pauseDuration)
          Sets the repetition information for the alarm.
 Repeat setRepeat(Integer count)
          Sets the number of times an alarm should be repeated after its initial trigger.
 void setRepeat(Repeat repeat)
          Sets the number of times an alarm should be repeated after its initial trigger.
 Summary setSummary(String summary)
           Sets the summary of the alarm.
 void setSummary(Summary summary)
           Sets the summary of the alarm.
 void setTrigger(Trigger trigger)
          Sets when the alarm will be triggered.
protected  void validate(List<ICalComponent> components, List<String> warnings)
          Checks the component for data consistency problems or deviations from the spec.
 
Methods inherited from class biweekly.component.ICalComponent
addComponent, addExperimentalComponent, addExperimentalProperty, addExperimentalProperty, addProperty, checkOptionalCardinality, checkRequiredCardinality, getComponent, getComponents, getComponents, getExperimentalComponent, getExperimentalComponents, getExperimentalComponents, getExperimentalProperties, getExperimentalProperties, getExperimentalProperty, getProperties, getProperties, getProperty, removeExperimentalComponents, removeExperimentalProperty, removeProperties, setComponent, setComponent, setExperimentalComponents, setExperimentalProperty, setExperimentalProperty, setProperty, setProperty, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VAlarm

public VAlarm(Action action,
              Trigger trigger)
Creates a new alarm. Consider using one of the static factory methods instead.

Parameters:
action - the alarm action (e.g. "email")
trigger - the trigger
Method Detail

audio

public static VAlarm audio(Trigger trigger)
Creates an audio alarm.

Parameters:
trigger - the trigger
Returns:
the alarm

audio

public static VAlarm audio(Trigger trigger,
                           Attachment sound)
Creates an audio alarm.

Parameters:
trigger - the trigger
sound - a sound to play when the alarm triggers
Returns:
the alarm

display

public static VAlarm display(Trigger trigger,
                             String displayText)
Creates a display alarm.

Parameters:
trigger - the trigger
displayText - the display text
Returns:
the alarm

email

public static VAlarm email(Trigger trigger,
                           String subject,
                           String body,
                           String... recipients)
Creates an email alarm.

Parameters:
trigger - the trigger
subject - the email subject
body - the email body
recipients - the email address(es) to send the alert to
Returns:
the alarm

email

public static VAlarm email(Trigger trigger,
                           String subject,
                           String body,
                           List<String> recipients)
Creates an email alarm.

Parameters:
trigger - the trigger
subject - the email subject
body - the email body
recipients - the email address(es) to send the alert to
Returns:
the alarm

getAttachments

public List<Attachment> getAttachments()
Gets any attachments that are associated with the alarm.

Returns:
the attachments
Specification Reference:
RFC 5545 p.80-1

addAttachment

public void addAttachment(Attachment attachment)
Adds an attachment to the alarm. Note that AUDIO alarms should only have 1 attachment.

Parameters:
attachment - the attachment to add
Specification Reference:
RFC 5545 p.80-1

getDescription

public Description getDescription()

Gets a detailed description of the alarm. The description should be more detailed than the one provided by the Summary property.

This property has different meanings, depending on the alarm action:

Returns:
the description or null if not set
Specification Reference:
RFC 5545 p.84-5

setDescription

public void setDescription(Description description)

Sets a detailed description of the alarm. The description should be more detailed than the one provided by the Summary property.

This property has different meanings, depending on the alarm action:

Parameters:
description - the description or null to remove
Specification Reference:
RFC 5545 p.84-5

setDescription

public Description setDescription(String description)

Sets a detailed description of the alarm. The description should be more detailed than the one provided by the Summary property.

This property has different meanings, depending on the alarm action:

Parameters:
description - the description or null to remove
Returns:
the property that was created
Specification Reference:
RFC 5545 p.84-5

getSummary

public Summary getSummary()

Gets the summary of the alarm.

This property has different meanings, depending on the alarm action:

Returns:
the summary or null if not set
Specification Reference:
RFC 5545 p.93-4

setSummary

public void setSummary(Summary summary)

Sets the summary of the alarm.

This property has different meanings, depending on the alarm action:

Parameters:
summary - the summary or null to remove
Specification Reference:
RFC 5545 p.93-4

setSummary

public Summary setSummary(String summary)

Sets the summary of the alarm.

This property has different meanings, depending on the alarm action:

Parameters:
summary - the summary or null to remove
Returns:
the property that was created
Specification Reference:
RFC 5545 p.93-4

getAttendees

public List<Attendee> getAttendees()
Gets the people who will be emailed when the alarm fires (only applicable for EMAIL alarms).

Returns:
the email recipients
Specification Reference:
RFC 5545 p.107-9

addAttendee

public void addAttendee(Attendee attendee)
Adds a person who will be emailed when the alarm fires (only applicable for EMAIL alarms).

Parameters:
attendee - the email recipient
Specification Reference:
RFC 5545 p.107-9

getAction

public Action getAction()
Gets the type of action to invoke when the alarm is triggered.

Returns:
the action or null if not set
Specification Reference:
RFC 5545 p.132-3

setAction

public void setAction(Action action)
Sets the type of action to invoke when the alarm is triggered.

Parameters:
action - the action or null to remove
Specification Reference:
RFC 5545 p.132-3

getDuration

public DurationProperty getDuration()
Gets the length of the pause between alarm repetitions.

Returns:
the duration or null if not set
Specification Reference:
RFC 5545 p.99

setDuration

public void setDuration(DurationProperty duration)
Sets the length of the pause between alarm repetitions.

Parameters:
duration - the duration or null to remove
Specification Reference:
RFC 5545 p.99

setDuration

public DurationProperty setDuration(Duration duration)
Sets the length of the pause between alarm repetitions.

Parameters:
duration - the duration or null to remove
Returns:
the property that was created
Specification Reference:
RFC 5545 p.99

getRepeat

public Repeat getRepeat()
Gets the number of times an alarm should be repeated after its initial trigger.

Returns:
the repeat count or null if not set
Specification Reference:
RFC 5545 p.133

setRepeat

public void setRepeat(Repeat repeat)
Sets the number of times an alarm should be repeated after its initial trigger.

Parameters:
repeat - the repeat count or null to remove
Specification Reference:
RFC 5545 p.133

setRepeat

public Repeat setRepeat(Integer count)
Sets the number of times an alarm should be repeated after its initial trigger.

Parameters:
count - the repeat count (e.g. "2" to repeat it two more times after it was initially triggered, for a total of three times) or null to remove
Returns:
the property that was created
Specification Reference:
RFC 5545 p.133

setRepeat

public void setRepeat(int count,
                      Duration pauseDuration)
Sets the repetition information for the alarm.

Parameters:
count - the repeat count (e.g. "2" to repeat it two more times after it was initially triggered, for a total of three times)
pauseDuration - the length of the pause between repeats
Specification Reference:
RFC 5545 p.133

getTrigger

public Trigger getTrigger()
Gets when the alarm will be triggered.

Returns:
the trigger time or null if not set
Specification Reference:
RFC 5545 p.133-6

setTrigger

public void setTrigger(Trigger trigger)
Sets when the alarm will be triggered.

Parameters:
trigger - the trigger time or null to remove
Specification Reference:
RFC 5545 p.133-6

validate

protected void validate(List<ICalComponent> components,
                        List<String> warnings)
Description copied from class: ICalComponent
Checks the component for data consistency problems or deviations from the spec. Meant to be overridden by child classes.

Overrides:
validate in class ICalComponent
Parameters:
components - the hierarchy of components that the component belongs to
warnings - the list to add the warnings to


Copyright © 2013 Michael Angstadt. All Rights Reserved.