当前位置: 首页>>代码示例>>Java>>正文


Java Related.END属性代码示例

本文整理汇总了Java中biweekly.parameter.Related.END属性的典型用法代码示例。如果您正苦于以下问题:Java Related.END属性的具体用法?Java Related.END怎么用?Java Related.END使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在biweekly.parameter.Related的用法示例。


在下文中一共展示了Related.END属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:44,代码来源:VAlarmScribe.java

示例2: validate

@Test
public void validate() {
	Trigger property = new Trigger((Date) null);
	assertValidate(property).run(33);

	property = new Trigger(new Date());
	assertValidate(property).run();

	property = new Trigger(new Duration.Builder().build(), null);
	assertValidate(property).run(10);

	property = new Trigger(new Duration.Builder().build(), Related.END);
	assertValidate(property).run();
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:14,代码来源:TriggerTest.java

示例3: 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));
				}
			}
		}
	}
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:67,代码来源:VAlarm.java

示例4: validate_related_end

@Test
public void validate_related_end() {
	VAlarm component = new VAlarm(Action.audio(), new Trigger(new Duration.Builder().build(), Related.END));

	VEvent event = new VEvent();
	assertValidate(component).parents(event).run(12);

	event = new VEvent();
	event.setDateStart(new Date());
	event.setDateEnd(new Date());
	assertValidate(component).parents(event).run();

	event = new VEvent();
	event.setDateStart(new Date());
	assertValidate(component).parents(event).run(12);

	event = new VEvent();
	event.setDuration(new Duration.Builder().build());
	assertValidate(component).parents(event).run(12);

	event = new VEvent();
	event.setDateStart(new Date());
	event.setDuration(new Duration.Builder().build());
	assertValidate(component).parents(event).run();

	VTodo todo = new VTodo();
	assertValidate(component).parents(todo).run(12);

	todo = new VTodo();
	todo.setDateStart(new Date());
	todo.setDateDue(new Date());
	assertValidate(component).parents(todo).run();

	todo = new VTodo();
	todo.setDateStart(new Date());
	assertValidate(component).parents(todo).run(12);

	todo = new VTodo();
	todo.setDuration(new Duration.Builder().build());
	assertValidate(component).parents(todo).run(12);

	todo = new VTodo();
	todo.setDateStart(new Date());
	todo.setDuration(new Duration.Builder().build());
	assertValidate(component).parents(todo).run();

	VJournal journal = new VJournal();
	assertValidate(component).parents(journal).run();
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:49,代码来源:VAlarmTest.java


注:本文中的biweekly.parameter.Related.END属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。