本文整理汇总了Java中net.fortuna.ical4j.model.component.VTimeZone类的典型用法代码示例。如果您正苦于以下问题:Java VTimeZone类的具体用法?Java VTimeZone怎么用?Java VTimeZone使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VTimeZone类属于net.fortuna.ical4j.model.component包,在下文中一共展示了VTimeZone类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ComponentFilter
import net.fortuna.ical4j.model.component.VTimeZone; //导入依赖的package包/类
/**
* Construct a ComponentFilter object from a DOM Element.
* @param element The element.
* @param timezone The timezone.
* @throws ParseException - if something is wrong this exception is thrown.
*/
public ComponentFilter(Element element, VTimeZone timezone) throws ParseException {
// Name must be present
validateName(element);
final ElementIterator i = DomUtils.getChildren(element);
int childCount = 0;
while (i.hasNext()) {
final Element child = i.nextElement();
childCount++;
// if is-not-defined is present, then nothing else can be present
validateNotDefinedState(childCount);
Initializers.getInitializer(child.getLocalName()).initialize(child, timezone, this, childCount);
}
}
示例2: CalendarFilter
import net.fortuna.ical4j.model.component.VTimeZone; //导入依赖的package包/类
/**
* Construct a CalendarFilter object from a DOM Element.
*
* @param element
* The element.
* @param timezone
* The timezone.
* @throws ParseException
* - if something is wrong this exception is thrown.
*/
public CalendarFilter(Element element, VTimeZone timezone) throws ParseException {
// Can only have a single comp-filter element
final ElementIterator i = DomUtils.getChildren(element, CarldavConstants.c(ELEMENT_CALDAV_COMP_FILTER));
if (!i.hasNext()) {
throw new ParseException("CALDAV:filter must contain a comp-filter", -1);
}
final Element child = i.nextElement();
if (i.hasNext()) {
throw new ParseException("CALDAV:filter can contain only one comp-filter", -1);
}
// Create new component filter and have it parse the element
filter = new ComponentFilter(child, timezone);
}
示例3: hasMultipleComponentTypes
import net.fortuna.ical4j.model.component.VTimeZone; //导入依赖的package包/类
public static boolean hasMultipleComponentTypes(Calendar calendar) {
String found = null;
for (Object component: calendar.getComponents()) {
if (component instanceof VTimeZone) {
continue;
}
if (found == null) {
found = ((CalendarComponent)component).getName();
continue;
}
if (! found.equals(((CalendarComponent)component).getName())) {
return true;
}
}
return false;
}
示例4: parseReport
import net.fortuna.ical4j.model.component.VTimeZone; //导入依赖的package包/类
/**
* Parses the report info, extracting the properties, filters and time
* zone.
*/
protected void parseReport(ReportInfo info)
throws CosmoDavException {
if (! getType().isRequestedReportType(info)) {
throw new CosmoDavException("Report not of type " + getType());
}
setPropFindProps(info.getPropertyNameSet());
if (info.containsContentElement(DavConstants.ALLPROP)) {
setPropFindType(PROPFIND_ALL_PROP);
} else if (info.containsContentElement(DavConstants.PROPNAME)) {
setPropFindType(PROPFIND_PROPERTY_NAMES);
} else {
setPropFindType(PROPFIND_BY_PROPERTY);
setOutputFilter(findOutputFilter(info));
}
VTimeZone tz = findTimeZone(info);
queryFilter = findQueryFilter(info, tz);
}
示例5: findTimeZone
import net.fortuna.ical4j.model.component.VTimeZone; //导入依赖的package包/类
private static VTimeZone findTimeZone(ReportInfo info) throws CosmoDavException {
Element propdata = DomUtils.getChildElement(getReportElementFrom(info), caldav(XML_PROP));
if (propdata == null) {
return null;
}
Element tzdata = DomUtils.getChildElement(propdata, c(ELEMENT_CALDAV_TIMEZONE));
if (tzdata == null) {
return null;
}
String icaltz = DomUtils.getTextTrim(tzdata);
if (icaltz == null) {
throw new UnprocessableEntityException("Expected text content for " + ELEMENT_CALDAV_TIMEZONE);
}
return TimeZoneExtractor.extract(icaltz);
}
示例6: TimeRangeFilter
import net.fortuna.ical4j.model.component.VTimeZone; //导入依赖的package包/类
/**
* Construct a TimeRangeFilter object from a DOM Element
* @param element The DOM Element.
* @throws ParseException - if something is wrong this exception is thrown.
*/
public TimeRangeFilter(Element element, VTimeZone timezone) throws ParseException {
// Get start (must be present)
String start =
DomUtil.getAttribute(element, ATTR_CALDAV_START, null);
if (start == null) {
throw new ParseException("CALDAV:comp-filter time-range requires a start time", -1);
}
DateTime trstart = new DateTime(start);
if (! trstart.isUtc()) {
throw new ParseException("CALDAV:param-filter timerange start must be UTC", -1);
}
// Get end (must be present)
String end =
DomUtil.getAttribute(element, ATTR_CALDAV_END, null);
DateTime trend = end != null ? new DateTime(end) : getDefaultEndDate(trstart);
if (! trend.isUtc()) {
throw new ParseException("CALDAV:param-filter timerange end must be UTC", -1);
}
setPeriod(new Period(trstart, trend));
setTimezone(timezone);
}
示例7: ComponentFilter
import net.fortuna.ical4j.model.component.VTimeZone; //导入依赖的package包/类
/**
* Construct a ComponentFilter object from a DOM Element.
* @param element The element.
* @param timezone The timezone.
* @throws ParseException - if something is wrong this exception is thrown.
*/
public ComponentFilter(Element element, VTimeZone timezone) throws ParseException {
// Name must be present
validateName(element);
final ElementIterator i = DomUtil.getChildren(element);
int childCount = 0;
while (i.hasNext()) {
final Element child = i.nextElement();
childCount++;
// if is-not-defined is present, then nothing else can be present
validateNotDefinedState(childCount);
Initializers.getInitializer(child.getLocalName()).initialize(child, timezone, this, childCount);
}
}
示例8: CalendarFilter
import net.fortuna.ical4j.model.component.VTimeZone; //导入依赖的package包/类
/**
* Construct a CalendarFilter object from a DOM Element.
* @param element The element.
* @param timezone The timezone.
* @throws ParseException - if something is wrong this exception is thrown.
*/
public CalendarFilter(Element element, VTimeZone timezone) throws ParseException {
// Can only have a single comp-filter element
final ElementIterator i = DomUtil.getChildren(element,
ELEMENT_CALDAV_COMP_FILTER, NAMESPACE_CALDAV);
if (!i.hasNext()) {
throw new ParseException(
"CALDAV:filter must contain a comp-filter", -1);
}
final Element child = i.nextElement();
if (i.hasNext()) {
throw new ParseException(
"CALDAV:filter can contain only one comp-filter", -1);
}
// Create new component filter and have it parse the element
filter = new ComponentFilter(child, timezone);
}
示例9: getVTimeZone
import net.fortuna.ical4j.model.component.VTimeZone; //导入依赖的package包/类
/**
* Return ical4j VTimeZone instance for timezone id
* @param id timezone id
* @return ical4j VTimeZone instance
*/
public static VTimeZone getVTimeZone(String id) {
if(!allTimezoneIds.contains(id)) {
return null;
}
com.ibm.icu.util.VTimeZone icuvtz = com.ibm.icu.util.VTimeZone.create(id);
if(icuvtz==null) {
return null;
}
try {
StringWriter sw = new StringWriter();
icuvtz.write(sw, TIMEZONE_START_DATE);
VTimeZone vtz = (VTimeZone) CalendarUtils.parseComponent(sw.toString());
fixIcuVTimeZone(vtz);
return vtz;
} catch (ParserException | IOException e) {
throw new CosmoException(e);
}
}
示例10: getSimpleVTimeZone
import net.fortuna.ical4j.model.component.VTimeZone; //导入依赖的package包/类
/**
* Return simple ical4j VTimeZone instance (including only relevant
* rules for given date.
* @param id timezone id
* @param time time in milliseconds to base rules off of
* @return ical4j VTimeZone instance
*/
public static VTimeZone getSimpleVTimeZone(String id, long time) {
if(!allTimezoneIds.contains(id)) {
return null;
}
com.ibm.icu.util.VTimeZone icuvtz = com.ibm.icu.util.VTimeZone.create(id);
if(icuvtz==null) {
return null;
}
StringWriter sw = new StringWriter();
try {
icuvtz.writeSimple(sw, time);
VTimeZone vtz = (VTimeZone) CalendarUtils.parseComponent(sw.toString());
return vtz;
} catch (Exception e) {
throw new CosmoException(e);
}
}
示例11: compactTimezones
import net.fortuna.ical4j.model.component.VTimeZone; //导入依赖的package包/类
/**
* Compact timezones.
* @param calendar The calendar.
*/
private void compactTimezones(Calendar calendar) {
if (calendar==null) {
return;
}
// Get list of timezones in master calendar and remove all timezone
// definitions that are in the registry. The idea is to not store
// extra data. Instead, the timezones will be added to the calendar
// by the getCalendar() api.
ComponentList<VTimeZone> timezones = calendar.getComponents(Component.VTIMEZONE);
List<VTimeZone> toRemove = new ArrayList<>();
for(VTimeZone vtz : timezones) {
String tzid = vtz.getTimeZoneId().getValue();
TimeZone tz = TIMEZONE_REGISTRY.getTimeZone(tzid);
// Remove timezone iff it matches the one in the registry
if(tz!=null && vtz.equals(tz.getVTimeZone())) {
toRemove.add(vtz);
}
}
// remove known timezones from master calendar
calendar.getComponents().removeAll(toRemove);
}
示例12: updateNoteModification
import net.fortuna.ical4j.model.component.VTimeZone; //导入依赖的package包/类
/**
* Updates note modification.
* @param noteMod The note item modified.
* @param event The event.
*/
private void updateNoteModification(NoteItem noteMod,
VEvent event) {
EventExceptionStamp exceptionStamp =
StampUtils.getEventExceptionStamp(noteMod);
exceptionStamp.setExceptionEvent(event);
// copy VTIMEZONEs to front if present
ComponentList<VTimeZone> vtimezones = exceptionStamp.getMasterStamp()
.getEventCalendar().getComponents(Component.VTIMEZONE);
for(VTimeZone vtimezone : vtimezones) {
exceptionStamp.getEventCalendar().getComponents().add(0, vtimezone);
}
noteMod.setClientModifiedDate(new Date());
noteMod.setLastModifiedBy(noteMod.getModifies().getLastModifiedBy());
noteMod.setLastModification(ContentItem.Action.EDITED);
setCalendarAttributes(noteMod, event);
}
示例13: isValid
import net.fortuna.ical4j.model.component.VTimeZone; //导入依赖的package包/类
public boolean isValid(Calendar value, ConstraintValidatorContext context) {
if(value==null) {
return true;
}
try {
Calendar calendar = (Calendar) value;
// validate entire icalendar object
calendar.validate(true);
// make sure we have a VTIMEZONE
VTimeZone timezone = (VTimeZone) calendar.getComponents()
.getComponents(Component.VTIMEZONE).get(0);
return timezone != null;
} catch(ValidationException ve) {
return false;
} catch (RuntimeException e) {
return false;
}
}
示例14: findTimeZone
import net.fortuna.ical4j.model.component.VTimeZone; //导入依赖的package包/类
private static VTimeZone findTimeZone(ReportInfo info) throws CosmoDavException {
Element propdata =
DomUtil.getChildElement(getReportElementFrom(info),
XML_PROP, NAMESPACE);
if (propdata == null) {
return null;
}
Element tzdata =
DomUtil.getChildElement(propdata, ELEMENT_CALDAV_TIMEZONE,
NAMESPACE_CALDAV);
if (tzdata == null) {
return null;
}
String icaltz = DomUtil.getTextTrim(tzdata);
if (icaltz == null) {
throw new UnprocessableEntityException("Expected text content for " + QN_CALDAV_TIMEZONE);
}
return TimeZoneExtractor.extract(icaltz);
}
示例15: testLoadSimpleTimeZone
import net.fortuna.ical4j.model.component.VTimeZone; //导入依赖的package包/类
/**
* Tests load simple timezone.
* @throws Exception - if something is wrong this exception is thrown.
*/
@Test
public void testLoadSimpleTimeZone() throws Exception {
DateTime dt1 = new DateTime("20080101T100000", TimeZoneUtils.getTimeZone("America/Chicago"));
DateTime dt2 = new DateTime("20060101T100000", TimeZoneUtils.getTimeZone("America/Chicago"));
VTimeZone vtz1 = TimeZoneUtils.getSimpleVTimeZone("America/Chicago", dt1.getTime());
Assert.assertNotNull(vtz1);
Assert.assertEquals(2, vtz1.getObservances().size());
VTimeZone vtz2 = TimeZoneUtils.getSimpleVTimeZone("America/Chicago", dt2.getTime());
Assert.assertNotNull(vtz2);
Assert.assertEquals(2, vtz2.getObservances().size());
Assert.assertFalse(vtz1.equals(vtz2));
}