本文整理汇总了Java中biweekly.parameter.Related.START属性的典型用法代码示例。如果您正苦于以下问题:Java Related.START属性的具体用法?Java Related.START怎么用?Java Related.START使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类biweekly.parameter.Related
的用法示例。
在下文中一共展示了Related.START属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: constructors
@Test
public void constructors() throws Exception {
Trigger property = new Trigger((Date) null);
assertNull(property.getDate());
assertNull(property.getDuration());
assertNull(property.getRelated());
Date date = new Date();
property = new Trigger(date);
assertEquals(date, property.getDate());
assertNull(property.getDuration());
assertNull(property.getRelated());
Duration duration = new Duration.Builder().hours(1).build();
property = new Trigger(duration, Related.START);
assertNull(property.getDate());
assertEquals(duration, property.getDuration());
assertEquals(Related.START, property.getRelated());
}
示例2: determineStartDate
/**
* Determines what the alarm property's start date should be.
* @param valarm the component that is being converted to a vCal alarm
* property
* @param parent the component's parent
* @return the start date or null if it cannot be determined
*/
private static Date determineStartDate(VAlarm valarm, ICalComponent parent) {
Trigger trigger = valarm.getTrigger();
if (trigger == null) {
return null;
}
Date triggerStart = trigger.getDate();
if (triggerStart != null) {
return triggerStart;
}
Duration triggerDuration = trigger.getDuration();
if (triggerDuration == null) {
return null;
}
if (parent == null) {
return null;
}
Related related = trigger.getRelated();
Date date = null;
if (related == Related.START) {
date = ValuedProperty.getValue(parent.getProperty(DateStart.class));
} else if (related == Related.END) {
date = ValuedProperty.getValue(parent.getProperty(DateEnd.class));
if (date == null) {
Date dateStart = ValuedProperty.getValue(parent.getProperty(DateStart.class));
Duration duration = ValuedProperty.getValue(parent.getProperty(DurationProperty.class));
if (duration != null && dateStart != null) {
date = duration.add(dateStart);
}
}
}
return (date == null) ? null : triggerDuration.add(date);
}
示例3: copy
@Test
public void copy() {
Trigger original = new Trigger((Date) null);
assertCopy(original);
original = new Trigger(new Date());
assertCopy(original).notSame("getDate");
original = new Trigger(new Duration.Builder().hours(1).build(), Related.START);
assertCopy(original);
}
示例4: validate_related_start
@Test
public void validate_related_start() {
VEvent event = new VEvent();
VAlarm component = new VAlarm(Action.audio(), new Trigger(new Duration.Builder().build(), Related.START));
assertValidate(component).parents(event).run(11);
event = new VEvent();
event.setDateStart(new Date());
component = new VAlarm(Action.audio(), new Trigger(new Duration.Builder().build(), Related.START));
assertValidate(component).parents(event).run();
}
示例5: populateReminders
void populateReminders(Event e) throws RemoteException {
// reminders
Uri remindersUri = Reminders.CONTENT_URI.buildUpon()
.appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true")
.build();
@Cleanup Cursor c = providerClient.query(remindersUri, new String[]{
/* 0 */ Reminders.MINUTES, Reminders.METHOD
}, Reminders.EVENT_ID + "=?", new String[]{String.valueOf(e.getLocalID())}, null);
while (c != null && c.moveToNext()) {
//Duration duration = new Duration.Builder().prior(true).minutes(c.getInt(0)).build();
Duration duration = new Duration.Builder().minutes(c.getInt(0)).build();
Trigger trigger = new Trigger(duration, Related.START);
VAlarm alarm = VAlarm.display(trigger, e.getSummary());
e.addAlarm(alarm);
}
}
示例6: validate
@SuppressWarnings("unchecked")
@Override
protected void validate(List<ICalComponent> components, ICalVersion version, List<ValidationWarning> warnings) {
checkRequiredCardinality(warnings, Action.class, Trigger.class);
Action action = getAction();
if (action != null) {
//AUDIO alarms should not have more than 1 attachment
if (action.isAudio()) {
if (getAttachments().size() > 1) {
warnings.add(new ValidationWarning(7));
}
}
//DESCRIPTION is required for DISPLAY alarms
if (action.isDisplay()) {
checkRequiredCardinality(warnings, Description.class);
}
if (action.isEmail()) {
//SUMMARY and DESCRIPTION is required for EMAIL alarms
checkRequiredCardinality(warnings, Summary.class, Description.class);
//EMAIL alarms must have at least 1 ATTENDEE
if (getAttendees().isEmpty()) {
warnings.add(new ValidationWarning(8));
}
} else {
//only EMAIL alarms can have ATTENDEEs
if (!getAttendees().isEmpty()) {
warnings.add(new ValidationWarning(9));
}
}
if (action.isProcedure()) {
checkRequiredCardinality(warnings, Description.class);
}
}
Trigger trigger = getTrigger();
if (trigger != null) {
Related related = trigger.getRelated();
if (related != null) {
ICalComponent parent = components.get(components.size() - 1);
//if the TRIGGER is relative to DTSTART, confirm that DTSTART exists
if (related == Related.START && parent.getProperty(DateStart.class) == null) {
warnings.add(new ValidationWarning(11));
}
//if the TRIGGER is relative to DTEND, confirm that DTEND (or DUE) exists
if (related == Related.END) {
boolean noEndDate = false;
if (parent instanceof VEvent) {
noEndDate = (parent.getProperty(DateEnd.class) == null && (parent.getProperty(DateStart.class) == null || parent.getProperty(DurationProperty.class) == null));
} else if (parent instanceof VTodo) {
noEndDate = (parent.getProperty(DateDue.class) == null && (parent.getProperty(DateStart.class) == null || parent.getProperty(DurationProperty.class) == null));
}
if (noEndDate) {
warnings.add(new ValidationWarning(12));
}
}
}
}
}