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


Java Related类代码示例

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


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

示例1: constructors

import biweekly.parameter.Related; //导入依赖的package包/类
@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());
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:20,代码来源:TriggerTest.java

示例2: equals

import biweekly.parameter.Related; //导入依赖的package包/类
@Test
public void equals() {
	//@formatter:off
	assertNothingIsEqual(
		new Trigger((Date)null),
		new Trigger(date("2016-01-21")),
		new Trigger(date("2016-01-22")),
		new Trigger(new Duration.Builder().hours(1).build(), null),
		new Trigger(new Duration.Builder().hours(1).build(), Related.START),
		new Trigger(new Duration.Builder().hours(1).build(), Related.END),
		new Trigger(new Duration.Builder().hours(2).build(), Related.START)
	);

	assertEqualsMethod(Trigger.class, new Date())
	.constructor(new Class<?>[]{Date.class}, (Date)null).test()
	.constructor(new Date()).test()
	.constructor(new Duration.Builder().hours(1).build(), Related.START).test();
	//@formatter:on
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:20,代码来源:TriggerTest.java

示例3: validate

import biweekly.parameter.Related; //导入依赖的package包/类
@Override
protected void validate(List<ICalComponent> components, ICalVersion version, List<ValidationWarning> warnings) {
	if (duration == null && date == null) {
		warnings.add(new ValidationWarning(33));
	}

	Related related = getRelated();
	if (duration != null && related == null) {
		warnings.add(new ValidationWarning(10));
	}
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:12,代码来源:Trigger.java

示例4: determineStartDate

import biweekly.parameter.Related; //导入依赖的package包/类
/**
 * 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,代码行数:45,代码来源:VAlarmScribe.java

示例5: set_value

import biweekly.parameter.Related; //导入依赖的package包/类
@Test
public void set_value() {
	Trigger property = new Trigger((Date) null);

	Date date = new Date();
	property.setDate(date);
	assertEquals(date, property.getDate());
	assertNull(property.getDuration());
	assertNull(property.getRelated());

	Duration duration = new Duration.Builder().hours(1).build();
	property.setDuration(duration, Related.START);
	assertNull(property.getDate());
	assertEquals(duration, property.getDuration());
	assertEquals(Related.START, property.getRelated());

	property.setRelated(Related.END);
	assertNull(property.getDate());
	assertEquals(duration, property.getDuration());
	assertEquals(Related.END, property.getRelated());

	property.setDate(date);
	assertEquals(date, property.getDate());
	assertNull(property.getDuration());
	assertNull(property.getRelated());

	property.setRelated(Related.END);
	assertEquals(date, property.getDate());
	assertNull(property.getDuration());
	assertEquals(Related.END, property.getRelated());

}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:33,代码来源:TriggerTest.java

示例6: validate

import biweekly.parameter.Related; //导入依赖的package包/类
@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,代码行数:15,代码来源:TriggerTest.java

示例7: copy

import biweekly.parameter.Related; //导入依赖的package包/类
@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);
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:12,代码来源:TriggerTest.java

示例8: validate_related_start

import biweekly.parameter.Related; //导入依赖的package包/类
@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();
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:12,代码来源:VAlarmTest.java

示例9: populateReminders

import biweekly.parameter.Related; //导入依赖的package包/类
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);
	}
}
 
开发者ID:eXfio,项目名称:CucumberSync,代码行数:17,代码来源:LocalCalendar.java

示例10: setDuration

import biweekly.parameter.Related; //导入依赖的package包/类
/**
 * Sets a relative time at which the alarm will trigger.
 * @param duration the relative time
 * @param related the date-time field that the duration is relative to
 */
public void setDuration(Duration duration, Related related) {
	this.date = null;
	this.duration = duration;
	setRelated(related);
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:11,代码来源:Trigger.java

示例11: validate

import biweekly.parameter.Related; //导入依赖的package包/类
@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,代码行数:68,代码来源:VAlarm.java

示例12: validate_related_end

import biweekly.parameter.Related; //导入依赖的package包/类
@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,代码行数:50,代码来源:VAlarmTest.java

示例13: Trigger

import biweekly.parameter.Related; //导入依赖的package包/类
/**
 * Creates a trigger property.
 * @param duration the relative time
 * @param related the date-time field that the duration is relative to
 */
public Trigger(Duration duration, Related related) {
	setDuration(duration, related);
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:9,代码来源:Trigger.java

示例14: getRelated

import biweekly.parameter.Related; //导入依赖的package包/类
/**
 * Gets the date-time field that the duration is relative to.
 * @return the field or null if not set
 * @see <a href="http://tools.ietf.org/html/rfc5545#page-24">RFC 5545
 * p.24</a>
 */
public Related getRelated() {
	return parameters.getRelated();
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:10,代码来源:Trigger.java

示例15: setRelated

import biweekly.parameter.Related; //导入依赖的package包/类
/**
 * Sets the date-time field that the duration is relative to.
 * @param related the field or null to remove
 * @see <a href="http://tools.ietf.org/html/rfc5545#page-24">RFC 5545
 * p.24</a>
 */
public void setRelated(Related related) {
	parameters.setRelated(related);
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:10,代码来源:Trigger.java


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